-
-
Notifications
You must be signed in to change notification settings - Fork 48
306 lines (260 loc) · 10.6 KB
/
build.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
name: CI
on:
push:
branches:
- main
tags:
- v*
env:
TEST_TAG: mansuf/mangadex-downloader:test
TEST_OPTIONAL_TAG: mansuf/mangadex-downloader:test-optional
DOCKERHUB_LATEST_TAG: mansuf/mangadex-downloader:latest
DOCKERHUB_LATEST_OPTIONAL_TAG: mansuf/mangadex-downloader:latest-optional
AWS_ECR_LATEST_TAG: public.ecr.aws/n3n5b0s8/mangadex-downloader:latest
AWS_ECR_LATEST_OPTIONAL_TAG: public.ecr.aws/n3n5b0s8/mangadex-downloader:latest-optional
jobs:
docker-build-test:
name: Docker build test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_SECRET_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: Build and export to Docker (with optional dependencies)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
load: true
tags: ${{ env.TEST_OPTIONAL_TAG }}
- name: Test docker image
run: |
docker run --rm ${{ env.TEST_TAG }}
- name: Test docker image (with optional dependencies)
run: |
docker run --rm ${{ env.TEST_OPTIONAL_TAG }}
docker-dockerhub-build-and-push:
name: Docker build and push (hub.docker.com)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_SECRET_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
push: true
tags: |
${{ env.DOCKERHUB_LATEST_TAG }}
mansuf/mangadex-downloader:${{ github.ref_name }}
- name: Build and push (with optional dependencies)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
push: true
tags: |
${{ env.DOCKERHUB_LATEST_OPTIONAL_TAG }}
mansuf/mangadex-downloader:${{ github.ref_name }}-optional
docker-aws-ecr-build-and-push:
name: Docker build and push (public.ecr.aws)
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to AWS ECR
uses: docker/login-action@v3
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
linux/arm/v6
push: true
tags: |
${{ env.AWS_ECR_LATEST_TAG }}
public.ecr.aws/mansuf/mangadex-downloader:${{ github.ref_name }}
- name: Build and push (with optional dependencies)
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.optional
platforms: |
linux/amd64
linux/arm64
linux/arm/v7
push: true
tags: |
${{ env.AWS_ECR_LATEST_OPTIONAL_TAG }}
public.ecr.aws/mansuf/mangadex-downloader:${{ github.ref_name }}-optional
windows-build:
name: Build app & docs (Windows)
runs-on: windows-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10' ]
steps:
# Make sure cancels CI when tags is released
- name: Cancel previous runs
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader'
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
all_but_latest: true
- name: Clone repo
uses: actions/checkout@v3
- name: Setup python (x64)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Setup python (x86)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x86
- name: Install required libraries
run: |
py -${{ matrix.python-version }}-64 -m pip install -U pip
py -${{ matrix.python-version }}-64 -m pip install -U wheel pyinstaller setuptools
py -${{ matrix.python-version }}-64 -m pip install -U .[optional]
py -${{ matrix.python-version }}-32 -m pip install -U pip
py -${{ matrix.python-version }}-32 -m pip install -U wheel pyinstaller setuptools
py -${{ matrix.python-version }}-32 -m pip install -U .[optional]
- name: Test imports
run: |
# I..... have no idea for this
mangadex-dl --version
- name: Get python version
run: |
$PythonVersion = (python --version)
Write-Output "python_version=${PythonVersion}" | Out-File -FilePath $env:GITHUB_ENV -Append
# Build mangadex-downloader with PyInstaller
# only allow python 3.10
- name: Setup python (x86)
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x86
- name: Compile script
if: ${{ contains(env.python_version, '3.10') }}
run: |
py -${{ matrix.python-version }}-64 -m PyInstaller "mangadex-dl_x64.spec" --distpath "./dist_x64"
py -${{ matrix.python-version }}-32 -m PyInstaller "mangadex-dl_x86.spec" --distpath "./dist_x86"
- name: Run compiled script
if: ${{ contains(env.python_version, '3.10') }}
run: |
& ".\dist_x64\mangadex-dl_x64\mangadex-dl_x64.exe" --version
& ".\dist_x86\mangadex-dl_x86\mangadex-dl_x86.exe" --version
- name: Cleanup build
if: contains(env.python_version, '3.10')
run: |
# x86 executable
copy "LICENSE" "dist_x86\mangadex-dl_x86"
copy "README.md" "dist_x86\mangadex-dl_x86"
copy "docs\changelog.md" "dist_x86\mangadex-dl_x86"
echo "${{ github.ref_name }}" | Out-File -FilePath "dist_x86\mangadex-dl_x86\version.txt" -NoNewLine
echo "mangadex-dl.exe --update" | Out-File -FilePath "dist_x86\mangadex-dl_x86\update.bat"
echo "start cmd" | Out-File -FilePath "dist_x86\mangadex-dl_x86\start cmd.bat"
Rename-Item -Path "dist_x86\mangadex-dl_x86\mangadex-dl_x86.exe" -NewName "mangadex-dl.exe"
Rename-Item -Path "dist_x86\mangadex-dl_x86" -NewName "mangadex-dl"
Compress-Archive -Path "dist_x86\mangadex-dl" -DestinationPath "mangadex-dl_x86_${{ github.ref_name }}.zip"
# x64 executable
copy "LICENSE" "dist_x64\mangadex-dl_x64"
copy "README.md" "dist_x64\mangadex-dl_x64"
copy "docs\changelog.md" "dist_x64\mangadex-dl_x64"
echo "${{ github.ref_name }}" | Out-File -FilePath "dist_x64\mangadex-dl_x64\version.txt" -NoNewLine
echo "mangadex-dl.exe --update" | Out-File -FilePath "dist_x64\mangadex-dl_x64\update.bat"
echo "start cmd" | Out-File -FilePath "dist_x64\mangadex-dl_x64\start cmd.bat"
Rename-Item -Path "dist_x64\mangadex-dl_x64\mangadex-dl_x64.exe" -NewName "mangadex-dl.exe"
Rename-Item -Path "dist_x64\mangadex-dl_x64" -NewName "mangadex-dl"
Compress-Archive -Path "dist_x64\mangadex-dl" -DestinationPath "mangadex-dl_x64_${{ github.ref_name }}.zip"
- name: Upload artifact (x64)
if: contains(env.python_version, '3.10')
uses: actions/upload-artifact@v3
with:
name: mangadex-dl_x64
path: dist_x64/mangadex-dl/
- name: Upload artifact (x86)
if: contains(env.python_version, '3.10')
uses: actions/upload-artifact@v3
with:
name: mangadex-dl_x86
path: dist_x86/mangadex-dl/
- name: Get File hash
if: contains(env.python_version, '3.10')
run: |
$File_x86 = "mangadex-dl_x86_${{ github.ref_name }}.zip"
$File_x64 = "mangadex-dl_x64_${{ github.ref_name }}.zip"
$Hash_x86 = (Get-FileHash -Algorithm SHA256 ${File_x86}).Hash.ToLower()
$Hash_x64 = (Get-FileHash -Algorithm SHA256 ${File_x64}).Hash.ToLower()
echo "mangadex_dl_x64_hash=${Hash_x64}" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "mangadex_dl_x86_hash=${Hash_x86}" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "${File_x64} Hash = ${Hash_x64}"
echo "${File_x86} Hash = ${Hash_x86}"
- name: Create Release
if: startsWith(github.ref, 'refs/tags/') && contains(env.python_version, '3.10') && github.repository == 'mansuf/mangadex-downloader'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.GIRHUB_REF_NAME }}
name: mangadex-downloader ${{ github.ref_name }}
body: |
------
## Files hash
| Name | SHA-256 |
| ---- | ------- |
| mangadex-dl_x64_${{ github.ref_name }}.zip | ${{ env.mangadex_dl_x64_hash }} |
| mangadex-dl_x86_${{ github.ref_name }}.zip | ${{ env.mangadex_dl_x86_hash }} |
These binaries are for Windows only.
files: |
mangadex-dl_x64_${{ github.ref_name }}.zip
mangadex-dl_x86_${{ github.ref_name }}.zip
draft: true
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}