Skip to content

Commit c5ab9db

Browse files
authored
Update pythonpublish.yml
1 parent 7462eba commit c5ab9db

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

.github/workflows/pythonpublish.yml

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,55 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
# https://www.caktusgroup.com/blog/2021/02/11/automating-pypi-releases/
1+
# This workflows will upload a Python Package for tagged commits
2+
# For more information see: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
43

5-
name: Published
4+
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
65

7-
on:
6+
on:
87
release:
98
types: [created]
109

1110
jobs:
12-
deploy:
13-
11+
build:
12+
name: Build distribution 📦
1413
runs-on: ubuntu-latest
1514

1615
steps:
17-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1817
- name: Set up Python
19-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.11"
21+
- name: Install pypa/build
22+
run: >-
23+
python3 -m
24+
pip install
25+
build
26+
--user
27+
- name: Build a source distribution
28+
run: python3 -m build
29+
- name: Store the distribution packages
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: python-package-distributions
33+
path: dist/
34+
35+
publish-to-pypi:
36+
name: >-
37+
Publish Python 🐍 distribution 📦 to PyPI
38+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
39+
needs:
40+
- build
41+
runs-on: ubuntu-latest
42+
environment:
43+
name: release
44+
url: https://pypi.org/project/astroviper
45+
permissions:
46+
id-token: write # IMPORTANT: mandatory for trusted publishing
47+
48+
steps:
49+
- name: Download all the dists
50+
uses: actions/download-artifact@v3
2051
with:
21-
python-version: '3.11'
22-
- name: Install dependencies
23-
run: |
24-
python -m pip install --upgrade pip
25-
pip install setuptools wheel twine build
26-
- name: Build and publish
27-
env:
28-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
29-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
30-
run: |
31-
python -m build
32-
twine upload dist/*
52+
name: python-package-distributions
53+
path: dist/
54+
- name: Publish distribution 📦 to PyPI
55+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)