Skip to content

Commit 9b4088a

Browse files
committed
add release workflow
1 parent bf2ec3e commit 9b4088a

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/release.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
3+
on: push
4+
5+
jobs:
6+
build:
7+
name: Build distribution 📦
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.10"
16+
- name: Install pypa/build
17+
run: pip install build
18+
- name: Build a binary wheel and a source tarball
19+
run: python -m build
20+
- name: Store the distribution packages
21+
uses: actions/upload-artifact@v4
22+
with:
23+
name: python-package-distributions
24+
path: dist/
25+
26+
publish-to-pypi:
27+
name: >-
28+
Publish Python 🐍 distribution 📦 to PyPI
29+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
30+
needs:
31+
- build
32+
runs-on: ubuntu-latest
33+
environment:
34+
name: pypi
35+
url: https://pypi.org/p/autointent
36+
permissions:
37+
id-token: write # IMPORTANT: mandatory for trusted publishing
38+
39+
steps:
40+
- name: Download all the dists
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: python-package-distributions
44+
path: dist/
45+
- name: Publish distribution 📦 to PyPI
46+
uses: pypa/gh-action-pypi-publish@release/v1
47+
48+
github-release:
49+
name: >-
50+
Sign the Python 🐍 distribution 📦 with Sigstore
51+
and upload them to GitHub Release
52+
needs:
53+
- publish-to-pypi
54+
runs-on: ubuntu-latest
55+
56+
permissions:
57+
contents: write # IMPORTANT: mandatory for making GitHub Releases
58+
id-token: write # IMPORTANT: mandatory for sigstore
59+
60+
steps:
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
- name: Sign the dists with Sigstore
67+
uses: sigstore/[email protected]
68+
with:
69+
inputs: >-
70+
./dist/*.tar.gz
71+
./dist/*.whl
72+
- name: Create GitHub Release
73+
env:
74+
GITHUB_TOKEN: ${{ github.token }}
75+
run: >-
76+
gh release create
77+
'${{ github.ref_name }}'
78+
--repo '${{ github.repository }}'
79+
--notes ""
80+
- name: Upload artifact signatures to GitHub Release
81+
env:
82+
GITHUB_TOKEN: ${{ github.token }}
83+
# Upload to GitHub Release using the `gh` CLI.
84+
# `dist/` contains the built packages, and the
85+
# sigstore-produced signatures and certificates.
86+
run: >-
87+
gh release upload
88+
'${{ github.ref_name }}' dist/**
89+
--repo '${{ github.repository }}'
90+
91+
publish-to-testpypi:
92+
name: Publish Python 🐍 distribution 📦 to TestPyPI
93+
needs:
94+
- build
95+
runs-on: ubuntu-latest
96+
97+
environment:
98+
name: testpypi
99+
url: https://test.pypi.org/p/autointent
100+
101+
permissions:
102+
id-token: write # IMPORTANT: mandatory for trusted publishing
103+
104+
steps:
105+
- name: Download all the dists
106+
uses: actions/download-artifact@v4
107+
with:
108+
name: python-package-distributions
109+
path: dist/
110+
- name: Publish distribution 📦 to TestPyPI
111+
uses: pypa/gh-action-pypi-publish@release/v1
112+
with:
113+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)