Repository navigation
180 lines (152 loc) · 5.89 KB
/
Copy pathdeploy-auto.yml
File metadata and controls
180 lines (152 loc) · 5.89 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Automatic Deployment
on:
push:
tags:
- 'v*' # 当推送带有 v 前缀的标签时触发
# Unlike deploy-manual.yml, no job here asks for `fetch-tags`. This workflow is triggered *by* the
# tag, so the tag is the ref being checked out and is already there — `check-release.js` finds it.
# Asking for it on top makes checkout fetch the commit and the tag into the same `refs/tags/*`,
# which git refuses: "Cannot fetch both <sha> and refs/tags/vX to refs/tags/vX". That failure took
# down every tag-triggered release from v0.0.5 onwards.
env:
NODE_VERSION: '23.11.1'
BUILD_MODE: release
jobs:
preflight:
name: Release preflight
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --immutable
- name: Validate tag matches package version
run: |
FULL_VERSION=$(node -p "require('./lerna.json').version")
TAG_VERSION="${GITHUB_REF_NAME#v}"
if [ "$FULL_VERSION" != "$TAG_VERSION" ]; then
echo "Tag v$TAG_VERSION does not match lerna.json version $FULL_VERSION"
exit 1
fi
- name: Check release metadata
run: node scripts/release/check-release.js
- name: Run release checks
run: |
yarn format
yarn build
yarn lint
node scripts/check-packages.js
yarn typecheck
yarn test:unit --single-run
yarn test:compat:tsc
yarn test:compat:ssr
- name: Build bundle
run: yarn build:bundle
- name: Verify ES5 compatibility of the legacy bundle
run: yarn test:compat:es5
- name: Upload bundle artifact
uses: actions/upload-artifact@v4
with:
name: release-bundles
path: packages/*/bundle/**
if-no-files-found: error
deploy-prod:
needs: preflight
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn install --immutable
- name: Download verified bundle artifact
uses: actions/download-artifact@v4
with:
name: release-bundles
path: packages
- name: Get version
run: |
FULL_VERSION=$(node -p "require('./lerna.json').version")
echo "VERSION=$FULL_VERSION" >> $GITHUB_ENV
- name: Deploy to prod
run: node ./scripts/deploy/deploy-oss.js prod v${VERSION}
env:
OSS_ENDPOINT: ${{ secrets.OSS_ENDPOINT }}
OSS_REGION: ${{ secrets.OSS_REGION }}
OSS_ACCESS_KEY: ${{ secrets.OSS_ACCESS_KEY }}
OSS_BUCKET: ${{ secrets.OSS_BUCKET }}
OSS_SECRET_KEY: ${{ secrets.OSS_SECRET_KEY }}
publish-npm:
needs: deploy-prod
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: yarn install --immutable
- name: Publish to NPM
run: node ./scripts/deploy/publish-npm.js
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
notify-success:
needs: publish-npm
runs-on: ubuntu-latest
if: success()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare notification
run: |
COMMIT_MESSAGE=$(git show-branch --no-name HEAD)
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
echo "COMMIT_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}" >> $GITHUB_ENV
- name: Notify deployment success
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TALK_TOKEN }}
secret: ${{ secrets.DING_TALK_SECRET }}
body: |
{
"msgtype": "markdown",
"markdown": {
"title": "RUM sdk 部署通知",
"text": "### ✅ RUM sdk 部署成功\n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
}
}
notify-failure:
needs: publish-npm
runs-on: ubuntu-latest
if: failure()
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare notification
run: |
COMMIT_MESSAGE=$(git show-branch --no-name HEAD)
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
echo "BUILD_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
- name: Notify deployment failure
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TALK_TOKEN }}
secret: ${{ secrets.DING_TALK_SECRET }}
body: |
{
"msgtype": "markdown",
"markdown": {
"title": "RUM sdk 部署通知",
"text": "### ❌ RUM sdk 部署失败 \n\n---\n\n 🔖 分支: ${{ github.ref }}\n\n 📝 提交信息: [${{ github.event.head_commit.message }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})\n\n 👨💻 提交者: ${{ github.actor }}\n\n 🚀 [查看部署详情](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})"
}
}