Skip to content

Commit 2bdd51b

Browse files
shungangcsg01123119YunZZY
authoredSep 6, 2023
chore: add github workflow release.yml (#1243)
* chore: add github workflow release.yml * chore: add snyk_token to yml * chore: remove snyk_token * chore: remove snyk_token * chore: remove snyk_token * chore: test puppeteer * chore: test puppeteer * chore: test puppeteer * chore: test master.yml * chore: set npm version * chore: set puppeteer version * chore: set puppeteer version --------- Co-authored-by: csg01123119 <csg01123119@alibaba-inc.com> Co-authored-by: YunZZY <1263206327@qq.com>
1 parent 13a2691 commit 2bdd51b

12 files changed

+23833
-14904
lines changed
 

‎.github/workflows/codeCov.yml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ jobs:
2323
ALI_SDK_STS_REGION: ${{secrets.ALI_SDK_STS_REGION}}
2424
ALI_SDK_STS_ROLE: ${{secrets.ALI_SDK_STS_ROLE}}
2525
ALI_SDK_STS_SECRET: ${{secrets.ALI_SDK_STS_SECRET}}
26+
2627
steps:
2728
- uses: actions/checkout@v2
2829
- name: test and report upload

‎.github/workflows/dev_node_test.yml

-6
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232

3333
steps:
3434
- uses: actions/checkout@v2
35-
with:
36-
ref: develop
3735
- name: browser build and test
3836
run: |
3937
curl cip.cc
@@ -64,8 +62,6 @@ jobs:
6462

6563
steps:
6664
- uses: actions/checkout@v2
67-
with:
68-
ref: develop
6965
- name: Use Node.js ${{ matrix.node-version }}
7066
uses: actions/setup-node@v2
7167
with:
@@ -97,8 +93,6 @@ jobs:
9793

9894
steps:
9995
- uses: actions/checkout@v2
100-
with:
101-
ref: develop
10296
- name: Use Node.js ${{ matrix.node-version }}
10397
uses: actions/setup-node@v2
10498
with:

‎.github/workflows/master_node_test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
uses: actions/setup-node@v2
6767
with:
6868
node-version: ${{ matrix.node-version }}
69+
- run: npm install -D npm@6.14.12
6970
- run: npm install
7071
- run: npm run test
7172

@@ -97,6 +98,7 @@ jobs:
9798
uses: actions/setup-node@v2
9899
with:
99100
node-version: ${{ matrix.node-version }}
101+
- run: npm install -D npm@6.14.16
100102
- run: npm install
101103
- run: npm run test
102104

@@ -128,5 +130,6 @@ jobs:
128130
uses: actions/setup-node@v2
129131
with:
130132
node-version: ${{ matrix.node-version }}
133+
- run: npm install -D npm@6.14.18
131134
- run: npm install
132135
- run: npm run test

‎.github/workflows/release.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
permissions:
12+
# https://docs.github.com/zh/actions/using-jobs/assigning-permissions-to-jobs
13+
contents: write # 为 GITHUB_TOKEN 授予更新tag的权限
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} # semantic-release和create-pull-request.js需要
16+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # 只有semantic-release需要
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Setup Node
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: 18
25+
- name: Install Dependencies
26+
run: npm install
27+
- name: Snyk Protect
28+
run: npm run snyk-protect
29+
- name: Release to npm
30+
run: npx semantic-release
31+
# - name: Publish to cdn
32+
# run: node publish.js # 因为发cdn 的ak权限比较大,有安全风险,故需要在本地发版到cdn
33+
# 为了创建pr,GIT_TOKEN需要public_repo权限(https://github.com/settings/tokens/new)
34+
- name: Create Pull Request
35+
run: node ./task/create-pull-request.js

‎.github/workflows/snyk.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ jobs:
1010
security:
1111
environment: ali_oss_AK
1212
runs-on: ubuntu-latest
13+
1314
steps:
1415
- uses: actions/checkout@v2
1516

‎.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

‎.releaserc

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"branches": "release",
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/github",
7+
[
8+
"@semantic-release/npm",
9+
{
10+
"npmPublish": true
11+
}
12+
],
13+
[
14+
"@semantic-release/exec",
15+
{
16+
"prepareCmd": "npm run build-dist"
17+
}
18+
],
19+
[
20+
"@semantic-release/git",
21+
{
22+
"assets": [
23+
"package.json",
24+
"lib/browser/version.js",
25+
"dist/*.js"
26+
],
27+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
28+
}
29+
]
30+
]
31+
}

