Skip to content

Commit 56568f9

Browse files
committed
github actions: set up environments for 'deployments' tab
1 parent 5e0e266 commit 56568f9

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/main.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,14 @@ jobs:
8989
permissions:
9090
# necessary for Trusted Publishing
9191
id-token: write
92-
92+
env:
93+
# always deploy merged master to test pypi
94+
# always deploy tags to release pypi
95+
TARGET: ${{ startsWith(github.event.ref, 'refs/tags/') && 'pypi' || 'testpypi' }}
96+
environment:
97+
# for "deployments" tab on github
98+
name: ${{ env.TARGET }}
99+
url: https://${{ env.TARGET == 'pypi' && 'pypi.org' || 'test.pypi.org' }}/project/${{ steps.meta.outputs.pypi_name }}/
93100
steps:
94101
- uses: actions/checkout@v6
95102
with:
@@ -101,12 +108,11 @@ jobs:
101108
python-version: '3.12'
102109
enable-cache: false # we don't have lock files during initial CI checkout, so can't use them as cache key
103110

104-
- name: 'release to test pypi'
105-
# always deploy merged master to test pypi
106-
if: github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch)
107-
run: .ci/release --use-test-pypi
111+
- name: 'release ${{ steps.meta.outputs.pypi_name }} to ${{ env.TARGET }}'
112+
run: .ci/release ${{ env.TARGET == 'testpypi' && '--use-test-pypi' || '' }}
108113

109-
- name: 'release to prod pypi'
110-
# always deploy tags to release pypi
111-
if: startsWith(github.event.ref, 'refs/tags/')
112-
run: .ci/release
114+
- id: meta
115+
shell: bash
116+
run: |
117+
pypi_name=$(unzip -p dist/*.whl '*.dist-info/METADATA' | awk '/^Name:/ {print $2; exit}')
118+
echo "pypi_name=$pypi_name" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)