-
-
Notifications
You must be signed in to change notification settings - Fork 3
215 lines (212 loc) · 6.5 KB
/
pull_requests.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
name: PR Build Checks
on:
pull_request:
branches:
- master
- releases/**
defaults:
run:
shell: bash
env:
project-name: qBitrr
jobs:
package:
if: github.event.pull_request.draft == false
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python:
- '3.10'
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:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- 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: 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: Set archive name
run: |
ARCHIVE_NAME=${{ env.project-name }}-${{ steps.git_hash.outputs.HASH }}-${{ matrix.os }}-${{ matrix.arch }}
echo "Archive name set to: $ARCHIVE_NAME"
echo "NAME=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
id: archieve
- name: Update git hash
run: |
sed -i -e 's/git_hash = \".*\"/git_hash = \"${{ steps.git_hash.outputs.HASH }}\"/g' ./qBitrr/bundled_data.py
- name: Retrieve current version
run: |
echo "Current version: $(python setup.py --version)"
echo "VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
id: current_version
- 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 }}.*
if-no-files-found: error
docker_image:
name: Build Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- 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=ref,event=pr
- name: Build and push Docker images
env:
DOCKER_BUILDKIT: 1
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
docker_image_arm:
name: Build ARM Docker Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- id: string
uses: ASzc/change-string-case-action@v6
with:
string: ${{ github.repository }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- 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 ARM Docker
id: meta-arm
uses: docker/metadata-action@v5
with:
images: |
feramance/qbitrr
ghcr.io/${{ steps.string.outputs.lowercase }}
tags: |
type=ref,event=pr,suffix=-arm
- name: Build and push ARM Docker images
env:
DOCKER_BUILDKIT: 1
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: true
tags: ${{ steps.meta-arm.outputs.tags }}
labels: ${{ steps.meta-arm.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max