-
-
Notifications
You must be signed in to change notification settings - Fork 3
402 lines (399 loc) · 13.7 KB
/
release.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
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
name: Create a Release
on:
push:
branches:
- master
defaults:
run:
shell: bash
env:
project-name: qBitrr
GREN_GITHUB_TOKEN: ${{ secrets.PAT }}
jobs:
bump_version:
name: Bump release version
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.head_commit.message, '[patch]') || startsWith(github.event.head_commit.message, '[minor]')|| startsWith(github.event.head_commit.message, '[major]') }}
env:
RELEASE_TYPE: ${{ startsWith(github.event.head_commit.message, '[patch]') && 'patch' || startsWith(github.event.head_commit.message, '[minor]') && 'minor' || startsWith(github.event.head_commit.message, '[major]') && 'major' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump2version setuptools wheel twine
- name: Retrieve current version
run: |
echo "Current version: $(python setup.py --version)"
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
id: current_version
- name: Bump Patch Version
run: |
bump2version --current-version $(python setup.py --version) ${{ env.RELEASE_TYPE }}
- name: Retrieve new version
run: |
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
id: new_version
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
id: import_gpg
- name: Git Auto Commit
uses: stefanzweifel/[email protected]
with:
commit_message: '[skip ci]Automated version bump: v${{ github.job.get_current_version.current_version.outputs.VERSION }} >> v${{ steps.new_version.outputs.VERSION }}'
tagging_message: v${{ steps.new_version.outputs.VERSION }}
commit_options: -S
commit_user_name: ${{ steps.import_gpg.outputs.name }}
commit_user_email: ${{ steps.import_gpg.outputs.email }}
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}>
outputs:
RELEASE_TYPE: ${{ env.RELEASE_TYPE }}
NEW_RELEASE: ${{ steps.new_version.outputs.VERSION }}
release:
name: Create a GitHub Release
needs: [bump_version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
token: ${{ secrets.PAT }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
id: import_gpg
- uses: ModeSevenIndustrialSolutions/action-automatic-releases@latest
with:
repo_token: ${{ secrets.PAT }}
prerelease: false
automatic_release_tag: v${{needs.bump_version.outputs.NEW_RELEASE}}
title: v${{needs.bump_version.outputs.NEW_RELEASE}}
release_hash:
name: Update The Version Hash
needs: [bump_version, release]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
fetch-depth: 0
ref: master
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Get git hash
run: |
echo "Current Hash: $(git rev-parse --short HEAD)"
echo "HASH=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
id: git_hash
- name: Update git hash
run: |
sed -i -e 's/git_hash = \".*\"/git_hash = \"${{ steps.git_hash.outputs.HASH }}\"/g' ./qBitrr/bundled_data.py
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
id: import_gpg
- name: Git Auto Commit
uses: stefanzweifel/[email protected]
with:
commit_message: '[skip ci] Update Release Hash for v${{needs.bump_version.outputs.NEW_RELEASE}}'
commit_options: -S
commit_user_name: ${{ steps.import_gpg.outputs.name }}
commit_user_email: ${{ steps.import_gpg.outputs.email }}
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}>
outputs:
RELEASE_HASH: ${{ steps.git_hash.outputs.HASH }}
publish:
name: Publish to PyPi
needs: [bump_version, release, release_hash, docker_image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build wheel
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
package:
name: Build Binaries
needs: [bump_version, release, release_hash, docker_image]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python:
- 3.10.11
os:
- windows-latest
- macOS-latest
- ubuntu-latest
arch:
- x86
- x64
- arm64
exclude:
- os: ubuntu-latest
arch: x86
- os: ubuntu-latest
arch: arm64
- os: macOS-latest
arch: x64
- os: macOS-latest
arch: x86
- os: windows-latest
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- name: Install Homebrew dependencies
if: runner.os == 'MacOS'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python}}
architecture: ${{ matrix.arch }}
- name: Install APT dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libsdl2-dev
- name: Set archive name
run: |
ARCHIVE_NAME=${{ env.project-name }}-${{ needs.release_hash.outputs.RELEASE_HASH }}-${{ matrix.os }}-${{ matrix.arch }}
echo "Archive name set to: $ARCHIVE_NAME"
echo "NAME=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
id: archieve
- name: Install Python dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools==69.5.1
python -m pip install -U wheel
python -m pip install -r requirements.dev.txt
- name: Run PyInstaller
env:
PYTHONOPTIMIZE: 1 # Enable optimizations as if the -O flag is given.
PYTHONHASHSEED: 42 # Try to ensure deterministic results.
PYTHONUNBUFFERED: 1
run: |
pyinstaller build.spec
# This step exists for debugging. Such as checking if data files were included correctly by PyInstaller.
- name: List distribution files
run: |
find dist
# Archive the PyInstaller build using the appropriate tool for the platform.
- name: Tar files
if: runner.os != 'Windows'
run: |
tar --format=ustar -czvf ${{ steps.archieve.outputs.NAME }}.tar.gz dist/
- name: Archive files
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive dist/* ${{ steps.archieve.outputs.NAME }}.zip
# Upload archives as artifacts, these can be downloaded from the GitHub actions page.
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: automated-build-${{ steps.archieve.outputs.NAME }}
path: ${{ steps.archieve.outputs.NAME }}.*
retention-days: 7
if-no-files-found: error
- name: Upload release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.PAT }}
file: ${{ steps.archieve.outputs.NAME }}.*
file_glob: true
tag: v${{needs.bump_version.outputs.NEW_RELEASE}}
overwrite: true
docker_image_arm:
name: Build ARM Docker Image
needs: [bump_version, release, release_hash]
runs-on: ubuntu-latest
steps:
- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REG_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
feramance/qbitrr
ghcr.io/${{ steps.string.outputs.lowercase }}
tags: |
type=edge
- name: Build and push
env:
DOCKER_BUILDKIT: 1
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: true
tags: feramance/qbitrr:nightly-arm,feramance/qbitrr:latest-arm,feramance/qbitrr:v${{needs.bump_version.outputs.NEW_RELEASE}}-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:nightly-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:latest-arm,ghcr.io/${{ steps.string.outputs.lowercase }}:v${{needs.bump_version.outputs.NEW_RELEASE}}-arm
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
docker_image:
name: Build Docker Image
needs: [bump_version, release, release_hash]
runs-on: ubuntu-latest
steps:
- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REG_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
feramance/qbitrr
ghcr.io/${{ steps.string.outputs.lowercase }}
tags: |
type=edge
- name: Build and push
env:
DOCKER_BUILDKIT: 1
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: feramance/qbitrr:nightly,feramance/qbitrr:latest,feramance/qbitrr:v${{needs.bump_version.outputs.NEW_RELEASE}},ghcr.io/${{ steps.string.outputs.lowercase }}:nightly,ghcr.io/${{ steps.string.outputs.lowercase }}:latest,ghcr.io/${{ steps.string.outputs.lowercase }}:v${{needs.bump_version.outputs.NEW_RELEASE}}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
change_logs:
name: Generate Change Logs and Release Notes
needs: [bump_version, release, release_hash, docker_image, publish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- uses: actions/setup-node@v4
with:
node-version: latest
- run: npm install github-release-notes -g
- name: Release Notes and Change logs
run: |
gren release
gren changelog
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
id: import_gpg
- name: Git Auto Commit
uses: stefanzweifel/[email protected]
with:
commit_message: '[skip ci] Update CHANGELOG.md and Release Notes for v${{needs.bump_version.outputs.NEW_RELEASE}}'
commit_options: -S
commit_user_name: ${{ steps.import_gpg.outputs.name }}
commit_user_email: ${{ steps.import_gpg.outputs.email }}
commit_author: ${{ steps.import_gpg.outputs.name }} <${{ steps.import_gpg.outputs.email }}>