Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 12: Update release script to adopt Trusted publisher management in pypi. #13

Merged
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
104b411
Update release script.
Bhupender-Y Nov 29, 2023
c934f9c
Update pypi with testpypi for testing.
Bhupender-Y Nov 29, 2023
8339f90
Update name for testpypi.
Bhupender-Y Nov 29, 2023
2e44a16
Update release script url.
Bhupender-Y Nov 29, 2023
0429a3c
Update release script url.
Bhupender-Y Nov 29, 2023
a945207
Update mint token.
Bhupender-Y Nov 29, 2023
a8df527
Update token for twin.
Bhupender-Y Nov 29, 2023
284db5d
Test commit.
Bhupender-Y Nov 29, 2023
573b2de
Add pypi-publish in action.
Bhupender-Y Nov 29, 2023
0887c18
Update twine password.
Bhupender-Y Nov 29, 2023
88e2731
update twine password.
Bhupender-Y Nov 29, 2023
a44899c
Test commit
Bhupender-Y Nov 30, 2023
91a47ce
Merge mint token and publish.
Bhupender-Y Nov 30, 2023
33d336d
Test commit.
Bhupender-Y Nov 30, 2023
73cdbb3
Print all result.
Bhupender-Y Nov 30, 2023
3010197
Print all results.
Bhupender-Y Nov 30, 2023
faa2330
Introduce single quote.
Bhupender-Y Nov 30, 2023
ec808f6
Print json data.
Bhupender-Y Nov 30, 2023
61bb15c
Remove double quotes.
Bhupender-Y Nov 30, 2023
e0fb6c5
Remove raw value.
Bhupender-Y Nov 30, 2023
2a5b684
update URL
Bhupender-Y Nov 30, 2023
af149c1
update token value.
Bhupender-Y Dec 1, 2023
2f84315
Update pypi account
Bhupender-Y Dec 1, 2023
1b4efa4
Change oidc token.
Bhupender-Y Dec 1, 2023
869f42e
Upload artifacts on pypi.
Bhupender-Y Dec 1, 2023
0827c4b
Print token.
Bhupender-Y Dec 1, 2023
f1abfdb
Remove double quotes.
Bhupender-Y Dec 1, 2023
b954f66
Remove double quotes.
Bhupender-Y Dec 1, 2023
b85432c
Remove echo and add mask to api-token.
Bhupender-Y Dec 1, 2023
89259fc
Change version to 0.3.7
Bhupender-Y Dec 1, 2023
8779bee
Resolve mint token failure.
Bhupender-Y Dec 1, 2023
669b8ab
Escape in curl request.
Bhupender-Y Dec 4, 2023
19bfb27
get token using bash.
Bhupender-Y Dec 4, 2023
71036cf
Test commit.
Bhupender-Y Dec 4, 2023
d43c1d4
Revert changes.
Bhupender-Y Dec 4, 2023
38fa230
Remove permissions.
Bhupender-Y Dec 4, 2023
420ffec
Update the permissions.
Bhupender-Y Dec 4, 2023
0741cd4
Update permissions.
Bhupender-Y Dec 4, 2023
2096f4a
Test commit.
Bhupender-Y Dec 4, 2023
e88fd97
Revert test changes.
Bhupender-Y Dec 4, 2023
a6b0c93
Add reference link.
Bhupender-Y Dec 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/tagPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
wheel:
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }}
runs-on: ${{ matrix.platform.os }}
permissions:
id-token: write
contents: write
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
Expand Down Expand Up @@ -66,11 +69,29 @@ jobs:
- name: build source
id: build_source
run: python -u .github/workflows/build_source.py
- name: mint API token
id: mint-token
shell: bash
# Reference link : https://docs.pypi.org/trusted-publishers/using-a-publisher/
run: |
# retrieve the ambient OIDC token
Bhupender-Y marked this conversation as resolved.
Show resolved Hide resolved
resp=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=pypi")
oidc_token=$(jq '.value' <<< "${resp}")
# exchange the OIDC token for an API token
resp=$(curl -X POST https://pypi.org/_/oidc/github/mint-token -d "{\"token\": ${oidc_token}}")
api_token=$(jq -r '.token' <<< "${resp}")

# mask the newly minted API token, so that we don't accidentally leak it
echo "::add-mask::${api_token}"

# see the next step in the workflow for an example of using this step output
echo "api-token=${api_token}" >> "${GITHUB_OUTPUT}"
- name: Publish to pypi
env:
# the username and the repository needs to be changed before release.
TWINE_USERNAME: ${{ secrets.pypi_user_name }}
TWINE_PASSWORD: ${{ secrets.pypi_password }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ steps.mint-token.outputs.api-token }}
TWINE_REPOSITORY: pypi
run: |
pip install -U twine
Expand Down
Loading