Skip to content

Commit 917b75f

Browse files
authored
Merge pull request #104 from django-commons/django-commons-release
Add Django Commons release.yml
2 parents 63c0ac7 + 3ceb297 commit 917b75f

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)