Skip to content

Commit 7243112

Browse files
kurodo3[bot]eywalker
authored andcommitted
ci: add tag-triggered TestPyPI → PyPI publish workflow (PLT-1251)
1 parent 313f39a commit 7243112

1 file changed

Lines changed: 103 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
jobs:
9+
test:
10+
name: Test (Python ${{ matrix.python-version }})
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
python-version: ["3.10", "3.11", "3.12"]
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # required: hatch-vcs needs full tag history
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: uv sync --dev --python ${{ matrix.python-version }}
29+
30+
- name: Run tests
31+
run: uv run --python ${{ matrix.python-version }} pytest tests/ -v
32+
33+
build:
34+
name: Build distribution
35+
needs: test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # required: hatch-vcs needs full tag history
41+
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v5
44+
45+
- name: Build wheel and sdist
46+
run: uv build
47+
48+
- name: Upload dist artifact
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: dist
52+
path: dist/
53+
if-no-files-found: error
54+
55+
publish-testpypi:
56+
name: Publish → TestPyPI
57+
needs: build
58+
runs-on: ubuntu-latest
59+
environment:
60+
name: testpypi
61+
url: https://test.pypi.org/p/starfix
62+
permissions:
63+
id-token: write # required for OIDC Trusted Publishing
64+
steps:
65+
- name: Download dist artifact
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: dist
69+
path: dist/
70+
71+
- name: Publish to TestPyPI
72+
uses: pypa/gh-action-pypi-publish@release/v1
73+
with:
74+
repository-url: https://upload.test.pypi.org/legacy/
75+
attestations: true
76+
77+
publish-pypi:
78+
name: Publish → PyPI
79+
needs: publish-testpypi
80+
runs-on: ubuntu-latest
81+
environment:
82+
name: pypi
83+
url: https://pypi.org/p/starfix
84+
permissions:
85+
id-token: write # required for OIDC Trusted Publishing
86+
contents: write # required for creating GitHub Release
87+
steps:
88+
- name: Download dist artifact
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: dist
92+
path: dist/
93+
94+
- name: Publish to PyPI
95+
uses: pypa/gh-action-pypi-publish@release/v1
96+
with:
97+
attestations: true
98+
99+
- name: Create GitHub Release
100+
uses: softprops/action-gh-release@v2
101+
with:
102+
generate_release_notes: true
103+
files: dist/*

0 commit comments

Comments
 (0)