Skip to content

Commit 70dea72

Browse files
committed
[TASK] pypi publish
1 parent aaf40a5 commit 70dea72

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Publish bact-archiver 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 source tarball (wheel would have to be manylinux )
19+
run: python3 -m build --sdist
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 bact-archiver distribution to PyPI
28+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
29+
needs:
30+
- build
31+
runs-on: ubuntu-latest
32+
environment:
33+
name: pypi
34+
url: https://pypi.org/p/
35+
permissions:
36+
id-token: write # IMPORTANT: mandatory for trusted publishing
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: Sign bact-archiver with Sigstore and upload them to GitHub Release
49+
needs:
50+
- publish-to-pypi
51+
runs-on: ubuntu-latest
52+
53+
permissions:
54+
contents: write # IMPORTANT: mandatory for making GitHub Releases
55+
id-token: write # IMPORTANT: mandatory for sigstore
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: ./dist/*.tar.gz
67+
- name: Create GitHub Release
68+
env:
69+
GITHUB_TOKEN: ${{ github.token }}
70+
run: >-
71+
gh release create
72+
'${{ github.ref_name }}'
73+
--repo '${{ github.repository }}'
74+
--notes ""
75+
- name: Upload artifact signatures to GitHub Release
76+
env:
77+
GITHUB_TOKEN: ${{ github.token }}
78+
# Upload to GitHub Release using the `gh` CLI.
79+
# `dist/` contains the built packages, and the
80+
# sigstore-produced signatures and certificates.
81+
run: >-
82+
gh release upload
83+
'${{ github.ref_name }}' dist/**
84+
--repo '${{ github.repository }}'
85+
86+
publish-to-testpypi:
87+
name: Publish bact-archiver to TestPyPI
88+
needs:
89+
- build
90+
runs-on: ubuntu-latest
91+
92+
environment:
93+
name: testpypi
94+
url: https://test.pypi.org/p/bact-archiver
95+
96+
permissions:
97+
id-token: write # IMPORTANT: mandatory for trusted publishing
98+
99+
steps:
100+
- name: Download all the dists
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: python-package-distributions
104+
path: dist/
105+
- name: Publish distribution to TestPyPI
106+
uses: pypa/gh-action-pypi-publish@release/v1
107+
with:
108+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)