Skip to content

Commit 9b19cc5

Browse files
authored
Add Django Commons release workflow (#209)
1 parent 4904c1a commit 9b19cc5

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Publish Python 🐍 distribution 📦 to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
# Order matters, the last rule that applies to a tag
7+
# is the one that takes effect:
8+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches-and-tags
9+
- '*'
10+
# There should be no dev tags created, but to be safe,
11+
# let's not publish them.
12+
- '!*.dev*'
13+
14+
env:
15+
PYPI_URL: https://pypi.org/p/axe-selenium-python/
16+
17+
jobs:
18+
19+
build:
20+
name: Build distribution 📦
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v5
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v5
27+
with:
28+
node-version: 24.x
29+
cache: "npm"
30+
- name: Install node_modules
31+
run: npm ci
32+
- name: Set up Python
33+
uses: actions/setup-python@v6
34+
with:
35+
python-version: "3.x"
36+
- name: Install pypa/build
37+
run:
38+
python3 -m pip install build --user
39+
- name: Build a binary wheel and a source tarball
40+
run: python3 -m build
41+
- name: Store the distribution packages
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
47+
publish-to-pypi:
48+
name: >-
49+
Publish Python 🐍 distribution 📦 to PyPI
50+
needs:
51+
- build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: pypi
55+
url: ${{ env.PYPI_URL }}
56+
permissions:
57+
id-token: write # IMPORTANT: mandatory for trusted publishing
58+
steps:
59+
- name: Download all the dists
60+
uses: actions/download-artifact@v5
61+
with:
62+
name: python-package-distributions
63+
path: dist/
64+
- name: Publish distribution 📦 to PyPI
65+
uses: pypa/gh-action-pypi-publish@release/v1.13
66+
67+
github-release:
68+
name: >-
69+
Sign the Python 🐍 distribution 📦 with Sigstore
70+
and upload them to GitHub Release
71+
needs:
72+
- publish-to-pypi
73+
runs-on: ubuntu-latest
74+
75+
permissions:
76+
contents: write # IMPORTANT: mandatory for making GitHub Releases
77+
id-token: write # IMPORTANT: mandatory for sigstore
78+
79+
steps:
80+
- name: Download all the dists
81+
uses: actions/download-artifact@v5
82+
with:
83+
name: python-package-distributions
84+
path: dist/
85+
- name: Sign the dists with Sigstore
86+
uses: sigstore/gh-action-sigstore-python@v3.0.1
87+
with:
88+
inputs: >-
89+
./dist/*.tar.gz
90+
./dist/*.whl
91+
- name: Create GitHub Release
92+
env:
93+
GITHUB_TOKEN: ${{ github.token }}
94+
run: >-
95+
gh release create
96+
'${{ github.ref_name }}'
97+
--repo '${{ github.repository }}'
98+
--notes ""
99+
- name: Upload artifact signatures to GitHub Release
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}
102+
# Upload to GitHub Release using the `gh` CLI.
103+
# `dist/` contains the built packages, and the
104+
# sigstore-produced signatures and certificates.
105+
run: >-
106+
gh release upload
107+
'${{ github.ref_name }}' dist/**
108+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)