Skip to content

Commit 815e837

Browse files
authored
Merge pull request #14 from 0x26res/add-job-to-publish
Add job to publish wheels
2 parents 3e7eeb7 + e330fd6 commit 815e837

File tree

2 files changed

+109
-1
lines changed

2 files changed

+109
-1
lines changed

.github/workflows/release.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "[ptars] Release"
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
branches: [ master ]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
env:
14+
PACKAGE_NAME: ptars
15+
PYTHON_VERSION: "3.11"
16+
CARGO_INCREMENTAL: 0
17+
CARGO_NET_RETRY: 10
18+
CARGO_TERM_COLOR: always
19+
RUSTUP_MAX_RETRIES: 10
20+
21+
jobs:
22+
sdist:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.sha }}
28+
- uses: actions/setup-python@v5
29+
with:
30+
python-version: ${{ env.PYTHON_VERSION }}
31+
- name: "Build sdist"
32+
uses: PyO3/maturin-action@v1
33+
with:
34+
command: sdist
35+
args: --out dist
36+
- name: "Test sdist"
37+
run: |
38+
pip install dist/${{ env.PACKAGE_NAME }}-*.tar.gz --force-reinstall
39+
python -c "import ptars"
40+
- name: "Upload sdist"
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: wheels-sdist
44+
path: dist
45+
46+
47+
macos-universal:
48+
runs-on: macos-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
with:
52+
ref: ${{ inputs.sha }}
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: ${{ env.PYTHON_VERSION }}
56+
architecture: x64
57+
- name: "Build wheels - universal2"
58+
uses: PyO3/maturin-action@v1
59+
with:
60+
args: --release --locked --target universal2-apple-darwin --out dist
61+
- name: "Test wheel - universal2"
62+
run: |
63+
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
64+
python -c "import ptars"
65+
- name: "Upload wheels"
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: wheels-aarch64-apple-darwin
69+
path: dist
70+
- name: "Archive binary"
71+
run: |
72+
ARCHIVE_FILE=ptars-${{ inputs.tag }}-aarch64-apple-darwin.tar.gz
73+
tar czvf $ARCHIVE_FILE -C target/aarch64-apple-darwin/release ptars
74+
shasum -a 256 $ARCHIVE_FILE > $ARCHIVE_FILE.sha256
75+
- name: "Upload binary"
76+
uses: actions/upload-artifact@v4
77+
with:
78+
name: binaries-aarch64-apple-darwin
79+
path: |
80+
*.tar.gz
81+
*.sha256
82+
83+
upload-release:
84+
name: Upload to PyPI
85+
runs-on: ubuntu-latest
86+
needs:
87+
- macos-universal
88+
# If you don't set an input tag, it's a dry run (no uploads).
89+
if: ${{ inputs.tag }}
90+
environment:
91+
name: release
92+
permissions:
93+
# For pypi trusted publishing
94+
id-token: write
95+
steps:
96+
- uses: actions/download-artifact@v4
97+
with:
98+
pattern: wheels-*
99+
path: wheels
100+
merge-multiple: true
101+
- name: Publish to PyPi
102+
uses: pypa/gh-action-pypi-publish@release/v1
103+
with:
104+
skip-existing: true
105+
packages-dir: wheels
106+
verbose: true
107+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
108+
repository-url: https://test.pypi.org/legacy/

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-rust"]
2+
requires = ["setuptools", "setuptools-rust", "maturin"]
33
build-backend = "maturin"
44

55
[project]

0 commit comments

Comments
 (0)