Skip to content

Commit d4e2719

Browse files
committed
chore: setup release automation
1 parent 8c1a9e0 commit d4e2719

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

.github/workflows/release.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
2+
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@v4
14+
with:
15+
python-version: "3.x"
16+
- name: Install pypa/build
17+
run: >-
18+
python3 -m pip install build --user
19+
- name: Build a binary wheel and a source tarball
20+
run: python3 -m build
21+
- name: Store the distribution packages
22+
uses: actions/upload-artifact@v3
23+
with:
24+
name: python-package-distributions
25+
path: dist/
26+
27+
publish-to-pypi:
28+
name: >-
29+
Publish Python 🐍 distribution 📦 to PyPI
30+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
31+
needs:
32+
- build
33+
runs-on: ubuntu-latest
34+
environment: # TODO: replace with pypi.org once verified.
35+
name: testpypi
36+
url: https://test.pypi.org/p/gyp-next
37+
permissions:
38+
id-token: write # IMPORTANT: mandatory for trusted publishing
39+
40+
steps:
41+
- name: Download all the dists
42+
uses: actions/download-artifact@v3
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
- name: Publish distribution 📦 to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1
48+
49+
github-release:
50+
name: >-
51+
Sign the Python 🐍 distribution 📦 with Sigstore
52+
and upload them to GitHub Release
53+
needs:
54+
- publish-to-pypi
55+
runs-on: ubuntu-latest
56+
57+
permissions:
58+
contents: write # IMPORTANT: mandatory for making GitHub Releases
59+
id-token: write # IMPORTANT: mandatory for sigstore
60+
61+
steps:
62+
- name: Download all the dists
63+
uses: actions/download-artifact@v3
64+
with:
65+
name: python-package-distributions
66+
path: dist/
67+
- name: Sign the dists with Sigstore
68+
uses: sigstore/gh-action-sigstore-python@v1.2.3
69+
with:
70+
inputs: >-
71+
./dist/*.tar.gz
72+
./dist/*.whl
73+
- name: Create GitHub Release
74+
env:
75+
GITHUB_TOKEN: ${{ github.token }}
76+
run: >-
77+
gh release create
78+
'${{ github.ref_name }}'
79+
--repo '${{ github.repository }}'
80+
--notes ""
81+
- name: Upload artifact signatures to GitHub Release
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
# Upload to GitHub Release using the `gh` CLI.
85+
# `dist/` contains the built packages, and the
86+
# sigstore-produced signatures and certificates.
87+
run: >-
88+
gh release upload
89+
'${{ github.ref_name }}' dist/**
90+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)