Skip to content

Commit 1ef8276

Browse files
authored
Merge pull request #95 from CambioML/jojo-branch
add pypi release github action
2 parents 61593a5 + 7b60f9b commit 1ef8276

File tree

1 file changed

+120
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)