Skip to content

Commit 7fe64fb

Browse files
create publish.yml
1 parent 8c03c57 commit 7fe64fb

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)