Skip to content

Commit f3f51fc

Browse files
committed
Publish releases to pypi
1 parent 7dbf7f7 commit f3f51fc

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

.github/workflows/python-lib.yml

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ permissions:
1010

1111
jobs:
1212
build:
13-
1413
runs-on: ubuntu-latest
15-
1614
steps:
1715
- uses: actions/checkout@v4
1816
- name: Fetch test files
@@ -24,7 +22,7 @@ jobs:
2422
- name: List test files
2523
run: |
2624
find tests/testdata/ -iname '*.dat'
27-
- name: Set up Python 3.10
25+
- name: Set up Python 3.11
2826
uses: actions/setup-python@v3
2927
with:
3028
python-version: "3.11"
@@ -36,3 +34,57 @@ jobs:
3634
- name: Run test script
3735
run: |
3836
./test
37+
- name: Build distribution
38+
run: |
39+
python3 -m pip install --upgrade build
40+
python3 -m build
41+
- name: Store the distribution packages
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: python-package-distributions
45+
path: dist/
46+
47+
publish-to-pypi:
48+
name: >-
49+
Publish Python 🐍 distribution 📦 to PyPI
50+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
51+
needs:
52+
- build
53+
runs-on: ubuntu-latest
54+
environment:
55+
name: release
56+
url: https://pypi.org/p/genieutils-py
57+
permissions:
58+
id-token: write # IMPORTANT: mandatory for trusted publishing
59+
steps:
60+
- name: Download all the dists
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: python-package-distributions
64+
path: dist/
65+
- name: Publish distribution 📦 to PyPI
66+
uses: pypa/gh-action-pypi-publish@release/v1
67+
68+
publish-to-testpypi:
69+
name: Publish Python 🐍 distribution 📦 to TestPyPI
70+
needs:
71+
- build
72+
runs-on: ubuntu-latest
73+
74+
environment:
75+
name: testpypi
76+
url: https://test.pypi.org/p/<package-name>
77+
78+
permissions:
79+
id-token: write # IMPORTANT: mandatory for trusted publishing
80+
81+
steps:
82+
- name: Download all the dists
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: python-package-distributions
86+
path: dist/
87+
- name: Publish distribution 📦 to TestPyPI
88+
uses: pypa/gh-action-pypi-publish@release/v1
89+
with:
90+
repository-url: https://test.pypi.org/legacy/

0 commit comments

Comments
 (0)