-
Notifications
You must be signed in to change notification settings - Fork 136
93 lines (79 loc) · 2.83 KB
/
release_candidate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Release Candidate
on:
workflow_dispatch:
inputs:
ref:
description: 'A valid branch or commit hash, eg: v2.14, master'
required: true
default: 'master'
distTag:
description: '要发布的 dist tag,仅可以为 alpha 或 beta'
required: true
default: 'beta'
jobs:
rc-version:
name: RC Version
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
# 判断用户是否有写权限
- name: 'Check if user has write access'
uses: 'lannonbr/repo-permission-check-action@2.0.0'
with:
permission: 'write'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Checkout 到指定分支
- uses: actions/checkout@v2
if: success()
with:
ref: ${{ github.event.inputs.ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
# 安装依赖并构建
- name: Install dependencies & Build
run: |
npm i
- name: Publish version
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
node ./scripts/publishRC
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
DIST_TAG: ${{ github.event.inputs.distTag }}
- name: Set Current Version
if: success()
run: |
DIST_VERSION=$(node -p 'require("./package.json").version')
echo "DIST_VERSION=${DIST_VERSION}" >> $GITHUB_ENV
- name: Adding markdown
if: success()
run: |
DIST_VERSION=$(node -p 'require("./package.json").version')
echo '### Released :rocket:' $DIST_VERSION >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo $DIST_VERSION >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo 'user input ref:' $INPUT_REF >> $GITHUB_STEP_SUMMARY
echo '```log' >> $GITHUB_STEP_SUMMARY
git log --oneline -1 >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
env:
INPUT_REF: ${{ github.event.inputs.ref }}
- name: Add Tag
if: success()
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
git tag ${{ env.DIST_VERSION }}
git push origin ${{ env.DIST_VERSION }}:${{ env.DIST_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}