You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/04/22 10:51:01 UTC

[echarts] 01/01: chore: add nightly build workflow

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch add-nightly-build
in repository https://gitbox.apache.org/repos/asf/echarts.git

commit 60d5ca620d811b366297ac94eace985706a8b8a8
Author: pissang <bm...@gmail.com>
AuthorDate: Thu Apr 22 18:49:35 2021 +0800

    chore: add nightly build workflow
---
 .github/workflows/nightly.yml | 32 ++++++++++++++++++++++
 build/prepareNightly.js       | 62 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+)

diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
new file mode 100644
index 0000000..db67ec0
--- /dev/null
+++ b/.github/workflows/nightly.yml
@@ -0,0 +1,32 @@
+name: Publish Nightly
+
+on:
+  schedule:
+    - cron: '0 9 * * *' # After zrender nightly published
+  repository_dispatch:
+    types: publish-nightly
+
+jobs:
+  build:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [12.x]
+
+    steps:
+      - uses: actions/checkout@v2
+      - 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 test
+          npm run test:dts
+          node build/prepareNightly.js
+          npm publish
+        env:
+          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
diff --git a/build/prepareNightly.js b/build/prepareNightly.js
new file mode 100644
index 0000000..e44016e
--- /dev/null
+++ b/build/prepareNightly.js
@@ -0,0 +1,62 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+
+const fs = require('fs');
+const packageJsonPath = __dirname + '/../package.json';
+const nightlyPackageName = 'echarts-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 notDev = !(parts[4] && parts[4].includes('-dev'));
+if (notDev) {
+    // It's previous stable or rc version. Dev version should be higher.
+    patch++;
+}
+
+const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8);
+const nightlyVersion = `${major}.${minor}.${patch}-dev.${date}`;
+
+packageJson.name = nightlyPackageName;
+packageJson.version = nightlyVersion;
+
+fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
+
+
+const readmePath = __dirname + '/../README.md';
+const readmeAttention = `<div style="color:red;font-weight:bold;">
+<p style="font-size:22px;text-transform:uppercase">⚠️ Attention Please</p>
+<p style="font-size:16px">This is nightly build of Apache ECharts. Please DON't use it in your production environment.</p>
+</div>`;
+const readmeContent = fs.readFileSync(readmePath, 'utf-8');
+if (!readmeContent.includes(readmeAttention)) {
+    fs.writeFileSync(readmePath, `
+${readmeAttention}
+
+${readmeContent}
+`, 'utf-8');
+}
\ No newline at end of file

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org