Skip to content

Commit 05bbb3c

Browse files
authored
cicd: update release.yaml (publish python distribution to pypi)
- Followed https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ - Did not include [Signing the distribution packages](https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#signing-the-distribution-packages) - In `publish-to-pypi`, removed `if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes` since we only make a release when a GH release is created.
1 parent 26f57a1 commit 05bbb3c

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

.github/workflows/release.yml

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
1-
name: Upload Python Package
1+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2+
name: Publish Python distribution to PyPI
23

34
on:
45
release:
56
types: [created]
67

78
jobs:
8-
deploy:
9+
build:
10+
name: Build distribution
911
runs-on: ubuntu-latest
1012

1113
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-python@v4
14-
- name: Install dependencies
15-
run: |
16-
python3 -m pip install --upgrade pip
17-
pip install setuptools wheel twine
18-
- name: Build and publish
19-
env:
20-
TWINE_USERNAME: __token__
21-
TWINE_PASSWORD: ${{ secrets.PYPI }}
22-
run: |
23-
python3 setup.py sdist bdist_wheel
24-
twine upload dist/*
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.x"
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+
publish-to-pypi:
33+
name: >-
34+
Publish Python distribution to PyPI
35+
needs:
36+
- build
37+
runs-on: ubuntu-latest
38+
environment:
39+
name: pypi
40+
url: https://pypi.org/p/cool-seq-tool
41+
permissions:
42+
id-token: write # IMPORTANT: mandatory for trusted publishing
43+
steps:
44+
- name: Download all the dists
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
- name: Publish distribution to PyPI
50+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)