Skip to content

Commit 662758e

Browse files
authored
CI - Swap to trusted publisher for releases (#1758)
* 👷 Remove token based release from CI * Add package inspection step
1 parent 525e52d commit 662758e

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

.github/workflows/publish.yml

+40-15
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,59 @@
1-
# This will run every time a tag is created and pushed to the repository.
1+
# This will run every time a release is created and published.
22
# It calls our tests workflow via a `workflow_call`, and if tests pass
33
# then it triggers our upload to PyPI for a new release.
44
name: Publish to PyPI
55
on:
66
release:
7-
types: ["published"]
7+
types:
8+
- published
9+
workflow_dispatch:
10+
11+
env:
12+
FORCE_COLOR: "1" # Make tools pretty.
13+
14+
permissions:
15+
contents: read
16+
id-token: write # needed for PyPI upload
817

918
jobs:
19+
# calls our tests workflow
1020
tests:
1121
uses: ./.github/workflows/tests.yml
12-
publish:
13-
name: publish
22+
23+
build-package:
24+
name: "Build & verify PST package"
1425
needs: [tests] # require tests to pass before deploy runs
1526
runs-on: ubuntu-latest
1627
steps:
17-
- name: Checkout source
28+
- name: "Checkout repository 🛎"
1829
uses: actions/checkout@v4
19-
- name: Set up Python 3.9
30+
31+
- name: "Set up Python 3.9"
2032
uses: actions/setup-python@v5
2133
with:
2234
python-version: "3.9"
23-
- name: Install gettext for translations
35+
36+
- name: "Install gettext for translations 🌐"
2437
run: |
2538
sudo apt-get install gettext
26-
- name: Build package
27-
run: |
28-
python -m pip install -U pip build
29-
python -m build
30-
- name: Publish
31-
uses: pypa/gh-action-pypi-publish@release/v1
39+
40+
- name: "Build and inspect package 📦"
41+
uses: hynek/build-and-inspect-python-package@v2
42+
id: baipp
43+
44+
- run: echo Packages can be found at ${{ steps.baipp.outputs.dist }}
45+
46+
release-pypi:
47+
runs-on: ubuntu-latest
48+
needs: [build-package]
49+
steps:
50+
- name: "Download PST built package 📦"
51+
uses: actions/download-artifact@v4
3252
with:
33-
user: __token__
34-
password: ${{ secrets.PYPI_KEY }}
53+
name: PST-package
54+
path: dist
55+
56+
- name: "Publish PST package to PyPI 🚀"
57+
uses: pypa/gh-action-pypi-publish@release/v1
58+
# only publish if this is a published release by pydata
59+
if: github.repository_owner == 'pydata' && github.event_name == 'release' && github.event.action == 'published'

0 commit comments

Comments
 (0)