Skip to content

Commit 638ec40

Browse files
committed
Add workflow to publish to PyPi
1 parent 401c202 commit 638ec40

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/cd.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
packaging:
14+
if: github.repository_owner == 'sgkit-dev'
15+
name: Packaging
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.9'
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
python -m pip install build twine validate-pyproject[all]
26+
- name: Check and install package
27+
run: |
28+
validate-pyproject pyproject.toml
29+
python -m build
30+
python -m twine check --strict dist/*
31+
python -m pip install dist/*.whl
32+
- name: Store the distribution packages
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: python-package-distributions
36+
path: dist/
37+
38+
publish-to-pypi:
39+
if: github.repository_owner == 'sgkit-dev' && github.event_name == 'release'
40+
needs:
41+
- packaging
42+
runs-on: ubuntu-latest
43+
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/p/hypothesis-vcf
47+
permissions:
48+
id-token: write # IMPORTANT: mandatory for trusted publishing
49+
50+
steps:
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: python-package-distributions
54+
path: dist/
55+
- uses: pypa/gh-action-pypi-publish@release/v1
56+
57+
58+
publish-to-testpypi:
59+
if: github.repository_owner == 'sgkit-dev' && github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
60+
needs:
61+
- packaging
62+
runs-on: ubuntu-latest
63+
64+
environment:
65+
name: testpypi
66+
url: https://test.pypi.org/p/hypothesis-vcf
67+
68+
permissions:
69+
id-token: write # IMPORTANT: mandatory for trusted publishing
70+
71+
steps:
72+
- uses: actions/download-artifact@v4
73+
with:
74+
name: python-package-distributions
75+
path: dist/
76+
- uses: pypa/gh-action-pypi-publish@release/v1
77+
with:
78+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)