Skip to content

Commit bea854d

Browse files
authored
Merge pull request #53 from robsdedude/release/trusted-publisher
CI: use trusted publishing for releasing to PyPI
2 parents 9e530cd + d454468 commit bea854d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish Python 🐍️ distribution 📦️ to PyPI and TestPyPI
2+
on:
3+
push:
4+
tags:
5+
- '[0-9]+\.[0-9]+\.[0-9]+'
6+
7+
jobs:
8+
build:
9+
name: Build distribution 📦️
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
14+
with:
15+
persist-credentials: false
16+
- name: Set up Python
17+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
18+
with:
19+
python-version: '3.13'
20+
- name: Update pip
21+
run: python3 -m pip install --user -U pip
22+
- name: Install build tool(s)
23+
run: python3 -m pip install --user -U setuptools
24+
- name: Install dependencies
25+
run: python3 -m pip install --user -Ur requirements.txt
26+
- name: Build distribution packages
27+
env:
28+
VERSION: ${{ github.ref_name }}
29+
run: ./bin/make-dist.sh "${VERSION}"
30+
- name: Check distribution packages
31+
env:
32+
VERSION: ${{ github.ref_name }}
33+
run: ./bin/check-dist.sh "${VERSION}"
34+
- name: Store the distribution packages
35+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
36+
with:
37+
name: python-package-distributions
38+
path: dist/
39+
40+
pypi-publish:
41+
name: Publish distribution to PyPI 🚚️
42+
needs:
43+
- build
44+
runs-on: ubuntu-latest
45+
environment:
46+
name: pypi
47+
url: https://pypi.org/p/flake8-picky-parentheses
48+
permissions:
49+
# IMPORTANT: this permission is mandatory for Trusted Publishing
50+
id-token: write
51+
steps:
52+
- name: Download all the dists
53+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
54+
with:
55+
name: python-package-distributions
56+
path: dist/
57+
- name: Publish package distributions to PyPI
58+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
59+
60+
testpypi-publish:
61+
name: Publish distribution to TestPyPI 🚚️
62+
needs:
63+
- build
64+
runs-on: ubuntu-latest
65+
environment:
66+
name: testpypi
67+
url: https://test.pypi.org/p/flake8-picky-parentheses
68+
permissions:
69+
# IMPORTANT: this permission is mandatory for Trusted Publishing
70+
id-token: write
71+
steps:
72+
- name: Download all the dists
73+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
74+
with:
75+
name: python-package-distributions
76+
path: dist/
77+
- name: Publish package distributions to TestPyPI
78+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
79+
with:
80+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)