-
Notifications
You must be signed in to change notification settings - Fork 5
92 lines (75 loc) · 3.23 KB
/
build-extension.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
name: Build extension
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
jobs:
pre:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.full }}
is_prerelease: ${{ steps.version.outputs.prerelease && 'true' || 'false' }}
dist_source_zip: dist/artifacts/source/ao3-enhancements_source_${{ steps.version.outputs.full }}.zip
dist_chrome_zip: dist/artifacts/chrome/ao3-enhancements_chrome_${{ steps.version.outputs.full }}.zip
dist_firefox_zip: dist/artifacts/firefox/ao3-enhancements_firefox_${{ steps.version.outputs.full }}.zip
dist_firefox_xpi: dist/artifacts/firefox/ao3-enhancements_firefox_${{ steps.version.outputs.full }}.xpi
steps:
- name: Parse version from tag
id: version
uses: release-kit/semver@v2
build:
runs-on: ubuntu-latest
needs: pre
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
- run: bun run dist
- run: bun run dist:lint
- name: Create draft release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create --draft --generate-notes --prerelease=${{ needs.pre.outputs.is_prerelease }} v${{ needs.pre.outputs.version }} ${{ needs.pre.outputs.dist_source_zip }} ${{ needs.pre.outputs.dist_chrome_zip }}
- name: Upload dist
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
firefox:
runs-on: ubuntu-latest
needs: [pre, build]
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- uses: actions/download-artifact@v4
- name: Submit to AMO
env:
API_KEY: ${{ secrets.AMO_API_KEY }}
API_SECRET: ${{ secrets.AMO_API_SECRET }}
CHANNEL: ${{ needs.pre.outputs.is_prerelease == 'true' && 'unlisted' || 'listed' }}
run: bun x web-ext sign --config=scripts/web-ext.firefox.cjs --channel=$CHANNEL --api-key=$API_KEY --api-secret=$API_SECRET --upload-source-code=${{ needs.pre.outputs.dist_source_zip }}
- name: Rename .xpi to proper version if applicable
run: |
if ls dist/artifacts/firefox/*.xpi 1> /dev/null 2>&1; then
mv dist/artifacts/firefox/*.xpi ${{ needs.pre.outputs.dist_firefox_xpi }}
rm ${{ needs.pre.outputs.dist_firefox_zip }}
fi
- name: Upload firefox artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload v${{ needs.pre.outputs.version }} ${{ needs.pre.outputs.dist_firefox_xpi }} || gh release upload v${{ needs.pre.outputs.version }} ${{ needs.pre.outputs.dist_firefox_zip }}
chrome:
runs-on: ubuntu-latest
needs: [pre, build]
if: ${{ needs.pre.outputs.is_prerelease == 'false' }}
steps:
- uses: oven-sh/setup-bun@v2
- uses: actions/download-artifact@v4
- name: Submit to Chrome Web Store
env:
EXTENSION_ID: ${{ secrets.CHROME_EXTENSION_ID }}
CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
run: bun x chrome-webstore-upload-cli --source={{ needs.pre.outputs.dist_chrome_zip }}