Skip to content

Commit c10fa8b

Browse files
authored
Set up Django Commons release workflow (#133)
* Set up Django Commons release workflow * Disable test-pypi publish
1 parent 11f3a02 commit c10fa8b

File tree

2 files changed

+121
-32
lines changed

2 files changed

+121
-32
lines changed

.github/workflows/publish.yml

-32
This file was deleted.

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)