-
Notifications
You must be signed in to change notification settings - Fork 5
131 lines (126 loc) · 4.33 KB
/
main.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
name: Python Package Publication
on:
pull_request:
branches: [master]
paths:
- '**.cpp'
- '**.hpp'
- '**.py'
- 'setup.py'
- 'setup.cfg'
- 'pyproject.toml'
- '**.yml'
pull_request_target:
types: [closed]
branches: [master]
paths:
- '**.cpp'
- '**.hpp'
- '**.py'
- 'setup.py'
- 'setup.cfg'
- 'pyproject.toml'
workflow_dispatch:
inputs:
dry-run:
description: 'Dry run (no actual upload to PyPI)'
type: boolean
default: true
jobs:
linux-build:
runs-on: ubuntu-latest
env:
TWINE_USERNAME: __token__
IS_DRY_RUN: ${{ !(github.event_name == 'pull_request_target' && github.event.pull_request.merged == true) }}
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Get version
id: get_version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Python wheels manylinux stable build
uses: RalfG/python-wheels-manylinux-build@v0.5.0
with:
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
- name: Upload wheel testpypi
if: env.IS_DRY_RUN == 'true'
env:
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
python -m pip install wheel setuptools twine packaging
python -m pip install --upgrade twine packaging
python -m twine upload --repository testpypi dist/*-manylinux*.whl --verbose
continue-on-error: ${{ env.IS_DRY_RUN == 'true' }}
- name: Upload wheel to production
if: env.IS_DRY_RUN == 'false'
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pip install wheel setuptools twine packaging
python -m pip install --upgrade twine packaging
python -m twine upload dist/*-manylinux*.whl
continue-on-error: ${{ env.IS_DRY_RUN == 'true' }}
other-os-build:
runs-on: ${{ matrix.os }}
env:
TWINE_USERNAME: __token__
IS_DRY_RUN: ${{ !(github.event_name == 'pull_request_target' && github.event.pull_request.merged == true) }}
strategy:
matrix:
os: [macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Get version
id: get_version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: build wheel
run: |
python -m pip install wheel setuptools twine packaging
python -m pip install --upgrade twine packaging
python setup.py bdist_wheel
- name: Upload wheel testpypi
if: env.IS_DRY_RUN == 'true'
env:
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: |
python -m pip install wheel setuptools twine packaging
python -m pip install --upgrade twine packaging
python -m twine upload --repository testpypi dist/* --verbose
continue-on-error: ${{ env.IS_DRY_RUN == 'true' }}
- name: Upload wheel to production
if: env.IS_DRY_RUN == 'false'
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
python -m pip install wheel setuptools twine packaging
python -m pip install --upgrade twine packaging
python -m twine upload dist/*
continue-on-error: ${{ env.IS_DRY_RUN == 'true' }}
release-build:
needs: [ linux-build, other-os-build ]
if: (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get version
id: get_version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.get_version.outputs.version }}" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${{ steps.get_version.outputs.version }}" \
--generate-notes