Skip to content

Commit fdc3e84

Browse files
committed
Add Actions publishing
1 parent 18d1e30 commit fdc3e84

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

.github/workflows/publish.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build:
10+
name: Build packages
11+
runs-on: ubuntu-24.04
12+
environment: publish
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.13"
23+
- name: Build packages
24+
run: |
25+
pip install -r requirements/testing.txt
26+
make package
27+
- name: Upload packages
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: python-package-distributions
31+
path: dist/
32+
if-no-files-found: error
33+
34+
publish-to-pypi:
35+
name: Publish package on PyPI
36+
needs:
37+
- build
38+
runs-on: ubuntu-24.04
39+
environment:
40+
name: pypi
41+
url: https://pypi.org/project/${{ github.event.repository.name }}/${{ github.ref_name }}/
42+
permissions:
43+
id-token: write
44+
45+
steps:
46+
- name: Download packages
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish to PyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
54+
github-release:
55+
name: Publish package on GitHub Releases
56+
needs:
57+
- build
58+
runs-on: ubuntu-24.04
59+
environment:
60+
name: github-releases
61+
url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}
62+
permissions:
63+
contents: write
64+
id-token: write
65+
66+
steps:
67+
- name: Download packages
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Sign packages
73+
uses: sigstore/[email protected]
74+
with:
75+
inputs: >-
76+
./dist/*.tar.gz
77+
./dist/*.whl
78+
- name: Create GitHub Release
79+
env:
80+
GH_TOKEN: ${{ github.token }}
81+
run: >-
82+
gh release create
83+
"$GITHUB_REF_NAME"
84+
--repo "$GITHUB_REPOSITORY"
85+
--title "${GITHUB_REPOSITORY#*/} $GITHUB_REF_NAME"
86+
- name: Upload artifact signatures to GitHub Release
87+
env:
88+
GH_TOKEN: ${{ github.token }}
89+
run: >-
90+
gh release upload
91+
"$GITHUB_REF_NAME" dist/**
92+
--repo "$GITHUB_REPOSITORY"

0 commit comments

Comments
 (0)