Skip to content

Commit dac888e

Browse files
committed
add publishing workflow
1 parent 3ad18bd commit dac888e

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)