-
Notifications
You must be signed in to change notification settings - Fork 1
234 lines (200 loc) · 7.12 KB
/
release.yaml
File metadata and controls
234 lines (200 loc) · 7.12 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
name: Build & Publish
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
workflow_dispatch:
permissions:
contents: write
jobs:
# --------------------------------------------------------------------
# 1) MANUAL TAG CREATION — triggers official release
# --------------------------------------------------------------------
create_tag:
name: Create Release Tag
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # required to push tags
- name: Read version from manifest.json
id: manifest
run: |
VERSION=$(jq -r '.version' manifest.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create git tag
run: |
TAG="v${{ steps.manifest.outputs.version }}"
echo "Creating tag: $TAG"
# Check if tag already exists
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "::error::Tag $TAG already exists."
exit 1
fi
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag "$TAG"
git push origin "$TAG"
# --------------------------------------------------------------------
# 2) BUILD JOB — runs for PRs, pushes, and tags
# --------------------------------------------------------------------
build:
name: Build XPI
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
major: ${{ steps.version.outputs.major }}
minor: ${{ steps.version.outputs.minor }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Read version from manifest.json
id: version
run: |
VERSION=$(jq -r '.version' manifest.json)
MAJ=$(echo "$VERSION" | cut -d. -f1)
MIN=$(echo "$VERSION" | cut -d. -f2)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "major=$MAJ" >> $GITHUB_OUTPUT
echo "minor=$MIN" >> $GITHUB_OUTPUT
- name: Build extension
id: web-ext-build
uses: kewisch/action-web-ext@v1
with:
cmd: build
source: .
filename: "{name}-{version}.xpi"
ignoreFiles: '[ ]'
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: built-xpi
path: ${{ steps.web-ext-build.outputs.target }}
# --------------------------------------------------------------------
# 3) PRE-RELEASE JOB — only runs on main/master pushes (not tags)
# --------------------------------------------------------------------
prerelease:
name: Create Pre-Release
runs-on: ubuntu-latest
needs: build
if: >
github.event_name != 'workflow_dispatch'
&& github.ref_type == 'branch' && (github.ref_name == 'main' || github.ref_name == 'master')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built XPI
uses: actions/download-artifact@v4
with:
name: built-xpi
path: xpi
- name: Extract artifact if needed
run: |
if ls xpi/*.zip 1> /dev/null 2>&1; then
unzip xpi/*.zip -d xpi/
fi
- name: Read version from manifest.json
id: version
run: |
VERSION="${{ needs.build.outputs.version }}"
MAJ="${{ needs.build.outputs.major }}"
MIN="${{ needs.build.outputs.minor }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "major=$MAJ" >> $GITHUB_OUTPUT
echo "minor=$MIN" >> $GITHUB_OUTPUT
- name: Check if full release exists
id: check_release
run: |
if gh release view "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
- name: Fail if full release already exists
if: steps.check_release.outputs.exists == 'true'
run: |
echo "Version ${{ steps.version.outputs.version }} is already released. Aborting prerelease."
exit 1
- name: Generate prerelease tag
id: prerelease_tag
run: |
VERSION=${{ steps.version.outputs.version }}
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
TAG="pre-$VERSION-$TIMESTAMP"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Create Pre-Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ steps.prerelease_tag.outputs.tag }} \
--prerelease \
--title "Pre-Release ${{ steps.prerelease_tag.outputs.tag }}" \
--notes "Automated prerelease" \
xpi/*.xpi
# --------------------------------------------------------------------
# 4) OFFICIAL RELEASE — signing + AMO upload — only for tags
# --------------------------------------------------------------------
release:
name: Sign & Publish Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@v4
# --- Generate changelog from commits since previous tag ---
- name: Generate changelog
id: changelog
run: |
LAST_TAG=$(git describe --tags --abbrev=0 --always HEAD^ 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
echo "changelog=$(git log --pretty=format:'- %s')" >> $GITHUB_OUTPUT
else
echo "changelog=$(git log $LAST_TAG..HEAD --pretty=format:'- %s')" >> $GITHUB_OUTPUT
fi
- name: Download built XPI
uses: actions/download-artifact@v4
with:
name: built-xpi
path: xpi
- name: Extract artifact if needed
run: |
if ls xpi/*.zip 1> /dev/null 2>&1; then
unzip xpi/*.zip -d xpi/
fi
- name: Determine XPI filename
id: xpi
run: |
FILE=$(ls xpi/*.xpi | head -n 1)
echo "file=$FILE" >> $GITHUB_OUTPUT
- name: Sign extension (Firefox AMO)
id: web-ext-sign
uses: kewisch/action-web-ext@v1
with:
cmd: sign
source: ${{ steps.xpi.outputs.file }}
channel: listed
apiKey: ${{ secrets.FIREFOX_JWT_ISSUER }}
apiSecret: ${{ secrets.FIREFOX_JWT_SECRET }}
metaDataFile: amo_metadata.json
approvalNotes: "Please find more information at https://github.com/tonur/music-link-redirection"
releaseNotes: ${{ steps.changelog.outputs.changelog }}
license: Unlicense
licenseFile: LICENSE
- name: Upload signed XPI to GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--notes "${{ steps.changelog.outputs.changelog }}" \
"${{ steps.web-ext-sign.outputs.target }}"