Skip to content

Commit 2a17680

Browse files
committed
refactor(ci): GitHub and PyPI release on tag
transition to PyPI Trusted Publisher https://docs.pypi.org/trusted-publishers/
1 parent 908f074 commit 2a17680

File tree

3 files changed

+62
-44
lines changed

3 files changed

+62
-44
lines changed

.github/workflows/.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/publish.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release to GitHub and PyPI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v[2-9].[0-9]+.[0-9]+"
8+
- "v[2-9].[0-9]+.[0-9]+-pre[0-9]?"
9+
10+
jobs:
11+
test:
12+
uses: ./.github/workflows/test.yml
13+
14+
release:
15+
runs-on: ubuntu-latest
16+
environment: release
17+
needs: test
18+
permissions:
19+
# https://github.com/softprops/action-gh-release#permissions
20+
contents: write
21+
# IMPORTANT: this permission is mandatory for trusted publishing
22+
id-token: write
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: actions/setup-python@v4
28+
with:
29+
python-version: "3.11"
30+
cache: pip
31+
cache-dependency-path: "**/pyproject.toml"
32+
33+
- name: Install build dependencies
34+
run: pip install build
35+
36+
- name: Build package
37+
run: python -m build
38+
39+
- name: Release
40+
id: release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
files: |
44+
./dist/*.whl
45+
./dist/*.tar.gz
46+
prerelease: ${{ contains(github.ref, '-pre') }}
47+
generate_release_notes: ${{ !contains(github.ref, '-pre') }}
48+
49+
- name: Publish to Test PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1.5
51+
if: ${{ contains(github.ref, '-pre') }}
52+
with:
53+
repository_url: https://test.pypi.org/legacy/
54+
print_hash: true
55+
skip_existing: true
56+
verbose: true
57+
58+
- name: Publish to PyPI
59+
uses: pypa/gh-action-pypi-publish@release/v1.5
60+
if: ${{ !contains(github.ref, '-pre') }}
61+
with:
62+
print_hash: true

0 commit comments

Comments
 (0)