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

shenyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/master by this push:
     new 29f18d6  chore: workflow enhancement (#14728)
29f18d6 is described below

commit 29f18d6e17f0c58e7b58c4d9a0984530dcc927f0
Author: Yi Shen <[email protected]>
AuthorDate: Wed Apr 21 13:31:55 2021 +0800

    chore: workflow enhancement (#14728)
---
 .github/workflows/{nodejs.yml => ci.yml}           |  33 ++---
 .github/workflows/source-release.yml               | 127 ++++++++++++++++
 build/.jshintrc                                    |  77 ----------
 build/source-release/prepareReleaseMaterials.js    | 159 +++++++++++++++++++++
 build/source-release/template/announce-release.tpl |  26 ++++
 build/source-release/template/vote-release.tpl     |  40 ++++++
 test/types/basic.ts                                |  19 +++
 test/types/event.ts                                |  19 +++
 test/types/importPartial.ts                        |  19 +++
 9 files changed, 421 insertions(+), 98 deletions(-)

diff --git a/.github/workflows/nodejs.yml b/.github/workflows/ci.yml
similarity index 62%
rename from .github/workflows/nodejs.yml
rename to .github/workflows/ci.yml
index c9495d8..1f8c7c6 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/ci.yml
@@ -30,25 +30,16 @@ jobs:
           key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ 
hashFiles('**/package-lock.json') }}
 
       - name: npm install
-        run: |
-          npm ci
-      - name: check type
-        run: |
-          npm run checktype
+        run: npm ci
+
+      # - name: check type
+      #   run: npm run checktype
+
       - name: build release
