-
-
Notifications
You must be signed in to change notification settings - Fork 59
369 lines (318 loc) · 11.3 KB
/
release.yml
File metadata and controls
369 lines (318 loc) · 11.3 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
name: Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
on:
create:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # Matches semantic version tags like v1.2.3
env:
artifact-prefix: pkg-${{ github.run_id }}
jobs:
release-metadata:
name: Define Release Metadata
runs-on: ubuntu-latest
environment: release
timeout-minutes: 30
outputs:
version: ${{ steps.target-version.outputs.version }}
version-tag: ${{ steps.target-version.outputs.version-tag }}
changelog: ${{ steps.changelog.outputs.release }}
should-release: ${{ steps.validate-tag.outputs.should-release }}
steps:
- name: Validate semantic version tag
id: validate-tag
run: |
if [[ "${{ github.ref_type }}" == "tag" ]] && [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "should-release=true" >> $GITHUB_OUTPUT
echo "Valid semantic version tag: ${{ github.ref_name }}"
else
echo "should-release=false" >> $GITHUB_OUTPUT
echo "Not a semantic version tag, skipping release"
fi
- uses: actions/checkout@v5
if: steps.validate-tag.outputs.should-release == 'true'
with:
fetch-depth: 0
- name: Setup git
if: steps.validate-tag.outputs.should-release == 'true'
id: setup-git
uses: ./.github/actions/setup-git-as-bot
with:
app-id: ${{ vars.MH_BOT_APP_ID }}
app-private-key: ${{ secrets.MH_BOT_APP_PRIVATE_KEY }}
- name: Enable corepack
if: steps.validate-tag.outputs.should-release == 'true'
run: corepack enable
- name: Setup Node.js
if: steps.validate-tag.outputs.should-release == 'true'
uses: actions/setup-node@v4.4.0
with:
node-version: '22.x'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock' # Cache all workspaces' yarn.lock
- name: Install Dependencies
if: steps.validate-tag.outputs.should-release == 'true'
run: yarn install --immutable
- name: Check env file
shell: bash
run: |
echo "${{ secrets.ENV_FILE }}" | base64 -d >> .env
if ! grep -q "DSN" .env; then
echo "error: DSN not found in .env file" >&2
exit 1
fi
- name: Run Tests
if: steps.validate-tag.outputs.should-release == 'true'
run: |
yarn lint
yarn ci:all
yarn check:all
- name: Confirm version
if: steps.validate-tag.outputs.should-release == 'true'
id: target-version
shell: bash
run: |
VERSION=$(jq -r .version package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version-tag=v$VERSION" >> $GITHUB_OUTPUT
- name: Extract Changelog
if: steps.validate-tag.outputs.should-release == 'true'
id: changelog
uses: zogot/kacl-parser@1.0.0
with:
version: ${{ steps.target-version.outputs.version }}
build:
name: Build (${{matrix.browser}})
needs: release-metadata
if: needs.release-metadata.outputs.should-release == 'true'
runs-on: ubuntu-latest
environment: release
strategy:
matrix:
node-version: [22.x]
browser: [chrome, edge, firefox]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Set yarn version
run: yarn set version 4.9.1
- name: Check env file
shell: bash
run: |
echo "${{ secrets.ENV_FILE }}" | base64 -d >> .env
if ! grep -q "DSN" .env; then
echo "error: DSN not found in .env file" >&2
exit 1
fi
- name: Build ${{ matrix.browser }}
run: |
yarn install --immutable
yarn check-envfile
yarn build:tools
if [ "${{ matrix.browser }}" = "chrome" ]; then
yarn build:chrome:all
elif [ "${{ matrix.browser }}" = "edge" ]; then
yarn build:edge:all
elif [ "${{ matrix.browser }}" = "firefox" ]; then
yarn build:firefox:all:self-sign
fi
- name: Archive Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.artifact-prefix }}-${{ matrix.browser}}
path: |
dist/
build/
if-no-files-found: error
retention-days: 7
github-release:
name: Create Github Release
environment: release
runs-on: ubuntu-latest
if: needs.release-metadata.outputs.should-release == 'true'
needs:
- release-metadata
- build
outputs:
release-id: ${{ steps.create-release.outputs.id }}
steps:
- uses: actions/checkout@v4
- name: Download All Artifacts
id: artifact
uses: actions/download-artifact@v7
with:
pattern: ${{ env.artifact-prefix }}-*
path: ${{ github.workspace }}/artifacts
merge-multiple: true
- name: Create Repository Release
id: create-release
uses: ncipollo/release-action@v1
with:
name: 'TwitterMediaHarvest ${{ needs.release-metadata.outputs.version-tag }}'
artifacts: ${{ format('{0}/dist/*.zip,{0}/dist/*.xpi', steps.artifact.outputs.download-path) }}
token: ${{ secrets.GITHUB_TOKEN }}
body: ${{ needs.release-metadata.outputs.changelog }}
tag: ${{ needs.release-metadata.outputs.version-tag }}
- name: Rollback Release
if: failure() && steps.create-release.outputs.id != ''
uses: author/action-rollback@stable
with:
release_id: ${{ steps.create-release.outputs.id }}
tag: ${{ needs.release-metadata.outputs.version-tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sentry-release:
name: Create Sentry Release
environment: release
runs-on: ubuntu-latest
if: needs.release-metadata.outputs.should-release == 'true'
needs:
- release-metadata
- build
- github-release
strategy:
matrix:
target: ['chrome', 'edge', 'firefox']
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4.4.0
with:
node-version: '22.x'
- name: Make release name
id: release-name
run: |
echo "name=$(node ./utils/make-release-name.mjs --browser=${{ matrix.target }})" >> $GITHUB_OUTPUT
- name: Download Artifact
id: download-artifact
uses: actions/download-artifact@v7
with:
name: ${{ env.artifact-prefix }}-${{ matrix.target }}
- name: Create Sentry release for ${{ matrix.target }}
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
# SENTRY_URL: https://sentry.io/
with:
version: ${{ steps.release-name.outputs.name }}
url_prefix: '~/'
environment: production
sourcemaps: ${{ format('{0}/build/{1}', steps.download-artifact.outputs.download-path, matrix.target) }}
chrome_release:
name: Release to Chrome Web Store
environment: release
runs-on: ubuntu-latest
if: needs.release-metadata.outputs.should-release == 'true'
needs:
- release-metadata
- build
- github-release
- sentry-release
steps:
- uses: actions/checkout@v4
- name: Download Artifact
id: download-artifact
uses: actions/download-artifact@v7
with:
name: ${{ env.artifact-prefix }}-chrome
- name: Get file path
id: get_filepath
run: |
echo "zip_file=$(ls ${{ steps.download-artifact.outputs.download-path }}/dist/*chrome*)" >> $GITHUB_OUTPUT
- name: Publish to Chrome Web Store
uses: mobilefirstllc/cws-publish@latest
with:
action: 'publish'
client_id: ${{ secrets.CWS_CLIENT }}
client_secret: ${{ secrets.CWS_SECRET }}
refresh_token: ${{ secrets.CWS_TOKEN }}
extension_id: hpcgabhdlnapolkkjpejieegfpehfdok
zip_file: ${{ steps.get_filepath.outputs.zip_file }}
xpi-release:
name: XPI Release
runs-on: ubuntu-latest
environment: release
if: needs.release-metadata.outputs.should-release == 'true'
needs:
- release-metadata
- build
- github-release
- sentry-release
env:
XPI_NAME: ${{ vars.FF_ADDON_ID_SELF_SIGN }}-${{ needs.release-metadata.outputs.version-tag }}.xpi
steps:
- uses: actions/checkout@v5
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock' # Cache all workspaces' yarn.lock
- name: Download Artifact
id: artifact
uses: actions/download-artifact@v7
with:
name: ${{ env.artifact-prefix }}-firefox
- name: Sign Firefox xpi
continue-on-error: true
run: |
npx web-ext sign \
-s ${{ steps.artifact.outputs.download-path }}/build/firefox-signed \
-a dist \
--ignore-files "*.map" \
--channel unlisted \
--api-key ${{ secrets.FF_JWT_ISSUER }} \
--api-secret ${{ secrets.FF_JWT_SECRET }}
mv dist/*.xpi dist/${{ env.XPI_NAME }}
- name: Upload files to a GitHub release
id: upload-xpi
uses: svenstaro/upload-release-action@v2
with:
file: dist/${{ env.XPI_NAME }}
asset_name: ${{ env.XPI_NAME }}
release_id: ${{ needs.github-release.outputs.release-id }}
- name: Create Gecko Release
uses: ./.github/actions/create-gecko-release
with:
id: ${{ vars.FF_ADDON_ID_SELF_SIGN }}
version: ${{ needs.release-metadata.outputs.version }}
url: ${{ steps.upload-xpi.outputs.browser_download_url }}
min-browser-version: '111.0' # TODO: This should be parsed from browserlist config
endpoint: ${{ secrets.GECKO_RELEASE_ENDPOINT }}
api-key: ${{ secrets.RELEASE_API_KEY }}
edge_release:
name: Release to Edge Add-ons Store
runs-on: ubuntu-latest
environment: release
if: needs.release-metadata.outputs.should-release == 'true'
needs:
- release-metadata
- build
- github-release
- sentry-release
steps:
- uses: actions/checkout@v4
- name: Download Artifact
id: download-artifact
uses: actions/download-artifact@v7
with:
name: ${{ env.artifact-prefix }}-edge
- name: Get file path
id: get-filepath
run: |
echo "zip_file=$(ls ${{ steps.download-artifact.outputs.download-path }}/dist/*edge*)" >> $GITHUB_OUTPUT
- name: Upload to Edge Add-ons Store
uses: wdzeng/edge-addon@v2
with:
product-id: ${{ secrets.MS_STORE_PRODUCT_ID }}
client-id: ${{ secrets.MS_STORE_CLIENT_ID }}
api-key: ${{ secrets.MS_STORE_API_KEY }}
zip-path: ${{ steps.get-filepath.outputs.zip_file }}