Skip to content

Commit fe85ae4

Browse files
committed
rework publish workflow for trusted publisher
1 parent 4fbce8d commit fe85ae4

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

.github/workflows/publish_to_pypi.yml

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,43 @@
1+
---
12
name: Publish Pypi package
2-
33
on:
44
workflow_call:
5-
65
jobs:
76
publish_to_pypi:
87
name: Publish Python 🐍 package 📦 to PyPI
98
runs-on: ubuntu-latest
9+
permissions:
10+
# This permission is required for trusted publishing.
11+
id-token: write
12+
contents: read
1013
env:
1114
ZENML_DEBUG: 1
1215
ZENML_ANALYTICS_OPT_IN: false
13-
PYTHONIOENCODING: 'utf-8'
14-
16+
PYTHONIOENCODING: utf-8
1517
steps:
16-
- uses: actions/checkout@v3
17-
18+
- uses: actions/checkout@v4.1.1
1819
- name: Get the version from the github tag ref
1920
id: get_version
2021
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
21-
2222
- name: Set up Python
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v5.0.0
2424
with:
2525
python-version: '3.8'
26-
2726
- name: Install Poetry
28-
uses: snok/install-poetry@v1
27+
uses: snok/install-poetry@v1.3.4
2928
with:
3029
virtualenvs-create: true
3130
virtualenvs-in-project: true
32-
3331
- name: Include latest dashboard
34-
shell: bash
35-
env:
36-
TAG: v0.9.0
37-
run: scripts/install-dashboard.sh
38-
39-
- name: publish
40-
env:
41-
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
42-
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
43-
run: |
32+
run: bash scripts/install-dashboard.sh
33+
- name: Build package
34+
run: poetry build
35+
- name: Mint token
36+
id: mint
37+
uses: tschm/token-mint-action@v1.0.2
38+
- name: Publish the package with poetry
39+
run: |-
4440
if [ "$(cat src/zenml/VERSION)" = "$(echo ${GITHUB_REF} | sed 's|refs/tags/||g')" ];
45-
then ./scripts/publish.sh;
41+
then poetry publish -u __token__ -p '${{ steps.mint.outputs.api-token }}';
4642
else echo "Version mismatch between src/zenml/VERSION and branch tag" && exit 1;
4743
fi
48-

0 commit comments

Comments
 (0)