-
Notifications
You must be signed in to change notification settings - Fork 2
183 lines (159 loc) · 5.55 KB
/
release.yml
File metadata and controls
183 lines (159 loc) · 5.55 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
name: Release
on:
push:
branches: [main]
paths:
- manifest.json
- package.json
concurrency:
group: release
cancel-in-progress: false
permissions: {}
jobs:
check:
name: Check for version bump
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
release: ${{ steps.check.outputs.release }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- name: Read and validate version
id: version
run: |
VERSION=$(jq -r .version manifest.json)
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Invalid version in manifest.json: $VERSION"
exit 1
fi
PKG=$(jq -r .version package.json)
if [[ "$VERSION" != "$PKG" ]]; then
echo "::error::Version mismatch: manifest.json=$VERSION package.json=$PKG (keep them in sync)"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Has this version been released?
id: check
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.version.outputs.version }}
run: |
if gh release view "v$VERSION" >/dev/null 2>&1; then
echo "release=false" >> "$GITHUB_OUTPUT"
echo "v$VERSION already released — nothing to do."
else
echo "release=true" >> "$GITHUB_OUTPUT"
echo "v$VERSION is new — will build and publish."
fi
build:
name: Build extensions
needs: check
if: ${{ needs.check.outputs.release == 'true' }}
runs-on: ubuntu-latest
environment: build
permissions:
contents: write
outputs:
version: ${{ needs.check.outputs.version }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
- run: pnpm install --frozen-lockfile
- name: Build Chrome extension
run: pnpm build-chrome
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Zip Chrome extension
env:
VERSION: ${{ needs.check.outputs.version }}
run: cd dist && zip -r "../batchcamp-chrome-${VERSION}.zip" .
- name: Clean Chrome build
run: rm -rf dist
- name: Build Firefox extension
run: pnpm build-firefox
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Lint Firefox build
uses: kewisch/action-web-ext@84a13bb9e1b6108c43788ba091c41ca1dba6ad45 # v2.0
with:
cmd: lint
source: dist
channel: listed
- name: Zip Firefox extension
env:
VERSION: ${{ needs.check.outputs.version }}
run: cd dist && zip -r "../batchcamp-firefox-${VERSION}.zip" .
- name: Clean Firefox build
run: rm -rf dist
- name: Zip source for Firefox review
run: git archive --format=zip --output=batchcamp-source.zip HEAD
- name: Create release and attach builds
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.check.outputs.version }}
run: |
gh release create "v$VERSION" \
--title "v$VERSION" \
--notes "" \
"batchcamp-chrome-${VERSION}.zip" \
"batchcamp-firefox-${VERSION}.zip"
- name: Upload builds for publishing
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: extension-builds
path: |
batchcamp-chrome-${{ needs.check.outputs.version }}.zip
batchcamp-firefox-${{ needs.check.outputs.version }}.zip
batchcamp-source.zip
retention-days: 7
if-no-files-found: error
chrome:
name: Publish to Chrome Web Store
needs: build
runs-on: ubuntu-latest
environment: Chrome
permissions: {}
steps:
- name: Download builds
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: extension-builds
- name: Upload to Chrome Web Store
uses: mnao305/chrome-extension-upload@fdfe79400af990f5145a319e834aee64907ccff4 # v6.0.0
with:
file-path: batchcamp-chrome-${{ needs.build.outputs.version }}.zip
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
publish: true
firefox:
name: Publish to Firefox AMO
needs: build
runs-on: ubuntu-latest
environment: Firefox
permissions: {}
steps:
- name: Download builds
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: extension-builds
- name: Upload to Firefox AMO
uses: kewisch/action-web-ext@84a13bb9e1b6108c43788ba091c41ca1dba6ad45 # v2.0
with:
cmd: sign
source: batchcamp-firefox-${{ needs.build.outputs.version }}.zip
channel: listed
apiKey: ${{ secrets.AMO_API_KEY }}
apiSecret: ${{ secrets.AMO_API_SECRET }}
sourceCode: batchcamp-source.zip
approvalTimeout: 0