-
Notifications
You must be signed in to change notification settings - Fork 36
136 lines (129 loc) · 4.22 KB
/
pypi.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
name: Build wheels and publish to PyPI
on:
push:
branches:
- master
tags:
- "v*"
workflow_dispatch:
jobs:
configure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read Python versions from pyproject.toml
id: read-versions
# produces output like: python_versions=39,310,311,312,313
run: >-
echo "python_versions=$(
grep -oP '(?<=Language :: Python :: )\d.\d+' pyproject.toml
| sed 's/\.//'
| tr '\n' ','
| sed 's/,$//'
)" >> $GITHUB_OUTPUT
outputs:
python_versions: ${{ steps.read-versions.outputs.python_versions }}
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: python version.py check "${{ github.ref }}"
- name: Add untagged version suffix
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
run: python version.py update
- name: Build sdist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist
choose_linux_wheel_types:
name: Decide which wheel types to build
runs-on: ubuntu-latest
steps:
- id: manylinux_x86_64
run: echo "wheel_types=manylinux_x86_64" >> $GITHUB_OUTPUT
- id: musllinux_x86_64
run: echo "wheel_types=musllinux_x86_64" >> $GITHUB_OUTPUT
outputs:
wheel_types: ${{ toJSON(steps.*.outputs.wheel_types) }}
build_linux_wheels:
needs: [configure, choose_linux_wheel_types, build_sdist]
name: ${{ matrix.wheel_type }} wheels
runs-on: ubuntu-latest
strategy:
matrix:
wheel_type: ${{ fromJSON(needs.choose_linux_wheel_types.outputs.wheel_types) }}
steps:
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Extract sdist
run: |
tar zxvf dist/*.tar.gz --strip-components=1
- uses: docker/setup-qemu-action@v3
if: runner.os == 'Linux'
name: Set up QEMU
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: cp{${{ needs.configure.outputs.python_versions }}}-${{ matrix.wheel_type }}
CIBW_ARCHS_LINUX: auto
CIBW_BEFORE_BUILD: cd {project}; pip install -e . # is there a better way to build the .so files?
CIBW_TEST_COMMAND: cd {project}; python -m unittest
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.wheel_type }}-wheels
path: ./wheelhouse/*.whl
pypi-publish:
name: Upload release to PyPI
needs: [build_sdist, build_linux_wheels]
runs-on: ubuntu-latest
#if: startsWith(github.ref, 'refs/tags/v') # removed until pypi-test-publish is working
environment:
name: pypi
url: https://pypi.org/p/jsonobject
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
# with no name set, it downloads all of the artifacts
path: dist/
- run: |
mv dist/sdist/*.tar.gz dist/
mv dist/*-wheels/*.whl dist/
rmdir dist/{sdist,*-wheels}
ls -R dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# https://github.com/finpassbr/json-object/issues/1
#pypi-test-publish:
# name: Upload release to test PyPI
# needs: [build_sdist, build_linux_wheels]
# runs-on: ubuntu-latest
# environment:
# name: testpypi
# url: https://test.pypi.org/p/jsonobject
# permissions:
# id-token: write
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# # with no name set, it downloads all of the artifacts
# path: dist/
# - run: |
# mv dist/sdist/*.tar.gz dist/
# mv dist/*-wheels/*.whl dist/
# rmdir dist/{sdist,*-wheels}
# ls -R dist
# - name: Publish package distributions to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/