-
Notifications
You must be signed in to change notification settings - Fork 63
540 lines (507 loc) · 18.9 KB
/
release_bundler.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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
name: package builder release
on:
workflow_dispatch:
inputs:
version:
description: 'version'
required: true
files:
required: true
type: boolean
pip:
required: true
type: boolean
docker:
required: true
type: boolean
docker_old:
required: true
type: boolean
jobs:
create_version:
runs-on: ubuntu-20.04
if: ${{ inputs.files}}
name: create version doc
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{inputs.version}}
- name: update line
run:
sed -i -e s/'>=3.7.0,<4'/'>=3.7.0,<3.13'/ pyproject.toml
- name: Set up Python 3.11.5
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: install dunamai
run: pip install dunamai
- name: replace_version
run: |
sed -i -e s/'from dunamai import Version,Pattern'// ofscraper/__version__.py
sed -i -e s/'Version.from_git(pattern=.*'/\""$(dunamai from git --format "{base}" --pattern "(?P<base>\d+\.\d+\.\d+|\d+\.\d+)")"\"/ ofscraper/__version__.py
- name: show file
run: cat ofscraper/__version__.py
- name: upload file
uses: actions/upload-artifact@v3
with:
name: ofscraper_version
path: /home/runner/work/OF-Scraper/OF-Scraper/ofscraper/__version__.py
# - name: list files 1
# run: ls /home/runner/work/
# - name: list files 2
# run: ls /home/runner/work/OF-Scraper/
# - name: list files 3
# run: ls /home/runner/work/OF-Scraper/OF-Scraper
# - name: list files 4
# run: ls /home/runner/work/OF-Scraper/OF-Scraper/ofscraper
linux:
needs: [create_version]
runs-on: ubuntu-20.04
name: create linux release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{inputs.version}}
- name: list files
run: ls -d $PWD/*
- name: list files2
run: ls -d $PWD/ofscraper/*
- name: update line
run:
sed -i -e s/'>=3.7.0,<4'/'>=3.7.0,<3.13'/ pyproject.toml
- name: commit
uses: pr-mpt/actions-commit-hash@v2
id: commit
- name: replace version.py
uses: actions/download-artifact@v3
with:
name: ofscraper_version
path: ofscraper
- name: create one file
uses: addnab/docker-run-action@v3
with:
image: datawhores/ubuntu:latest
options: -v ${{ github.workspace }}:/root/work
shell: bash
run: |
cd work
python3.11 -m venv .venv
/root/.local/bin/poetry add lxml
/root/.local/bin/poetry install
/root/.local/bin/poetry add pyinstaller
echo "install run pyinstaller"
/root/.local/bin/poetry run pyinstaller .venv/bin/ofscraper --collect-submodules application --name "ofscraper_linux_${{inputs.version}}" --onefile
- name: upload one file
uses: actions/upload-artifact@v3
with:
name: ofscraper_linux
path: "dist/ofscraper_linux_${{inputs.version}}"
- name: create zip
uses: addnab/docker-run-action@v3
with:
image: datawhores/ubuntu:latest
options: -v ${{ github.workspace }}:/root/work
shell: bash
run: |
cd work
apt-get install zip -y
python3.11 -m venv .venv
/root/.local/bin/poetry install
/root/.local/bin/poetry add pyinstaller
/root/.local/bin/poetry run pyinstaller .venv/bin/ofscraper --collect-submodules application --name "ofscraper_linux_${{inputs.version}}" --onefile
zip -r "dist/ofscraper_linux_${{inputs.version}}.zip" "dist/ofscraper_linux_${{inputs.version}}"
- name: upload zip
uses: actions/upload-artifact@v3
with:
name: ofscraper_linux_zip
path: "dist/ofscraper_linux_${{inputs.version}}.zip"
windows:
needs: [create_version]
runs-on: windows-latest
name: create windows release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{inputs.version}}
- name: list files
run: ls .
- name: list files2
run: ls ofscraper
- name: replace version.py
uses: actions/download-artifact@v3
with:
name: ofscraper_version
path: ofscraper
- name: update line
run:
sed -i -e s/'>=3.7.0,<4'/'>=3.7.0,<3.13'/ pyproject.toml
- name: Set up Python 3.11.5
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.1
- name: create virtualenv
run: python3 -m venv .venv
- name: active env
run: poetry env use .venv/Scripts/python3
- name: Install package
run: poetry install
- name: install builder
run: poetry add pyinstaller
- name: create-one-file
id: create-one-file
run: poetry run pyinstaller D:\a\OF-Scraper\OF-Scraper\ofscraper\__main__.py --collect-submodules ofscraper --onefile --name "ofscraper_windows_${{inputs.version}}"
continue-on-error: true
- name: create-one-file2
id: create-one-file2
if: steps.create-one-file.outcome != 'success'
run: poetry run pyinstaller .venv/Scripts/ofscraper --collect-submodules application --onefile --name "ofscraper_windows_${{inputs.version}}"
- name: upload file
uses: actions/upload-artifact@v3
with:
name: ofscraper_windows
path: 'dist\ofscraper_windows_${{inputs.version}}.exe'
- name: create-dir
id: create-dir
run: poetry run pyinstaller D:\a\OF-Scraper\OF-Scraper\ofscraper\__main__.py --collect-submodules ofscraper --name "ofscraper_windows_${{inputs.version}}"
continue-on-error: true
- name: create-dir2
id: create-dir2
if: steps.create-dir.outcome != 'success'
run: poetry run pyinstaller .venv/Scripts/ofscraper --collect-submodules application --name "ofscraper_windows_${{inputs.version}}"
- uses: vimtor/action-zip@v1
with:
files: "dist/ofscraper_windows_${{inputs.version}}"
dest: "dist/ofscraper_windows_${{inputs.version}}.zip"
- name: upload file
uses: actions/upload-artifact@v3
with:
name: ofscraper_windows_zip
path: "dist/ofscraper_windows_${{inputs.version}}.zip"
mac:
needs: [create_version]
runs-on: macos-latest
name: create mac release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{inputs.version}}
- name: list files
run: ls -d $PWD/*
- name: list files2
run: ls -d $PWD/ofscraper/*
- name: replace version.py
uses: actions/download-artifact@v3
with:
name: ofscraper_version
path: ofscraper
# - name: update line
# run:
# sed -i -e s/'>=3.7.0,<4'/'>=3.7.0,<3.13'/ pyproject.toml
- name: Set up Python 3.11.5
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: create virtualenv
run: python3 -m venv .venv
- name: install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.1
- name: Install package
run: poetry install
- name: install builder
run: poetry add pyinstaller
- name: create-one-file
id: create-one-file
run: poetry run pyinstaller /Users/runner/work/OF-Scraper/OF-Scraper/ofscraper/__main__.py --collect-submodules application --onefile --name "ofscraper_macos_${{inputs.version}}"
continue-on-error: true
- name: create-one-file2
id: create-one-file2
if: steps.create-one-file.outcome != 'success'
run: poetry run pyinstaller .venv/bin/ofscraper --collect-submodules application --onefile --name "ofscraper_macos_${{inputs.version}}"
- name: upload file
uses: actions/upload-artifact@v3
with:
name: ofscraper_macos
path: "dist/ofscraper_macos_${{inputs.version}}"
- name: create-dir
id: create-dir
run: poetry run pyinstaller /Users/runner/work/OF-Scraper/OF-Scraper/ofscraper/__main__.py --collect-submodules application --name "ofscraper_macos_${{inputs.version}}"
continue-on-error: true
- name: create-dir2
id: create-dir2
if: steps.create-dir.outcome != 'success'
run: poetry run pyinstaller .venv/bin/ofscraper --collect-submodules application --name "ofscraper_macos_${{inputs.version}}"
- uses: vimtor/action-zip@v1
with:
files: "dist/ofscraper_macos_${{inputs.version}}"
dest: "dist/ofscraper_macos_${{inputs.version}}.zip"
- name: upload file
uses: actions/upload-artifact@v3
with:
name: ofscraper_macos_zip
path: "dist/ofscraper_macos_${{inputs.version}}.zip"
publish_release:
runs-on: ubuntu-latest
name: publish
needs: [linux,windows,mac]
permissions:
contents: write
steps:
- name: Download linux
uses: actions/download-artifact@v3
with:
name: ofscraper_linux
- name: Download linux zip
uses: actions/download-artifact@v3
with:
name: ofscraper_linux_zip
- name: Download mac
uses: actions/download-artifact@v3
with:
name: ofscraper_macos
- name: Download mac zip
uses: actions/download-artifact@v3
with:
name: ofscraper_macos_zip
- name: Download windows
uses: actions/download-artifact@v3
with:
name: ofscraper_windows
- name: Download windows zip
uses: actions/download-artifact@v3
with:
name: ofscraper_windows_zip
- name: commit
uses: pr-mpt/actions-commit-hash@v2
id: commit
- name: show files
run: ls /home/runner/work/OF-Scraper/OF-Scraper
- name: upload package
uses: ncipollo/release-action@v1
with:
artifacts: "/home/runner/work/OF-Scraper/OF-Scraper/ofscraper_*"
tag: ${{inputs.version}}
allowUpdates: True
omitBodyDuringUpdate: True
omitDraftDuringUpdate: True
pypi:
if: ${{ inputs.pip}}
runs-on: ubuntu-latest
name: create pypi
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{inputs.version}}
- name: Set up Python 3.11.5
uses: actions/setup-python@v4
with:
python-version: '3.11.5'
- name: 🐍 Install dependencies
run: |
pip install poetry-dynamic-versioning
pip install dunamai
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Build
run: |
poetry version $(dunamai from git --format "{base}" --pattern="(?P<base>\d+\.\d+\.\w+|\d+\.\w+)")
poetry build
- name: Push to pypi
env:
PYPI_TOKEN: ${{ secrets.pypi }}
run: |
poetry config pypi-token.pypi $PYPI_TOKEN
poetry publish
docker:
if: ${{ inputs.docker}}
runs-on: ubuntu-latest
name: Docker Release
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: get tag
run: echo release=$(git describe --tags `git rev-list --tags --max-count=1`) >> $GITHUB_ENV
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
#Install the cosign tool except on PR
#https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@main #v2.6.0
with:
cosign-release: 'v1.13.1'
#Login against a Docker registry except on PR
#https://github.com/docker/login-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: push image to Docker Hub
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
tags: |
datawhores/of-scraper:${{ inputs.version }}
datawhores/of-scraper:latest
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
- name: cosign-installer
uses: sigstore/[email protected]
- name: Write signing key to disk
run: 'echo "$KEY" > cosign.key'
shell: bash
env:
KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
- name: Sign the published Docker image
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_EXPERIMENTAL: "true"
run: echo "datawhores/of-scraper:${{ env.release }}" | xargs -I {} cosign sign --yes --key cosign.key {}@${{ steps.build-and-push.outputs.digest }}
# # Sign the resulting Docker image digest except on PRs.
# # This will only write to the public Rekor transparency log when the Docker
# # repository is public to avoid leaking data. If you would like to publish
# # transparency data even for private images, pass --force to cosign below.
# # https://github.com/sigstore/cosign
# - name: Sign the published Docker image
# env:
# COSIGN_EXPERIMENTAL: "true"
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: echo "datawhores/of-scraper:${{ env.release }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
#Login against a Docker registry except on PR
#https://github.com/docker/login-action
- name: login to ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN}}
# Extract metadata (tags, labels) for Docker
- name: push image to ghcr
id: build-and-push2
uses: docker/build-push-action@v4
with:
context: .
tags: |
ghcr.io/datawhores/of-scraper:${{ inputs.version }}
ghcr.io/datawhores/of-scraper:latest
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
docker_old:
if: ${{ inputs.docker_old}}
runs-on: ubuntu-latest
name: Docker Release Old
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: get tag
run: echo release=$(git describe --tags `git rev-list --tags --max-count=1`) >> $GITHUB_ENV
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
#Install the cosign tool except on PR
#https://github.com/sigstore/cosign-installer
- name: Install cosign
uses: sigstore/cosign-installer@main #v2.6.0
with:
cosign-release: 'v1.13.1'
#Login against a Docker registry except on PR
#https://github.com/docker/login-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: push image to Docker Hub
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
tags: |
datawhores/of-scraper:${{ inputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true
- name: cosign-installer
uses: sigstore/[email protected]
- name: Write signing key to disk
run: 'echo "$KEY" > cosign.key'
shell: bash
env:
KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
- name: Sign the published Docker image
env:
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
COSIGN_EXPERIMENTAL: "true"
run: echo "datawhores/of-scraper:${{ env.release }}" | xargs -I {} cosign sign --yes --key cosign.key {}@${{ steps.build-and-push.outputs.digest }}
# # Sign the resulting Docker image digest except on PRs.
# # This will only write to the public Rekor transparency log when the Docker
# # repository is public to avoid leaking data. If you would like to publish
# # transparency data even for private images, pass --force to cosign below.
# # https://github.com/sigstore/cosign
# - name: Sign the published Docker image
# env:
# COSIGN_EXPERIMENTAL: "true"
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: echo "datawhores/of-scraper:${{ env.release }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
#Login against a Docker registry except on PR
#https://github.com/docker/login-action
- name: login to ghcr
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN}}
# Extract metadata (tags, labels) for Docker
- name: push image to ghcr
id: build-and-push2
uses: docker/build-push-action@v4
with:
context: .
tags: |
ghcr.io/datawhores/of-scraper:${{ inputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true