Skip to content

Commit d51b514

Browse files
authored
Merge pull request #9 from nejch/oidc-release
feat(ci): switch to OIDC publishing
2 parents a2b8c8c + ea5af31 commit d51b514

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/release.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ on:
77

88
jobs:
99
release:
10-
if: github.repository == 'python-gitlab/python-gitlab'
10+
if: github.repository == 'nejch/python-gitlab' # testing via test.pypi.org first
1111
runs-on: ubuntu-latest
12+
environment: test.pypi.org # testing via test.pypi.org first
1213
steps:
1314
- uses: actions/checkout@v3.5.0
1415
with:
1516
fetch-depth: 0
1617
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
18+
- name: mint API token
19+
id: mint-token
20+
run: |
21+
oidc_token=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=testpypi" | jq '.value')
22+
api_token=$(curl -X POST https://test.pypi.org/_/oidc/github/mint-token -d "{\"token\": \"${oidc_token}\"}" | jq '.token')
23+
echo "::add-mask::${api_token}"
24+
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
1725
- name: Python Semantic Release
1826
uses: relekang/python-semantic-release@v7.33.2
1927
with:
2028
github_token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
21-
pypi_token: ${{ secrets.PYPI_TOKEN }}
29+
pypi_token: ${{ steps.mint-token.outputs.api-token }}

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ branch = "main"
3030
version_variable = "gitlab/_version.py:__version__"
3131
commit_subject = "chore: release v{version}"
3232
commit_message = ""
33+
repository = "testpypi" # testing via test.pypi.org first
3334

3435
[tool.pylint.messages_control]
3536
max-line-length = 88

0 commit comments

Comments
 (0)