-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (71 loc) · 2.27 KB
/
release.yml
File metadata and controls
83 lines (71 loc) · 2.27 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
name: Release
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
validate-version:
name: Validate tag matches package version
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Check versions match tag
run: |
TAG="${GITHUB_REF#refs/tags/v}"
PY_VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*= *"//' | sed 's/"//')
RS_VERSION=$(grep '^version' crates/panchang-core/Cargo.toml | head -1 | sed 's/.*= *"//' | sed 's/"//')
echo "Git tag: $TAG"
echo "pyproject.toml: $PY_VERSION"
echo "Cargo.toml: $RS_VERSION"
if [ "$TAG" != "$PY_VERSION" ]; then
echo "::error::Tag v$TAG does not match pyproject.toml version $PY_VERSION"
exit 1
fi
if [ "$TAG" != "$RS_VERSION" ]; then
echo "::error::Tag v$TAG does not match Cargo.toml version $RS_VERSION"
exit 1
fi
echo "All versions match: $TAG"
build-wheels:
name: Build wheels (${{ matrix.os }})
needs: [validate-version]
if: always() && (needs.validate-version.result == 'success' || needs.validate-version.result == 'skipped')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
command: build
args: --release --out dist --interpreter 3.11 3.12 3.13
manylinux: auto
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: dist/
publish:
name: Publish to PyPI
needs: [validate-version, build-wheels]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
environment:
name: pypi
url: https://pypi.org/p/panchang
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1