Skip to content

Commit f1dd998

Browse files
authored
Update CONTRIBUTING.md and pyproject.toml for improved clarity and project metadata (#1)
- Revised the CONTRIBUTING.md to reflect the correct repository name and enhance the recommended workflow for contributors. - Added keywords and project URLs in pyproject.toml to improve discoverability and provide essential links for users. - Introduced new GitHub Actions workflows for publishing to PyPI and managing releases, ensuring a streamlined deployment process.
1 parent 1cfce2c commit f1dd998

File tree

4 files changed

+252
-108
lines changed

4 files changed

+252
-108
lines changed

.github/workflows/publish.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "Tag version (e.g., v0.1.0)"
11+
required: false
12+
type: string
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
verify-version:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
24+
- name: Install Python
25+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Verify tag matches package version
30+
run: |
31+
if [ -n "${{ inputs.tag }}" ]; then
32+
TAG_VERSION="${{ inputs.tag }}"
33+
TAG_VERSION="${TAG_VERSION#v}"
34+
else
35+
TAG_VERSION="${GITHUB_REF_NAME#v}"
36+
fi
37+
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
38+
echo "Tag version: ${TAG_VERSION}"
39+
echo "Package version: ${PACKAGE_VERSION}"
40+
if [ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ]; then
41+
echo "::error::Tag version (${TAG_VERSION}) must match package version (${PACKAGE_VERSION})"
42+
exit 1
43+
fi
44+
45+
build-wheels:
46+
needs: verify-version
47+
name: Build wheels on ${{ matrix.os }} (${{ matrix.target }})
48+
runs-on: ${{ matrix.os }}
49+
strategy:
50+
matrix:
51+
include:
52+
# Linux
53+
- os: ubuntu-latest
54+
target: x86_64
55+
- os: ubuntu-latest
56+
target: aarch64
57+
# macOS
58+
- os: macos-13 # Intel
59+
target: x86_64
60+
- os: macos-14 # Apple Silicon
61+
target: aarch64
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
65+
66+
- name: Install Rust toolchain
67+
uses: dtolnay/rust-toolchain@stable
68+
69+
- name: Build wheels
70+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
71+
with:
72+
target: ${{ matrix.target }}
73+
args: --release --out dist
74+
sccache: "true"
75+
manylinux: auto
76+
77+
- name: Upload wheels
78+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
79+
with:
80+
name: wheels-${{ matrix.os }}-${{ matrix.target }}
81+
path: dist
82+
83+
build-sdist:
84+
needs: verify-version
85+
runs-on: ubuntu-latest
86+
steps:
87+
- name: Checkout
88+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
89+
90+
- name: Install Rust toolchain
91+
uses: dtolnay/rust-toolchain@stable
92+
93+
- name: Build sdist
94+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
95+
with:
96+
command: sdist
97+
args: --out dist
98+
99+
- name: Upload sdist
100+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
101+
with:
102+
name: sdist
103+
path: dist
104+
105+
publish:
106+
needs: [build-wheels, build-sdist]
107+
runs-on: ubuntu-latest
108+
permissions:
109+
id-token: write # Required for trusted publishing
110+
steps:
111+
- name: Download artifacts
112+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
113+
with:
114+
path: dist
115+
merge-multiple: true
116+
117+
- name: Publish to PyPI
118+
uses: pypa/gh-action-pypi-publish@release/v1
119+
with:
120+
packages-dir: dist/

.github/workflows/release.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
verify-version:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
18+
- name: Install Python
19+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
20+
with:
21+
python-version: "3.12"
22+
23+
- name: Verify tag matches package version
24+
run: |
25+
TAG_VERSION="${GITHUB_REF_NAME#v}"
26+
PACKAGE_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
27+
echo "Tag version: ${TAG_VERSION}"
28+
echo "Package version: ${PACKAGE_VERSION}"
29+
if [ "${TAG_VERSION}" != "${PACKAGE_VERSION}" ]; then
30+
echo "::error::Tag version (${TAG_VERSION}) must match package version (${PACKAGE_VERSION})"
31+
exit 1
32+
fi
33+
34+
build-wheels:
35+
needs: verify-version
36+
name: Build wheels on ${{ matrix.os }} (${{ matrix.target }})
37+
runs-on: ${{ matrix.os }}
38+
strategy:
39+
matrix:
40+
include:
41+
# Linux
42+
- os: ubuntu-latest
43+
target: x86_64
44+
- os: ubuntu-latest
45+
target: aarch64
46+
# macOS
47+
- os: macos-13 # Intel
48+
target: x86_64
49+
- os: macos-14 # Apple Silicon
50+
target: aarch64
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
55+
- name: Install Rust toolchain
56+
uses: dtolnay/rust-toolchain@stable
57+
58+
- name: Build wheels
59+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
60+
with:
61+
target: ${{ matrix.target }}
62+
args: --release --out dist
63+
sccache: "true"
64+
manylinux: auto
65+
66+
- name: Upload wheels
67+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
68+
with:
69+
name: wheels-${{ matrix.os }}-${{ matrix.target }}
70+
path: dist
71+
72+
build-sdist:
73+
needs: verify-version
74+
runs-on: ubuntu-latest
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
78+
79+
- name: Install Rust toolchain
80+
uses: dtolnay/rust-toolchain@stable
81+
82+
- name: Build sdist
83+
uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1
84+
with:
85+
command: sdist
86+
args: --out dist
87+
88+
- name: Upload sdist
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
90+
with:
91+
name: sdist
92+
path: dist
93+
94+
release:
95+
needs: [build-wheels, build-sdist]
96+
runs-on: ubuntu-latest
97+
permissions:
98+
contents: write
99+
steps:
100+
- name: Download artifacts
101+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
102+
with:
103+
path: artifacts
104+
merge-multiple: true
105+
106+
- name: Publish GitHub Release
107+
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # v2.1.0
108+
with:
109+
files: artifacts/*
110+
generate_release_notes: true
111+
draft: true
112+
env:
113+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)