-
Notifications
You must be signed in to change notification settings - Fork 38
123 lines (116 loc) · 3.63 KB
/
Copy pathrelease.yml
File metadata and controls
123 lines (116 loc) · 3.63 KB
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
name: Publish release to PyPi
on:
release:
types: [published]
env:
PYTHON_VERSION: "3.12"
jobs:
validate:
name: Validate release tag
runs-on: ubuntu-latest
outputs:
version: ${{ steps.vars.outputs.tag }}
steps:
- name: Get tag
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Validate version number
run: >-
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
if ! [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then
echo "Pre-release: Tag is missing beta suffix (${{ steps.vars.outputs.tag }})"
exit 1
fi
else
if [[ "${{ steps.vars.outputs.tag }}" =~ "b" ]]; then
echo "Release: Tag must not have a beta suffix (${{ steps.vars.outputs.tag }})"
exit 1
fi
fi
build-sdist:
name: Build source distribution
needs: ['validate']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build dependencies
run: pip install build
- name: Set Python project version from tag
run: sed -i 's/^version = "0.0.0"/version = "${{ needs.validate.outputs.version }}"/' pyproject.toml
- name: Build sdist
run: python3 -m build --sdist
- uses: actions/upload-artifact@v7.0.0
with:
name: dist-sdist
path: ./dist/*.tar.gz
build-wheels:
name: Build wheels (${{ matrix.os }}, ${{ matrix.archs }})
needs: ['validate']
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
archs: x86_64
qemu: false
- os: ubuntu-latest
archs: aarch64
qemu: true
- os: macos-latest
archs: x86_64 arm64
qemu: false
- os: windows-latest
archs: AMD64
qemu: false
steps:
- uses: actions/checkout@v6.0.2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set Python project version from tag
shell: python
run: |
import pathlib
p = pathlib.Path("pyproject.toml")
p.write_text(p.read_text().replace('version = "0.0.0"', 'version = "${{ needs.validate.outputs.version }}"', 1))
- name: Set up QEMU
if: matrix.qemu
uses: docker/setup-qemu-action@v4.0.0
with:
platforms: arm64,arm
- name: Build wheels
uses: pypa/cibuildwheel@v3.4.0
with:
extras: uv
env:
CIBW_ENVIRONMENT: "SENDSPIN_REQUIRE_C_EXT=1"
CIBW_BUILD: cp312-* cp313-*
CIBW_BUILD_FRONTEND: "uv"
CIBW_ARCHS: ${{ matrix.archs }}
CIBW_SKIP: "*-musllinux_*"
- uses: actions/upload-artifact@v7.0.0
with:
name: dist-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
publish:
needs: ['build-sdist', 'build-wheels']
environment: 'publish'
name: Upload release to PyPI
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v8.0.0
with:
pattern: dist-*
path: dist
merge-multiple: true
- name: Publish release to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/