Skip to content

Commit f8361c1

Browse files
authored
Create python-publish.yml
1 parent c40c147 commit f8361c1

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Publish Python package
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
name: Build distributions
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Check out source
18+
uses: actions/checkout@v6
19+
with:
20+
persist-credentials: false
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: "3.x"
26+
27+
- name: Install build tool
28+
run: python3 -m pip install --user build
29+
30+
- name: Build sdist and wheel
31+
run: python3 -m build
32+
33+
- name: Upload distribution artifacts
34+
uses: actions/upload-artifact@v5
35+
with:
36+
name: python-package-distributions
37+
path: dist/
38+
39+
publish-to-testpypi:
40+
name: Publish to TestPyPI
41+
needs:
42+
- build
43+
runs-on: ubuntu-latest
44+
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'
45+
environment:
46+
name: testpypi
47+
url: https://test.pypi.org/p/runcycles
48+
permissions:
49+
id-token: write
50+
contents: read
51+
52+
steps:
53+
- name: Download distribution artifacts
54+
uses: actions/download-artifact@v6
55+
with:
56+
name: python-package-distributions
57+
path: dist/
58+
59+
- name: Publish to TestPyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
repository-url: https://test.pypi.org/legacy/
63+
64+
publish-to-pypi:
65+
name: Publish to PyPI
66+
needs:
67+
- build
68+
runs-on: ubuntu-latest
69+
if: startsWith(github.ref, 'refs/tags/v')
70+
environment:
71+
name: pypi
72+
url: https://pypi.org/p/runcycles
73+
permissions:
74+
id-token: write
75+
contents: read
76+
77+
steps:
78+
- name: Download distribution artifacts
79+
uses: actions/download-artifact@v6
80+
with:
81+
name: python-package-distributions
82+
path: dist/
83+
84+
- name: Publish to PyPI
85+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)