-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (144 loc) · 4.66 KB
/
release-pypi.yml
File metadata and controls
168 lines (144 loc) · 4.66 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
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
name: Release PyPI
on:
push:
tags:
- 'pypi/v*'
permissions:
contents: read
id-token: write
jobs:
verify-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Extract version from tag
id: extract
run: |
TAG="${GITHUB_REF#refs/tags/pypi/v}"
echo "version=$TAG" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Check pyproject.toml version matches tag
run: |
pip install toml
PKG_VERSION=$(python -c "import toml; print(toml.load('jacspy/pyproject.toml')['project']['version'])")
TAG_VERSION="${{ steps.extract.outputs.version }}"
echo "Package version: $PKG_VERSION"
echo "Tag version: $TAG_VERSION"
if [ "$PKG_VERSION" = "$TAG_VERSION" ]; then
echo "Version match confirmed"
else
echo "::error::Version mismatch! pyproject.toml has $PKG_VERSION but tag is $TAG_VERSION"
exit 1
fi
build-wheels:
needs: verify-version
continue-on-error: ${{ matrix.allow_failure }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
use_zig: false
allow_failure: false
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
use_zig: true
allow_failure: false
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
use_zig: false
allow_failure: false
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
use_zig: false
allow_failure: true
- os: macos-latest
target: aarch64-apple-darwin
use_zig: false
allow_failure: false
- os: macos-14
target: x86_64-apple-darwin
use_zig: false
allow_failure: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: '1.93'
target: ${{ matrix.target }}
- name: Install musl toolchain
if: contains(matrix.target, 'musl') && !matrix.use_zig
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Set musl CC for native ARM builds
if: contains(matrix.target, 'aarch64') && contains(matrix.target, 'musl') && !matrix.use_zig
run: |
echo "CC_aarch64_unknown_linux_musl=musl-gcc" >> $GITHUB_ENV
echo "AR_aarch64_unknown_linux_musl=ar" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc" >> $GITHUB_ENV
- name: Install maturin
if: ${{ !matrix.use_zig }}
run: pip install maturin
- name: Install maturin with zig support
if: ${{ matrix.use_zig }}
run: pip install "maturin[zig]"
- name: Build wheel
if: ${{ !matrix.use_zig }}
working-directory: jacspy
run: maturin build --release --target ${{ matrix.target }} --out dist
- name: Build wheel (zig)
if: ${{ matrix.use_zig }}
working-directory: jacspy
run: maturin build --release --target ${{ matrix.target }} --out dist --zig
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}
path: jacspy/dist/*.whl
build-sdist:
needs: verify-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install maturin
run: pip install maturin
- name: Build sdist
working-directory: jacspy
run: maturin sdist --out dist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: jacspy/dist/*.tar.gz
publish:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
environment: pypi
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/
password: ${{ secrets.PYPI_API_TOKEN }}