-        run: |
-          npm run release
-      - name: test generated DTS
-        run: |
-          npm run test:dts
-
-  # test:
-  #   runs-on: ubuntu-latest
-  #   needs: build
-
-  #   # if: ${{ github.base_ref == 'refs/heads/master' || github.base_ref == 
'refs/heads/release' }}
-
-  #   steps:
-  #     - name: unit test
-  #       run: |
-  #         npm run test
+        run: npm run release
+
+      - name: Test generated DTS
+        run: npm run test:dts
+
+      - name: Unit Test
+        run: npm run test
\ No newline at end of file
diff --git a/.github/workflows/source-release.yml 
b/.github/workflows/source-release.yml
new file mode 100644
index 0000000..a9740d4
--- /dev/null
+++ b/.github/workflows/source-release.yml
@@ -0,0 +1,127 @@
+name: Source Release
+
+on:
+  release:
+    types: [prereleased]
+
+jobs:
+  source:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [12.x]
+
+    steps:
+      - uses: actions/checkout@v1
+
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+
+      - name: Prepare env
+        run: |
+          echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
+
+      # TODO Check release version is RC
+      # TODO Release Note
+
+      # Archive before run others to avoid packing unkown files.
+      - name: Archive source release
+        uses: actions/upload-artifact@v2
+        with:
+          name: apache-echarts-${{env.RELEASE_VERSION}}-src
+          path: |
+            index.d.ts
+            src/
+            extension-src/
+            licenses/
+            theme/
+            build/
+            !build/source-release
+            package.json
+            package-lock.json
+            LICENSE
+            NOTICE
+            README.md
+            tsconfig.json
+            test/ut
+            test/types
+
+
+  materials:
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [12.x]
+
+    steps:
+      - uses: actions/checkout@v1
+
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+
+      - name: Prepare env
+        run: |
+          echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
+
+      - name: Cache node modules
+        uses: actions/cache@v2
+        env:
+          cache-name: cache-node-modules
+        with:
+          # npm cache files are stored in `~/.npm` on Linux/macOS
+          path: ~/.npm
+          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ 
hashFiles('**/package-lock.json') }}
+
+      - name: Prepare releaes materials
+        run: |
+          npm i
+          node build/source-release/prepareReleaseMaterials.js \
+            --rcversion ${{env.RELEASE_VERSION}} \
+            --commit ${{github.sha}} \
+            --repo ${{github.repository}} \
+            --out tmp/materials
+
+      - name: Archive materials
+        uses: actions/upload-artifact@v2
+        with:
+          name: apache-echarts-${{env.RELEASE_VERSION}}-release-materials
+          path: |
+            tmp/materials/*
+
+  validate-source:
+    runs-on: ubuntu-latest
+    needs: source
+
+    strategy:
+      matrix:
+        node-version: [12.x]
+
+    steps:
+      - name: Use Node.js ${{ matrix.node-version }}
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+
+      - name: Prepare env
+        run: |
+          echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
+
+      - name: Download source release
+        uses: actions/download-artifact@v2
+        with:
+          name: apache-echarts-${{env.RELEASE_VERSION}}-src
+          path: tmp/echarts
+
+      - name: Build source release
+        run: |
+          npm ci
+          npm run release
+          npm run test
+          npm run test:dts
+        working-directory: tmp/echarts
diff --git a/build/.jshintrc b/build/.jshintrc
deleted file mode 100644
index d219229..0000000
--- a/build/.jshintrc
+++ /dev/null
@@ -1,77 +0,0 @@
-{
-    "bitwise": false,
-    "camelcase": true,
-    "curly": true,
-    "eqeqeq": false,
-    "forin": false,
-    "immed": true,
-    "latedef": false,
-    "newcap": true,
-    "noarg": false,
-    "noempty": true,
-    "nonew": true,
-    "plusplus": false,
-    "quotmark": "single",
-    "regexp": false,
-    "undef": true,
-    "unused": "vars",
-    "strict": false,
-    "trailing": false,
-    "maxparams": 20,
-    "maxdepth": 6,
-    "maxlen": 200,
-
-    "asi": false,
-    "boss": false,
-    "debug": false,
-    "eqnull": true,
-    "esversion": 6,
-    "evil": true,
-    "expr": true,
-    "funcscope": false,
-    "globalstrict": false,
-    "iterator": false,
-    "lastsemic": false,
-    "laxbreak": true,
-    "laxcomma": false,
-    "loopfunc": false,
-    "multistr": false,
-    "onecase": false,
-    "proto": false,
-    "regexdash": false,
-    "scripturl": false,
-    "smarttabs": false,
-    "shadow": true,
-    "sub": true,
-    "supernew": false,
-    "validthis": true,
-
-    "browser": true,
-    "couch": false,
-    "devel": true,
-    "dojo": false,
-    "jquery": true,
-    "mootools": false,
-    "node": false,
-    "nonstandard": false,
-    "prototypejs": false,
-    "rhino": false,
-    "wsh": false,
-
-    "nomen": false,
-    "onevar": false,
-    "passfail": false,
-    "white": false,
-
-    "varstmt": true,
-
-    "predef": [
-        "__DEV__",
-        "global",
-        "require",
-        "exports",
-        "Buffer",
-        "module",
-        "__dirname"
-    ]
-}
\ No newline at end of file
diff --git a/build/source-release/prepareReleaseMaterials.js 
b/build/source-release/prepareReleaseMaterials.js
new file mode 100644
index 0000000..939f12c
--- /dev/null
+++ b/build/source-release/prepareReleaseMaterials.js
@@ -0,0 +1,159 @@
+/*
+* 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.
+*/
+
+
+// Prepare release materials like mail, release note
+
+const commander = require('commander');
+const fse = require('fs-extra');
+const pathTool = require('path');
+const https = require('https');
+
+commander
+    .usage('[options]')
+    .description([
+        'Generate source release'
+    ].join('\n'))
+    .option(
+        '--rcversion <version>',
+        'Release version'
+    )
+    .option(
+        '--commit <commit>',
+        'Hash of commit'
+    )
+    .option(
+        '--repo <repo>',
+        'Repo'
+    )
+    .option(
+        '--out <out>',
+        'Out directory. Default to be tmp/release-mail'
+    )
+    .parse(process.argv);
+
+const outDir = pathTool.resolve(process.cwd(), commander.out || 
'tmp/release-materials');
+const releaseCommit = commander.commit;
+if (!releaseCommit) {
+    throw new Error('Release commit is required');
+}
+const repo = commander.repo || 'apache/echarts';
+
+let rcVersion = commander.rcversion + '';
+if (rcVersion.startsWith('v')) {   // tag may have v prefix, v5.1.0
+    rcVersion = rcVersion.substr(1);
+}
+if (rcVersion.indexOf('-rc.') < 0) {
+    throw new Error('Only rc version is accepeted.');
+}
+
+const parts = /(\d+)\.(\d+)\.(\d+)\-rc\.(\d+)/.exec(rcVersion);
+if (!parts) {
+    throw new Error(`Invalid version number ${rcVersion}`);
+}
+
+const major = +parts[1];
+const minor = +parts[2];
+const patch = +parts[3];
+const rc = +parts[4];
+
+const stableVersion = `${major}.${minor}.${patch}`;
+const releaseFullName = `Apache ECharts ${stableVersion} (release candidate 
${rc})`;
+
+console.log('[Release Repo] ' + repo);
+console.log('[Release Verion] ' + rcVersion);
+console.log('[Release Commit] ' + releaseCommit);
+console.log('[Release Name] ' + releaseFullName);
+
+const voteTpl = fse.readFileSync(pathTool.join(__dirname, 
'./template/vote-release.tpl'), 'utf-8');
+const announceTpl = fse.readFileSync(pathTool.join(__dirname, 
'./template/announce-release.tpl'), 'utf-8');
+const voteUntil = new Date(+new Date() + (72 + 12) * 3600 * 1000);   // 3.5 
day.
+
+fse.ensureDirSync(outDir);
+fse.writeFileSync(
+    pathTool.resolve(outDir, 'vote.txt'),
+    voteTpl.replace(/{{ECHARTS_RELEASE_VERSION}}/g, rcVersion)
+        .replace(/{{ECHARTS_RELEASE_VERSION_FULL_NAME}}/g, releaseFullName)
+        .replace(/{{ECHARTS_RELEASE_COMMIT}}/g, releaseCommit)
+        .replace(/{{VOTE_UNTIL}}/g, voteUntil.toISOString()),
+    'utf-8'
+);
+
+fse.writeFileSync(
+    pathTool.resolve(outDir, 'announce.txt'),
+    announceTpl.replace(/{{ECHARTS_RELEASE_VERSION}}/g, stableVersion)
+        .replace(/{{ECHARTS_RELEASE_COMMIT}}/g, releaseCommit),
+    'utf-8'
+);
+
+
+// Fetch RELEASE_NOTE
+https.get({
+    hostname: 'api.github.com',
+    path: `/repos/${repo}/releases`,
+    headers: {
+        'User-Agent': 'NodeJS'
+    }
+}, function (res) {
+    console.log(`https://api.github.com/repos/${repo}/releases`);
+    if (res.statusCode !== 200) {
+        console.error(`Failed to fetch releases ${res.statusCode}`);
+        res.resume();
+        return;
+    }
+
+    res.setEncoding('utf8');
+    let rawData = '';
+    res.on('data', (chunk) => {
+        rawData += chunk;
+    });
+    res.on('end', () => {
+        let releaseNote = '';
+        try {
+            const releases = JSON.parse(rawData);
+            const found = releases.find(release => release.name === rcVersion);
+            if (!found) {
+                console.error('Can\'t found release');
+            }
+            else {
+                releaseNote = found.body.trim();
+                if (!releaseNote) {
+                    console.error('Release description is empty');
+                }
+            }
+        }
+        catch (e) {
+            console.error(e.message);
+        }
+
+        const firstLine = releaseNote.split('\n')[0];
+        if (firstLine.indexOf(stableVersion) < 0) {
+            // Add version if release note is not start with version.
+        }
+        releaseNote = `## ${stableVersion}\n\n${releaseNote}`;
+
+        fse.writeFileSync(
+            pathTool.resolve(outDir, 'RELEASE_NOTE.txt'),
+            releaseNote,
+            'utf-8'
+        );
+    });
+  }).on('error', (e) => {
+      console.error('Error', e);
+  });
\ No newline at end of file
diff --git a/build/source-release/template/announce-release.tpl 
b/build/source-release/template/announce-release.tpl
new file mode 100755
index 0000000..a19a668
--- /dev/null
+++ b/build/source-release/template/announce-release.tpl
@@ -0,0 +1,26 @@
+--- Mail to: ---
[email protected]
+------------------------------------------------------------------------------
+
+--- Subject: ---
+[ANNOUNCE] Release Apache ECharts {{ECHARTS_RELEASE_VERSION}}
+------------------------------------------------------------------------------
+
+
+Hi all,
+
+The Apache ECharts team is proud to announce Apache ECharts 
{{ECHARTS_RELEASE_VERSION}}.
+
+Apache ECharts is a powerful, interactive charting and data visualization 
library for browser.
+
+Download Links: 
https://dist.apache.org/repos/dist/release/echarts/{{ECHARTS_RELEASE_VERSION}}/
+
+Release Notes: 
http://www.apache.org/dist/echarts/{{ECHARTS_RELEASE_VERSION}}/RELEASE_NOTE.txt
+
+Website: http://echarts.apache.org/
+
+
+ECharts Resources:
+- Issue: https://github.com/apache/echarts/issues
+- Build Guide: 
https://github.com/apache/echarts/blob/{{ECHARTS_RELEASE_VERSION}}/README.md
+- Mailing list: [email protected]
diff --git a/build/source-release/template/vote-release.tpl 
b/build/source-release/template/vote-release.tpl
new file mode 100755
index 0000000..7ab367a
--- /dev/null
+++ b/build/source-release/template/vote-release.tpl
@@ -0,0 +1,40 @@
+--- Mail To: ---
[email protected]
+-----------------------------------------------------------
+
+--- Subject: ---
+[VOTE] Release {{ECHARTS_RELEASE_VERSION_FULL_NAME}}
+-----------------------------------------------------------
+
+Dear community
+
+We are pleased to be calling this vote for the release of 
{{ECHARTS_RELEASE_VERSION_FULL_NAME}}.
+
+The release candidate to be voted over is available at:
+https://dist.apache.org/repos/dist/dev/echarts/{{ECHARTS_RELEASE_VERSION}}/
+
+The release candidate is signed with a GPG key available at:
+https://dist.apache.org/repos/dist/dev/echarts/KEYS
+
+The Git commit for this release is:
+https://gitbox.apache.org/repos/asf?p=echarts.git;a=commit;h={{ECHARTS_RELEASE_COMMIT}}
+
+The Release Note is available in:
+https://dist.apache.org/repos/dist/dev/echarts/{{ECHARTS_RELEASE_VERSION}}/RELEASE_NOTE.txt
+
+Build Guide:
+https://github.com/apache/echarts/blob/{{ECHARTS_RELEASE_VERSION}}/README.md#build
+
+Please vote on releasing this package as:
+{{ECHARTS_RELEASE_VERSION_FULL_NAME}}
+by "{{VOTE_UNTIL}}".
+
+[ ] +1 Release this package
+[ ] 0 I don't feel strongly about it, but don't object
+[ ] -1 Do not release this package because...
+
+Anyone can participate in testing and voting, not just committers, please
+feel free to try out the release candidate and provide your votes.
+
+A checklist for reference:
+https://cwiki.apache.org/confluence/display/ECHARTS/Apache+ECharts+Release+Checklist
diff --git a/test/types/basic.ts b/test/types/basic.ts
index 41b6192..19bfa67 100644
--- a/test/types/basic.ts
+++ b/test/types/basic.ts
@@ -1,3 +1,22 @@
+/*
+* 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.
+*/
+
 import * as echarts from '../../';
 
 const dom = document.createElement('div');
diff --git a/test/types/event.ts b/test/types/event.ts
index ae2f698..af3511f 100644
--- a/test/types/event.ts
+++ b/test/types/event.ts
@@ -1,3 +1,22 @@
+/*
+* 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.
+*/
+
 import * as echarts from '../../';
 
 const dom = document.createElement('div');
diff --git a/test/types/importPartial.ts b/test/types/importPartial.ts
index 2f43d0b..c4eb8c7 100644
--- a/test/types/importPartial.ts
+++ b/test/types/importPartial.ts
@@ -1,3 +1,22 @@
+/*
+* 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.
+*/
+
 import {init, use, ComposeOption} from '../../core';
 import {
     BarChart,

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to