-
Notifications
You must be signed in to change notification settings - Fork 14
216 lines (180 loc) · 6.25 KB
/
publish.yml
File metadata and controls
216 lines (180 loc) · 6.25 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
name: Release New Version
on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Build Extension
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Get version
id: version
run: echo "version=$(bun run scripts/get-version.mjs)" >> "$GITHUB_OUTPUT"
- name: Get changelog
id: changelog
run: |
changelog=$(bun run get-changelog)
{
echo "changelog<<EOF"
echo "$changelog"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build extension
run: |
# Make sure we pass linting before building.
bun run lint || exit 1
# Fetch external CSS files.
bun run build:css
bun run build:extension:chrome --release
bun run build:extension:firefox --release
bun run build:userscript
- name: Inject Sentry
run: |
# Create a new Sentry release, inject information, and upload source maps.
bun run sentry-cli releases new "mousehunt-improved@${{ steps.version.outputs.version }}" \
--org mousehunt \
--project mh-improved \
--auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
bun run sentry-cli sourcemaps inject dist/chrome \
--org mousehunt \
--project mh-improved \
--release "mousehunt-improved@${{ steps.version.outputs.version }}" \
--auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
bun run sentry-cli sourcemaps upload dist/chrome \
--org mousehunt \
--project mh-improved \
--release "mousehunt-improved@${{ steps.version.outputs.version }}" \
--rewrite \
--auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
bun run sentry-cli releases finalize "mousehunt-improved@${{ steps.version.outputs.version }}" \
--auth-token ${{ secrets.SENTRY_AUTH_TOKEN }}
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
- name: Zip and archive files
run: |
bun run build:zips
bun run build:archive
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: |
dist/mousehunt-improved-chrome.zip
dist/mousehunt-improved-firefox.zip
dist/firefox
dist/mousehunt-improved.user.js
dist/archive.zip
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create GitHub Release
run: |
# Create a GitHub release with the version and changelog.
VERSION_TAG="v${{ needs.build.outputs.version }}"
CHANGELOG="${{ needs.build.outputs.changelog }}"
gh release create "v"${{ needs.build.outputs.version }}" \
dist/mousehunt-improved-chrome.zip \
dist/mousehunt-improved-firefox.zip \
dist/mousehunt-improved.user.js \
--title "MouseHunt Improved v$VERSION_TAG" \
--notes "$CHANGELOG"
env:
GH_TOKEN: ${{ github.token }}
chrome-upload:
name: Upload Chrome Extension
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Upload Chrome Extension
run: |
bun run chrome-webstore-upload upload \
--source dist/mousehunt-improved-chrome.zip \
--auto-publish \
--extension-id fgjkidgknmkhnbeobehlfabjbignhkhm \
--client-id "$CHROME_CLIENT_ID" \
--client-secret "$CHROME_CLIENT_SECRET" \
--refresh-token "$CHROME_REFRESH_TOKEN"
env:
CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
firefox-upload:
name: Upload Firefox Extension
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Set up Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Upload Firefox Extension
run: |
bun run web-ext sign \
--source-dir dist/firefox \
--upload-source-code dist/archive.zip \
--api-key "$FIREFOX_API_KEY" \
--api-secret "$FIREFOX_API_SECRET" \
--channel "listed"
env:
FIREFOX_API_KEY: ${{ secrets.FIREFOX_API_KEY }}
FIREFOX_API_SECRET: ${{ secrets.FIREFOX_API_SECRET }}
userscript-upload:
name: Upload Userscript
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: 'userscript-build'
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Commit changes
run: |
# Commit the files to the userscript-build branch.
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add dist/mousehunt-improved.user.js
git commit -m "User script v${{ needs.build.outputs.version }}" || exit 0
git push origin userscript-build