Skip to content

Commit 47c48ee

Browse files
committed
Add initial publish workflow
1 parent bdf2973 commit 47c48ee

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

.github/workflows/publish.yml

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Publish to TestPyPI and PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- v*
9+
10+
jobs:
11+
build:
12+
name: Build distribution
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.x"
20+
- name: Install poetry
21+
run: >-
22+
pip install poetry --user
23+
- name: Build
24+
run: poetry build
25+
- name: Store distribution packages
26+
uses: actions/upload-artifact@v3
27+
with:
28+
name: python-package-distributions
29+
path: dist/
30+
31+
publish-to-pypi:
32+
name: Publish Python distribution to PyPI
33+
if: startsWith(github.ref, 'refs/tags/')
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/simplemonitor
40+
permissions:
41+
id-token: write
42+
steps:
43+
- name: Download dists
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: python-package-distributions
47+
path: dist/
48+
- name: Publish to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
51+
github-release:
52+
name: Sign distribution and upload to GitHub Release
53+
needs:
54+
- publish-to-pypi
55+
runs-on: ubuntu-latest
56+
permissions:
57+
contents: write
58+
id-token: write
59+
steps:
60+
- name: Download dists
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: python-package-distributions
64+
path: dist/
65+
- name: Sign the dists with Sigstore
66+
uses: sigstore/gh-action-sigstore-python@v2.1.1
67+
with:
68+
inputs: >-
69+
./dist/*.tar.gz
70+
./dist/*.whl
71+
- name: Create GitHub release
72+
env:
73+
GITHUB_TOKEN: ${{ github.token }}
74+
run: >-
75+
gh release create
76+
'${{ github.ref_name }}'
77+
--repo '${{ github.repository }}'
78+
--notes ""
79+
- name: Upload artifact signatures to GitHub Release
80+
env:
81+
GITHUB_TOKEN: ${{ github.token }}
82+
run: >-
83+
gh release upload
84+
'${{ github.ref_name }}' dist/**
85+
--repo '${{ github.repository }}'
86+
87+
publish-to-testpypi:
88+
name: Publish Python distribution to TestPyPI
89+
needs:
90+
- build
91+
runs-on: ubuntu-latest
92+
environment:
93+
name: pypi
94+
url: https://test.pypi.org/p/simplemonitor
95+
permissions:
96+
id-token: write
97+
steps:
98+
- name: Download dists
99+
uses: actions/download-artifact@v4
100+
with:
101+
name: python-package-distributions
102+
path: dist/
103+
- name: Publish to TestPyPI
104+
uses: pypa/gh-action-pypi-publish@release/v1
105+
with:
106+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)