Skip to content

Commit 6dba599

Browse files
Add Django Commons release GHA
1 parent 6758c33 commit 6dba599

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)