Skip to content

Commit 7ecea9d

Browse files
Create release.yaml
1 parent eb59aa8 commit 7ecea9d

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Build, Stage, Approve, Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
name: Build distribution 📦
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v6
14+
with:
15+
persist-credentials: false
16+
- name: Set up Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: "3.x"
20+
- name: Install pypa/build
21+
run: >-
22+
python3 -m
23+
pip install
24+
build
25+
--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@v5
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
34+
publish-to-testpypi:
35+
name: Publish Python 🐍 distribution 📦 to TestPyPI
36+
needs:
37+
- build
38+
runs-on: ubuntu-latest
39+
40+
environment:
41+
name: testpypi
42+
url: https://test.pypi.org/p/pycentral/
43+
44+
permissions:
45+
id-token: write # IMPORTANT: mandatory for trusted publishing
46+
47+
steps:
48+
- name: Download all the dists
49+
uses: actions/download-artifact@v6
50+
with:
51+
name: python-package-distributions
52+
path: dist/
53+
- name: Publish distribution 📦 to TestPyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
with:
56+
repository-url: https://test.pypi.org/legacy/
57+
58+
publish-to-pypi:
59+
name: Publish Python 🐍 distribution 📦 to PyPI
60+
needs: publish-to-testpypi # only run after TestPyPI succeeds
61+
runs-on: ubuntu-latest
62+
if: startsWith(github.ref, 'refs/tags/') # only run on tags
63+
64+
environment:
65+
name: pypi
66+
url: https://pypi.org/project/pycentral/
67+
68+
permissions:
69+
id-token: write # required for trusted publishing
70+
contents: read
71+
72+
steps:
73+
- name: Download all the dists
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: python-package-distributions
77+
path: dist/
78+
79+
- name: Publish distribution 📦 to PyPI
80+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)