Skip to content

Commit d47597d

Browse files
committed
ci: add publish workflow
1 parent 6523bd4 commit d47597d

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Publish Python distribution to PyPI and TestPyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Build distribution
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
persist-credentials: false
17+
18+
- name: Setup just
19+
uses: extractions/setup-just@v3
20+
with:
21+
just-version: 1.38.0
22+
23+
- name: Setup uv
24+
uses: astral-sh/setup-uv@v6
25+
with:
26+
version: 0.6.4
27+
28+
- name: Build a binary wheel and a source tarball
29+
run: just build
30+
31+
- name: Store the distribution packages
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: python-package-distributions
35+
path: dist/
36+
37+
publish-to-pypi:
38+
name: >-
39+
Publish Python distribution to PyPI
40+
if: startsWith(github.ref, 'refs/tags/')
41+
needs:
42+
- build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/p/textcase
47+
permissions:
48+
id-token: write
49+
50+
steps:
51+
- name: Download all the dists
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: python-package-distributions
55+
path: dist/
56+
57+
- name: Publish distribution to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
60+
publish-to-testpypi:
61+
name: Publish Python distribution to TestPyPI
62+
needs:
63+
- build
64+
runs-on: ubuntu-latest
65+
66+
environment:
67+
name: testpypi
68+
url: https://test.pypi.org/p/textcase
69+
70+
permissions:
71+
id-token: write
72+
73+
steps:
74+
- name: Download all the dists
75+
uses: actions/download-artifact@v4
76+
with:
77+
name: python-package-distributions
78+
path: dist/
79+
80+
- name: Publish distribution to TestPyPI
81+
uses: pypa/gh-action-pypi-publish@release/v1
82+
with:
83+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)