-
Notifications
You must be signed in to change notification settings - Fork 2
353 lines (307 loc) · 12.8 KB
/
release.yml
File metadata and controls
353 lines (307 loc) · 12.8 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-cli:
name: Build CLI for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --features replaygain --target ${{ matrix.target }}
env:
RUSTFLAGS: ${{ contains(matrix.target, 'windows') && '-C target-feature=+crt-static' || '' }}
- name: Upload artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: mp3rgain-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mp3rgain
- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: mp3rgain-${{ matrix.target }}
path: target/${{ matrix.target }}/release/mp3rgain.exe
build-gui:
name: Build GUI for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libxkbcommon-dev libwayland-dev libgtk-3-dev
- name: Build GUI
run: cargo build --release --manifest-path mp3rgui/Cargo.toml --target ${{ matrix.target }}
env:
RUSTFLAGS: ${{ contains(matrix.target, 'windows') && '-C target-feature=+crt-static' || '' }}
- name: Upload artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: mp3rgui-${{ matrix.target }}
path: mp3rgui/target/${{ matrix.target }}/release/mp3rgui
- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: mp3rgui-${{ matrix.target }}
path: mp3rgui/target/${{ matrix.target }}/release/mp3rgui.exe
release:
name: Create Release
needs: [build-cli, build-gui]
runs-on: macos-latest
outputs:
version: ${{ steps.version.outputs.version }}
windows_x64_sha256: ${{ steps.checksums.outputs.windows_x64_sha256 }}
windows_arm64_sha256: ${{ steps.checksums.outputs.windows_arm64_sha256 }}
macos_sha256: ${{ steps.checksums.outputs.macos_sha256 }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create universal macOS binary
run: |
mkdir -p dist
lipo -create \
artifacts/mp3rgain-x86_64-apple-darwin/mp3rgain \
artifacts/mp3rgain-aarch64-apple-darwin/mp3rgain \
-output dist/mp3rgain
chmod +x dist/mp3rgain
- name: Create macOS tarball
run: |
cd dist
tar -czvf mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz mp3rgain
shasum -a 256 mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz > mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz.sha256
- name: Create Linux tarball
run: |
cd artifacts/mp3rgain-x86_64-unknown-linux-gnu
chmod +x mp3rgain
tar -czvf ../../dist/mp3rgain-${{ github.ref_name }}-linux-x86_64.tar.gz mp3rgain
cd ../../dist
shasum -a 256 mp3rgain-${{ github.ref_name }}-linux-x86_64.tar.gz > mp3rgain-${{ github.ref_name }}-linux-x86_64.tar.gz.sha256
- name: Create Windows x86_64 zip
run: |
cd artifacts/mp3rgain-x86_64-pc-windows-msvc
zip ../../dist/mp3rgain-${{ github.ref_name }}-windows-x86_64.zip mp3rgain.exe
cd ../../dist
shasum -a 256 mp3rgain-${{ github.ref_name }}-windows-x86_64.zip > mp3rgain-${{ github.ref_name }}-windows-x86_64.zip.sha256
- name: Create Windows ARM64 zip
run: |
cd artifacts/mp3rgain-aarch64-pc-windows-msvc
zip ../../dist/mp3rgain-${{ github.ref_name }}-windows-arm64.zip mp3rgain.exe
cd ../../dist
shasum -a 256 mp3rgain-${{ github.ref_name }}-windows-arm64.zip > mp3rgain-${{ github.ref_name }}-windows-arm64.zip.sha256
- name: Create GUI universal macOS binary
run: |
lipo -create \
artifacts/mp3rgui-x86_64-apple-darwin/mp3rgui \
artifacts/mp3rgui-aarch64-apple-darwin/mp3rgui \
-output dist/mp3rgui
chmod +x dist/mp3rgui
tar -czvf dist/mp3rgui-${{ github.ref_name }}-macos-universal.tar.gz -C dist mp3rgui
rm dist/mp3rgui
- name: Create GUI Linux tarball
run: |
cd artifacts/mp3rgui-x86_64-unknown-linux-gnu
chmod +x mp3rgui
tar -czvf ../../dist/mp3rgui-${{ github.ref_name }}-linux-x86_64.tar.gz mp3rgui
- name: Create GUI Windows zip
run: |
cd artifacts/mp3rgui-x86_64-pc-windows-msvc
zip ../../dist/mp3rgui-${{ github.ref_name }}-windows-x86_64.zip mp3rgui.exe
- name: Extract checksums
id: checksums
run: |
echo "windows_x64_sha256=$(cat dist/mp3rgain-${{ github.ref_name }}-windows-x86_64.zip.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "windows_arm64_sha256=$(cat dist/mp3rgain-${{ github.ref_name }}-windows-arm64.zip.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
echo "macos_sha256=$(cat dist/mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz.sha256 | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2
with:
files: |
dist/mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz
dist/mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz.sha256
dist/mp3rgain-${{ github.ref_name }}-linux-x86_64.tar.gz
dist/mp3rgain-${{ github.ref_name }}-linux-x86_64.tar.gz.sha256
dist/mp3rgain-${{ github.ref_name }}-windows-x86_64.zip
dist/mp3rgain-${{ github.ref_name }}-windows-x86_64.zip.sha256
dist/mp3rgain-${{ github.ref_name }}-windows-arm64.zip
dist/mp3rgain-${{ github.ref_name }}-windows-arm64.zip.sha256
dist/mp3rgui-${{ github.ref_name }}-macos-universal.tar.gz
dist/mp3rgui-${{ github.ref_name }}-linux-x86_64.tar.gz
dist/mp3rgui-${{ github.ref_name }}-windows-x86_64.zip
draft: true
generate_release_notes: false
# Update Scoop bucket
update-scoop:
name: Update Scoop Bucket
needs: release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout scoop-bucket
uses: actions/checkout@v4
with:
repository: M-Igashi/scoop-bucket
token: ${{ secrets.SCOOP_BUCKET_TOKEN }}
path: scoop-bucket
- name: Update manifest
run: |
cd scoop-bucket
cat > mp3rgain.json << 'EOF'
{
"version": "${{ needs.release.outputs.version }}",
"description": "Lossless MP3 volume adjustment - a modern mp3gain replacement written in Rust",
"homepage": "https://github.com/M-Igashi/mp3rgain",
"license": "MIT",
"architecture": {
"64bit": {
"url": "https://github.com/M-Igashi/mp3rgain/releases/download/${{ github.ref_name }}/mp3rgain-${{ github.ref_name }}-windows-x86_64.zip",
"hash": "${{ needs.release.outputs.windows_x64_sha256 }}"
},
"arm64": {
"url": "https://github.com/M-Igashi/mp3rgain/releases/download/${{ github.ref_name }}/mp3rgain-${{ github.ref_name }}-windows-arm64.zip",
"hash": "${{ needs.release.outputs.windows_arm64_sha256 }}"
}
},
"bin": "mp3rgain.exe",
"checkver": "github",
"autoupdate": {
"architecture": {
"64bit": {
"url": "https://github.com/M-Igashi/mp3rgain/releases/download/v$version/mp3rgain-v$version-windows-x86_64.zip"
},
"arm64": {
"url": "https://github.com/M-Igashi/mp3rgain/releases/download/v$version/mp3rgain-v$version-windows-arm64.zip"
}
},
"hash": {
"url": "$url.sha256"
}
}
}
EOF
- name: Commit and push
run: |
cd scoop-bucket
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add mp3rgain.json
git commit -m "Update mp3rgain to ${{ needs.release.outputs.version }}" || exit 0
git push
# Update Homebrew tap
update-homebrew:
name: Update Homebrew Tap
needs: release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout homebrew-tap
uses: actions/checkout@v4
with:
repository: M-Igashi/homebrew-tap
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
run: |
cd homebrew-tap/Formula
sed -i 's|url "https://github.com/M-Igashi/mp3rgain/releases/download/v[^"]*|url "https://github.com/M-Igashi/mp3rgain/releases/download/${{ github.ref_name }}/mp3rgain-${{ github.ref_name }}-macos-universal.tar.gz|' mp3rgain.rb
sed -i 's|sha256 "[^"]*"|sha256 "${{ needs.release.outputs.macos_sha256 }}"|' mp3rgain.rb
sed -i 's|version "[^"]*"|version "${{ needs.release.outputs.version }}"|' mp3rgain.rb
- name: Commit and push
run: |
cd homebrew-tap
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/mp3rgain.rb
git commit -m "Update mp3rgain to ${{ needs.release.outputs.version }}" || exit 0
git push
# Build Debian package
build-deb:
name: Build Debian Package
needs: release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential debhelper
- name: Install Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
- name: Setup debian directory
run: cp -r packages/debian/debian .
- name: Update changelog version
run: |
VERSION=${{ needs.release.outputs.version }}
DATE=$(date -R)
cat > debian/changelog << EOF
mp3rgain (${VERSION}-1) unstable; urgency=medium
* Release ${VERSION}
-- Masanari Higashi <M-Igashi@users.noreply.github.com> ${DATE}
EOF
- name: Build package
run: dpkg-buildpackage -us -uc -b
- name: Upload to release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2
with:
files: ../mp3rgain_${{ needs.release.outputs.version }}-1_amd64.deb
# Publish to crates.io
publish-cargo:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}