Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/nightly-next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Nightly Next

on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch: {}
repository_dispatch:
types: publish-nightly-next

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
with:
ref: next

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
registry-url: https://registry.npmjs.org/
- name: Setup and publish nightly
run: |
npm ci
npm run release
npm run prepare:nightly-next
npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
44 changes: 27 additions & 17 deletions build/prepareNightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,36 @@ const fs = require('fs');
const packageJsonPath = __dirname + '/../package.json';
const nightlyPackageName = 'zrender-nightly';

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
const version = packageJson.version;
const parts = /(\d+)\.(\d+)\.(\d+)($|\-)/.exec(version);
if (!parts) {
throw new Error(`Invalid version number ${version}`);
}
// Add date to version.
const major = +parts[1];
const minor = +parts[2];
let patch = +parts[3];
const isStable = !parts[4];
if (isStable) {
// It's previous stable version. Dev version should be higher.
patch++;
function updateVersion(version) {
const isNext = process.argv.includes('--next');
const parts = /(\d+)\.(\d+)\.(\d+)($|\-)/.exec(version);
if (!parts) {
throw new Error(`Invalid version number ${version}`);
}
// Add date to version.
const major = +parts[1];
let minor = +parts[2];
let patch = +parts[3];
const isStable = !parts[4];
if (isStable) {
// It's previous stable version. Dev version should be higher.
if (isNext) {
// Increase minor version for next branch.
minor++;
}
else {
// Increase main version for master branch.
patch++;
}
}

const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8);
return `${major}.${minor}.${patch}-dev.${date}`;
}

const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8);
const nightlyVersion = `${major}.${minor}.${patch}-dev.${date}`;

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
packageJson.name = nightlyPackageName;
packageJson.version = nightlyVersion;
packageJson.version = updateVersion(packageJson.version);

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build": "npm run build:bundle && npm run build:lib",
"release": "node build/build.js --minify && npm run build:lib",
"prepare:nightly": "node build/prepareNightly.js",
"prepare:nightly-next": "node build/prepareNightly.js --next",
"build:bundle": "node build/build.js",
"build:lib": "npx tsc -m ES2015 --outDir lib",
"watch:bundle": "node build/build.js --watch",
Expand Down Expand Up @@ -51,4 +52,4 @@
"typescript": "4.3.5",
"uglify-js": "^3.10.0"
}
}
}