Skip to content

Commit 5695e17

Browse files
committed
chore(pypi): use trusted publishing
1 parent 687bcaf commit 5695e17

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎.github/workflows/cd.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ on:
88
jobs:
99
check-version:
1010
runs-on: ubuntu-latest
11-
permissions:
11+
environment: pypi
12+
permissions:
1213
pull-requests: write
1314
contents: write
15+
id-token: write
1416
steps:
1517
- uses: actions/checkout@v4
1618
with:
@@ -24,7 +26,6 @@ jobs:
2426
- name: Push tag for each updated package
2527
env:
2628
GH_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
27-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
2829
run: |
2930
git config --global user.name "SDK Releaser Bot"
3031
git config --global user.email "noreply@stackit.de"

‎RELEASE.md‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55
A release of the whole SDK should be created at least every 2 weeks.
66

7+
## PyPI trusted publishing setup
8+
9+
The [CD workflow](.github/workflows/cd.yaml) publishes the core package and service
10+
packages with `uv publish --trusted-publishing always`. GitHub Actions OIDC is
11+
required; no long-lived PyPI token is used. Keep the workflow filename `cd.yaml`
12+
and the job's environment `pypi` in sync with the PyPI publisher configuration.
13+
14+
The job grants `id-token: write` so uv can obtain short-lived publishing
15+
credentials.
16+
17+
References: [PyPI trusted publishers](https://docs.pypi.org/trusted-publishers/adding-a-publisher/),
18+
[uv publishing from GitHub Actions](https://docs.astral.sh/uv/guides/integration/github/#publishing-to-pypi),
19+
[GitHub environment options](https://docs.github.com/en/actions/reference/workflows-and-actions/deployments-and-environments).
20+
721
## Release creation
822

923
### Single service
@@ -38,4 +52,3 @@ The SDK is split into all the different STACKIT [services](https://github.com/st
3852
4. Copy the changelog entries for the new release from the `CHANGELOG.md` file in the root directory of the repository (see [here](https://github.com/stackitcloud/stackit-sdk-python/blob/608176ab8cdfa60a3cfb09da49de0b1aba5fea84/CHANGELOG.md)) to your clipboard.
3953
5. Go to the [releases page](https://github.com/stackitcloud/stackit-sdk-python/releases) on GitHub and create a new release. Select the git tag you just created.
4054
6. Before creating the GitHub release, add the *Highlights* heading at the top of the markdown description and paste the changelog entries from your clipboard (see [previous releases](https://github.com/stackitcloud/stackit-sdk-python/releases/tag/release-2025-03-27) to see what it should look like). Then create and publish the GitHub release.
41-

‎scripts/cd.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for file in $(find . -print | sed 's|^./||' | grep -E "(^services/[^/]+/pyprojec
1919
git push origin tag $expected_tag
2020
cd $dirpath
2121
uv build
22-
uv publish --username="__token__" --password="$PYPI_TOKEN"
22+
uv publish --trusted-publishing always
2323
cd $GITHUB_WORKSPACE
2424
fi
2525
done

0 commit comments

Comments
 (0)