‎browser-build.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function build(options, callback) {
2121
options = {};
2222
}
2323

24-
console.error('Building with options: %j', options);
24+
console.error('Building with options: %j %j', options, pkg.version);
2525

2626
const verStr = `exports.version = '${pkg.version}';`;
2727
fs.writeFileSync(path.resolve(__dirname + '/lib/browser/version.js'), verStr);

‎commitlint.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = { extends: ['@commitlint/config-conventional'] };
1+
module.exports = { extends: ['@commitlint/config-conventional'], ignores: [message => /\[skip ci\]/m.test(message)] };

‎package-lock.json

+23,719-14,889
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+16-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"publish-to-npm": "node publish-npm-check.js && npm publish",
3131
"publish-to-cdn": "node publish.js",
3232
"snyk-protect": "snyk-protect",
33-
"prepublish": "npm run snyk-protect",
3433
"lint-staged": "lint-staged",
3534
"detect-secrets": "node task/detect-secrets",
3635
"tsc": "npm run tsc:clean && npm run tsc:build",
@@ -46,9 +45,18 @@
4645
"npm run publish-to-cdn"
4746
]
4847
},
48+
"homepage": "https://github.com/ali-sdk/ali-oss",
49+
"bugs": {
50+
"url": "https://github.com/ali-sdk/ali-oss/issues"
51+
},
52+
"publishConfig": {
53+
"registry": "https://registry.npmjs.org/",
54+
"access": "public",
55+
"tag": "testtag"
56+
},
4957
"repository": {
5058
"type": "git",
51-
"url": "git://github.com/aliyun/oss-nodejs-sdk.git"
59+
"url": "https://github.com/ali-sdk/ali-oss.git"
5260
},
5361
"keywords": [
5462
"oss",
@@ -58,13 +66,9 @@
5866
],
5967
"author": "dead_horse",
6068
"license": "MIT",
61-
"bugs": {
62-
"url": "https://github.com/aliyun/oss-nodejs-sdk/issues"
63-
},
6469
"engines": {
6570
"node": ">=8"
6671
},
67-
"homepage": "https://github.com/aliyun/oss-nodejs-sdk",
6872
"devDependencies": {
6973
"@babel/core": "^7.11.6",
7074
"@babel/plugin-transform-regenerator": "^7.10.4",
@@ -73,6 +77,10 @@
7377
"@babel/runtime": "^7.11.2",
7478
"@commitlint/cli": "^17.6.7",
7579
"@commitlint/config-conventional": "^16.2.4",
80+
"@octokit/core": "^5.0.0",
81+
"@semantic-release/exec": "^6.0.3",
82+
"@semantic-release/git": "^10.0.1",
83+
"@semantic-release/npm": "^10.0.5",
7684
"@snyk/protect": "^1.1196.0",
7785
"@types/node": "^14.0.12",
7886
"@typescript-eslint/eslint-plugin": "^5.0.0",
@@ -112,7 +120,8 @@
112120
"nyc": "^15.1.0",
113121
"prettier": "^3.0.0",
114122
"promise-polyfill": "^6.0.2",
115-
"puppeteer": "^20.9.0",
123+
"puppeteer": "19.0.0",
124+
"semantic-release": "^21.1.1",
116125
"should": "^11.0.0",
117126
"sinon": "^15.2.0",
118127
"standard-version": "^9.3.1",

‎task/create-pull-request.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const { Octokit } = require('@octokit/core');
2+
const pkg = require('../package.json');
3+
4+
const { env } = process;
5+
6+
// Octokit.js
7+
// https://github.com/octokit/core.js#readme
8+
const octokit = new Octokit({
9+
auth: env.GITHUB_TOKEN
10+
});
11+
12+
// https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request
13+
octokit.request('POST /repos/{owner}/{repo}/pulls', {
14+
owner: 'ali-sdk',
15+
repo: 'ali-oss',
16+
title: `release ${pkg.version} success to master`,
17+
body: 'release to master',
18+
head: 'release',
19+
base: 'master',
20+
headers: {
21+
'X-GitHub-Api-Version': '2022-11-28'
22+
}
23+
});

0 commit comments

Comments
 (0)
Please sign in to comment.