generated from sehoffmann/python-template
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (84 loc) · 2.22 KB
/
build_and_upload_wheel.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
name: Build and Upload Wheel
on:
workflow_call:
inputs:
branch:
required: true
type: string
do-upload:
required: false
default: true
type: boolean
real-pypi:
required: false
default: false
type: boolean
secrets:
PYPI_TOKEN:
required: true
jobs:
wheel_build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
submodules: recursive
- name: Setup Environment
uses: ./.github/actions/setup_environment
- name: Build Wheel
run: |
python -m build
- name: Upload Wheels to Github
uses: actions/upload-artifact@v4
with:
name: wheels
path: dist/*.whl
wheel_upload:
if: inputs.do-upload == true
needs: [wheel_build]
runs-on: ubuntu-latest
outputs:
upload: ${{ steps.trigger_upload.outputs.value }}
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Download Artifacts From Github
continue-on-error: true
uses: actions/download-artifact@v4
with:
name: wheels
- name: Determine If Wheel Uploading Is Needed
run: |
upload=false
for txt in *.whl; do
upload=true
break
done
echo "value=$upload" >> $GITHUB_OUTPUT
id: trigger_upload
- name: Display All Wheels
if: steps.trigger_upload.outputs.value == 'true'
run: ls -lh *.whl
- name: Upload Wheels to PyPI
if: |
steps.trigger_upload.outputs.value == 'true'
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
pip install twine
if [[ "${{ inputs.real-pypi }}" == true ]]; then
python -m twine upload \
--username __token__ \
--password "$PYPI_TOKEN" \
*.whl
else
python -m twine upload \
-r testpypi \
--username __token__ \
--password "$PYPI_TOKEN" \
*.whl
fi