-
Notifications
You must be signed in to change notification settings - Fork 0
665 lines (567 loc) · 20.1 KB
/
publish.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
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
name: Publish Packages
on:
workflow_dispatch:
inputs:
origen_metal_python_package:
description: Publish the Origen Metal python package
default: "false"
type: choice
options:
- true
- false
origen_python_package:
description: Publish the Origen python package
default: "false"
type: choice
options:
- true
- false
# build_for_debug_target:
# description: If 'true', does not use the '--release' switch when building Rust libraries
# required: false
# default: "false"
publish_pypi:
description: Publish built packages to PyPi
required: true
default: "false"
type: choice
options:
- true
- false
publish_pypi_test:
description: Publish To PyPI Test Server
required: true
default: "false"
type: choice
options:
- true
- false
publish_github_release:
description: Publish built packages to Github Release page
required: true
default: "false"
type: choice
options:
- true
- false
prerelease:
description: Indicate that any release is a pre/dev release
required: true
default: "true"
type: choice
options:
- true
- false
# id:
# description: Set the run ID to a known value
# required: false
# type: number
env:
om_ver_file: om_version
origen_ver_file: origen_version
jobs:
precheck:
# Need to make sure that only one publish action is running at a time to avoid releases stepping on each other.
# GA's concurrency only allows for this job replacing previous jobs, but we want the opposite, otherwise we might end up
# with imcomplete or duplicate releases.
runs-on: ubuntu-latest
steps:
- name: Query Concurrency
id: query-concurrency
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: 'always'
do_not_skip: '[]'
- name: Check Concurrency
uses: actions/github-script@v7
if: ${{ steps.query-concurrency.outputs.should_skip == 'true' }}
with:
script: |
core.setFailed('Found existing publish workflow: ${{ steps.query-concurrency.outputs.skipped_by.htmlUrl }}')
build_manylinux:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS_FOR_RELEASE) }}
needs: [precheck]
runs-on: ubuntu-latest
container:
image: quay.io/pypa/manylinux2014_x86_64
options: --user root
steps:
- name: Show Env
run: |
pwd
echo "ROOT_DIR=$PWD" >> $GITHUB_ENV
env
echo "HOME=/root" >> $GITHUB_ENV
- uses: actions/checkout@v1
- name: Install Rust
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Set Rust Version
run: |
rustup install ${{ fromJSON(vars.RUST_VERSION) }}
rustup default ${{ fromJSON(vars.RUST_VERSION) }}
- name: Check Rust Version
run: |
rustc --version
cargo --version
- name: Install Newer OpenSSL
run: |
curl -O -L https://www.openssl.org/source/openssl-1.1.1w.tar.gz
ls -al openssl-1.1.1w.tar.gz
tar zxf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config
make
make install
- name: Save Minor Python Version
run: |
IFS='.' read -r -a SPLIT_VER <<< ${{ matrix.python-version }}
M_VER=${SPLIT_VER[0]}.${SPLIT_VER[1]}
echo $M_VER
echo "PY_M_VER=$M_VER" >> $GITHUB_ENV
- name: Install libffi for Python 3.12+
if: ${{ fromJSON(env.PY_M_VER) >= 3.12 }}
run: |
yum install libffi-devel -y
ldconfig
- name: Install Perl-IPC-cmd
run : |
yum install perl-IPC-Cmd -y
- name: Install Python
run: |
ls $ROOT_DIR/openssl-1.1.1w
curl -O https://www.python.org/ftp/python/${{ matrix.python-version }}/Python-${{ matrix.python-version }}.tgz
tar zxf Python-${{ matrix.python-version }}.tgz
cd Python-${{ matrix.python-version }}
./configure --with-openssl=$ROOT_DIR/openssl-1.1.1w --prefix=/root/python --enable-optimizations --enable-shared
make altinstall
- name: Copy Python Shared Library (Python 3.7)
if: ${{ matrix.python-version == '3.7.17' }}
run: |
echo $PY_M_VER
cd Python-${{ matrix.python-version }}
ls
cp libpython$PY_M_VER\m.so.1.0 /usr/local/lib64/
- name: Copy Python Shared Library (Python 3.8+ Versions)
if: ${{ matrix.python-version != '3.7.17' }}
run: |
echo $PY_M_VER
cd Python-${{ matrix.python-version }}
ls
cp libpython$PY_M_VER.so.1.0 /usr/local/lib64/
# - name: Update LD_LIBRARY_PATH
# run: |
# echo $LD_LIBRARY_PATH
# echo "LD_LIBRARY_PATH=/Python-${{ matrix.python-version }}:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Check LD_LIBRARY_PATH
run: |
echo $LD_LIBRARY_PATH
- name: Alias Python and Pip binaries
run: |
echo $PY_M_VER
ls /root/python/bin
ln -s /root/python/bin/python$PY_M_VER /root/python/bin/python
ln -s /root/python/bin/pip$PY_M_VER /root/python/bin/pip
ls /root/python/bin
- name: Update $PATH
run: |
echo /root/python/bin >> $GITHUB_PATH
# # TODO: For now use pre-installed python version.
# # In future, will probably want to download latest version
# - name: Set Python Version (3.7 Path)
# if: ${{ matrix.python-version == 3.7 }}
# run: |
# PYVER=$(echo ${{ matrix.python-version }} | sed -e "s/\.//g")
# echo $PYVER
# PATH_TO_PY=/opt/python/cp$PYVER-cp$PYVER\m/bin
# echo $PATH_TO_PY
# echo "$PATH_TO_PY" >> $GITHUB_PATH
# - name: Set Python Version
# if: ${{ matrix.python-version != 3.7 }}
# run: |
# PYVER=$(echo ${{ matrix.python-version }} | sed -e "s/\.//g")
# echo $PYVER
# PATH_TO_PY=/opt/python/cp$PYVER-cp$PYVER/bin
# echo $PATH_TO_PY
# echo "$PATH_TO_PY" >> $GITHUB_PATH
- name: Display Python Version
run: |
which python
which pip
python --version
pip --version
- name: Install Poetry
run: |
pip install poetry==1.3.2
poetry --version
- name: Install Auditwheel
run: |
pip install setuptools
pip install auditwheel
auditwheel --version
- name: Build Origen Metal Python Package
working-directory: python/origen_metal
run: poetry build --format wheel
- name: Display OM Dist Directory
working-directory: python/origen_metal
run: ls dist
- name: Repair OM Wheel
working-directory: python/origen_metal
run: |
auditwheel show dist/*
auditwheel repair dist/*
- name: Display OM Wheelhouse Directory
working-directory: python/origen_metal
run: |
ls wheelhouse
echo "OM_WHEEL=$( ls wheelhouse | head -1 )" >> $GITHUB_ENV
- name: Display OM Wheel Name
run: |
echo ${{ env.OM_WHEEL }}
- name: Upload Origen Metal Python Package Artifact
uses: actions/upload-artifact@v1
with:
name: om_wheels
# path: python/origen_metal/wheelhouse/*
path: python/origen_metal/wheelhouse/${{ env.OM_WHEEL }}
- name: Get OM Python Package Version
working-directory: python/origen_metal
run: poetry version -s > ${{ env.om_ver_file }}
- name: Upload OM Python Package Version
uses: actions/upload-artifact@v1
with:
name: ${{ env.om_ver_file }}
path: python/origen_metal/${{ env.om_ver_file }}
- name: Build Origen Python Package
working-directory: python/origen
run: poetry build --format wheel
- name: Display Origen Dist Directory
working-directory: python/origen
run: ls dist
- name: Repair Origen Wheel
working-directory: python/origen
run: |
auditwheel show dist/*
auditwheel repair dist/*
- name: Display Origen Wheelhouse Directory
working-directory: python/origen
run: |
ls wheelhouse
echo "ORIGEN_WHEEL=$( ls wheelhouse | head -1 )" >> $GITHUB_ENV
- name: Display Origen Wheelhouse Directory
run: |
ls -al python/origen/origen/__bin__/bin
ls -al rust/pyapi/target/release
echo ${{ env.ORIGEN_WHEEL }}
- name: Upload Origen Python Package Artifact
uses: actions/upload-artifact@v1
with:
name: origen_wheels
# path: python/origen/wheelhouse/*
path: python/origen/wheelhouse/${{ env.ORIGEN_WHEEL }}
- name: Get Origen Python Package Version
working-directory: python/origen
run: poetry version -s > ${{ env.origen_ver_file }}
- name: Upload Origen Python Package Version
uses: actions/upload-artifact@v1
with:
name: ${{ env.origen_ver_file }}
path: python/origen/${{ env.origen_ver_file }}
- name: Upload CLI as a standalone entity
uses: actions/upload-artifact@v1
with:
name: cli
path: python/origen/origen/__bin__/bin/origen
build_windows:
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS) }}
needs: [precheck]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ fromJSON(vars.RUST_VERSION) }}
rustflags:
- name: Override Project Rust Version
run: rustup override set ${{ fromJSON(vars.RUST_VERSION) }}
- name: Check Rust Version
run: |
rustc --version
cargo --version
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Display Python Version
run: python -c "import sys; print(sys.version)"
- name: Install Poetry
run: |
pip install poetry==1.3.2
poetry --version
- name: Build Origen Metal Python Package
working-directory: python/origen_metal
run: poetry build --format wheel
- name: Display Dist Directory
working-directory: python/origen_metal/dist
run: ls
- name: Upload Origen Metal Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: om_wheels
path: python/origen_metal/dist/origen_metal*
- name: Get OM Python Package Version
working-directory: python/origen_metal
run: poetry version -s > ${{ env.om_ver_file }}
- name: Upload OM Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.om_ver_file }}
path: python/origen_metal/${{ env.om_ver_file }}
# - name: Build Origen CLI
# working-directory: rust/origen/cli
# run: cargo build --bins --release
# - name: Add Origen to PATH (Linux)
# if: matrix.os == 'ubuntu-latest'
# run: echo "${{ github.workspace }}/rust/origen/target/release" >> $GITHUB_PATH
# - name: Add Origen to PATH (Windows)
# if: matrix.os == 'windows-latest'
# run: echo "${{ github.workspace }}/rust/origen/target/release" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# - name: Display Origen CLI Version
# run: origen -v
# - name: Build PyAPI
# working-directory: rust/pyapi
# run: cargo build --release
# - name: Setup App Env
# working-directory: python
# run: origen env setup
# - name: Display Origen App Version
# working-directory: python
# run: origen -v
- name: Build Origen Python Package
working-directory: python/origen
run: poetry build --format wheel
- name: Display Dist Directory
working-directory: python/origen/dist
run: ls
- name: Upload Origen Python Package Artifact
uses: actions/upload-artifact@v3
with:
name: origen_wheels
path: python/origen/dist/origen*
- name: Get Origen Python Package Version
working-directory: python/origen
run: poetry version -s > ${{ env.origen_ver_file }}
- name: Upload Origen Python Package Version
uses: actions/upload-artifact@v3
with:
name: ${{ env.origen_ver_file }}
path: python/origen/${{ env.origen_ver_file }}
# - name: "Publish To PyPi"
# if: ${{ github.event.inputs.publish_pypi }} == true
# working_directory: python
# run: |
# echo "Publishing to PyPi"
# # poetry publish ...
# - name: "Publish To PyPi Test Server"
# if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
# working-directory: python
# run: |
# echo "Publishing to PyPi Test Server"
# poetry config repositories.pypi-test https://test.pypi.org/legacy/
# poetry config pypi-token.pypi-test ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
# poetry publish -r pypi-test
# - name: pypi-publish
# if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
# uses: pypa/gh-action-pypi-publish@v1.4.2
# with:
# packages_dir: python/dist/
# user: __token__
# password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# skip_existing: true
# - name: "Publish To Github Releases"
# if: ${{ github.event.inputs.publish_github_release }} == true
# working_directory: python
# run: |
# echo "Publishing to Github Releases"
# # ...
show_wheels:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
steps:
- name: Retrieve OM Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Retrieve Origen Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Upload CLI as a standalone entity
uses: actions/upload-artifact@v3
with:
name: cli
path: python\origen\origen\__bin__\bin\origen.exe
publish_to_pypi_test:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_pypi_test == 'true' }}
steps:
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Push To PyPi Test Server
if: ${{ github.event.inputs.origen_metal_python_package == 'true' }}
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
packages-dir: om_wheels
password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN_OM }}
repository-url: https://test.pypi.org/legacy/
verify-metadata: false
verbose: true
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Push To PyPi Test Server
if: ${{ github.event.inputs.origen_python_package == 'true' }}
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
packages-dir: origen_wheels
password: ${{ secrets.PYPI_TEST_SERVER_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verify-metadata: false
verbose: true
publish_to_pypi:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_pypi == 'true' }}
steps:
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: om_wheels
path: om_wheels
- name: List OM Wheels
run: ls -al ./om_wheels
- name: Push To PyPi Server
if: ${{ github.event.inputs.origen_metal_python_package == 'true' }}
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
packages-dir: om_wheels
password: ${{ secrets.PYPI_OM_API_TOKEN }}
verify-metadata: false
verbose: true
- name: Retrieve Wheels
uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen_wheels
- name: List Origen Wheels
run: ls -al ./origen_wheels
- name: Push To PyPi Server
if: ${{ github.event.inputs.origen_python_package == 'true' }}
uses: pypa/gh-action-pypi-publish@v1.8.10
with:
packages-dir: origen_wheels
password: ${{ secrets.PYPI_ORIGEN_API_TOKEN }}
verify-metadata: false
verbose: true
publish_github_release:
needs: [build_manylinux, build_windows]
runs-on: ubuntu-latest
if: ${{ github.event.inputs.publish_github_release == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v3
with:
name: om_wheels
path: origen_metal
- uses: actions/download-artifact@v3
with:
name: origen_wheels
path: origen
- name: Check wheels directories
run: |
ls -al ./origen_metal
ls -al ./origen
- uses: actions/download-artifact@v3
with:
name: cli
path: cli
- name: Show downloaded artifact directories
run: |
ls -al ./origen_metal
ls -al ./origen
ls -al ./cli
- uses: actions/download-artifact@v3
with:
name: ${{ env.om_ver_file }}
- uses: actions/download-artifact@v3
with:
name: ${{ env.origen_ver_file }}
- uses: vimtor/action-zip@v1.1
with:
files: origen_metal
dest: origen_metal.zip
- uses: vimtor/action-zip@v1.1
with:
files: origen
dest: origen.zip
- uses: vimtor/action-zip@v1.1
with:
files: cli
dest: cli.zip
- name: Get OM/Origen Versions
run: |
ls -al
cat ./${{ env.om_ver_file }}
cat ./${{ env.origen_ver_file }}
echo "om_version=$(cat ./${{ env.om_ver_file }})" >> $GITHUB_ENV
echo "origen_version=$(cat ./${{ env.origen_ver_file }})" >> $GITHUB_ENV
- name: Show Versions
run: |
echo ${{ env.om_version }}
echo ${{ env.origen_version }}
- name: Figure Out Tag
run: |
echo "tag=commit-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Display Tag
run: echo ${{ env.tag }}
- name: Generate Github Release
uses: ncipollo/release-action@v1
with:
artifacts: ./origen_metal.zip, ./origen.zip, cli.zip
artifactErrorsFailBuild: true
prerelease: ${{ github.event.inputs.prerelease == 'true' }}
commit: ${{ github.sha }}
tag: ${{ env.tag }}
cleanup:
needs: [precheck, build_manylinux, build_windows, publish_to_pypi_test, publish_to_pypi, publish_github_release, show_wheels]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- run: |
echo "Begin Clean Up..."
echo "No Clean Up Tasks!"