Skip to content

Commit 967e1f3

Browse files
committed
Updating publishing to PyPI actions
1 parent 52ef228 commit 967e1f3

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,37 @@ jobs:
3131
- name: Run core tests
3232
run: python -m unittest discover --pattern "*_test.py" --start-directory "pathwaysutils/test"
3333

34-
# Auto-publish when version is increased
35-
publish-job:
36-
# Only try to publish if:
37-
# * Repo is self (prevents running from forks)
38-
# * Branch is `main`
39-
if: |
40-
github.repository == 'AI-Hypercomputer/pathways-utils'
41-
&& github.ref == 'refs/heads/main'
42-
needs: unittest-job # Only publish after tests are successful
34+
publish-to-testpypi:
35+
if: ${{inputs.testpypi}} == true
36+
name: Publish Python distribution to TestPyPI
37+
needs:
38+
- build
4339
runs-on: ubuntu-latest
40+
environment:
41+
name: testpypi
42+
url: https://test.pypi.org/p/pathwaysutils
4443
permissions:
45-
contents: write
46-
timeout-minutes: 30
47-
44+
id-token: write
4845
steps:
49-
# Publish the package (if local `__version__` > pip version)
50-
- uses: etils-actions/pypi-auto-publish@v1
46+
- name: Download all the dists
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish distribution 📦 to TestPyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
5153
with:
52-
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
53-
gh-token: ${{ secrets.GH_TOKEN }}
54-
parse-changelog: true
54+
repository-url: https://test.pypi.org/legacy/
55+
verbose: true
56+
57+
publish-to-pypi:
58+
name: Publish Python distribution to PyPI
59+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
60+
needs: unittest-job # Only publish after tests are successful
61+
runs-on: ubuntu-latest
62+
environment:
63+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing
64+
name: pypi
65+
url: https://pypi.org/p/pathwaysutils # Replace <package-name> with your PyPI project name
66+
permissions:
67+
id-token: write # IMPORTANT: mandatory for trusted publishing

0 commit comments

Comments
 (0)