-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace release.py with OIDC publishing
We are now in the PyPI OIDC publishing beta
- Loading branch information
Showing
3 changed files
with
44 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Publish to PyPI | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["wheel-builder.yml"] | ||
types: [completed] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
# We're not actually verifying that the triggering push event was for a | ||
# tag, because github doesn't expose enough information to do so. | ||
# wheel-builder.yml currently only has push events for tags. | ||
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' | ||
permissions: | ||
id-token: "write" | ||
steps: | ||
- uses: dawidd6/action-download-artifact@5e780fc7bbd0cac69fc73271ed86edf5dcb72d67 | ||
with: | ||
path: dist/ | ||
run_id: ${{ github.event.workflow_run.event.id }} | ||
- run: pip install -c ci-constraints-requirements.txt twine requests | ||
- run: | | ||
import json | ||
import requests | ||
response = requests.get( | ||
os.environ["ACTIONS_ID_TOKEN_REQUEST_URL"] + "&audience=pypi", | ||
headers={"Authorization": f"bearer {os.environ['ACTIONS_ID_TOKEN_REQUEST_TOKEN']"} | ||
) | ||
response.raise_for_status() | ||
token = response.json()["value"] | ||
response = requests.post("https://pypi.org/_/oidc/github/mint-token", json={"token": token}) | ||
response.raise_for_status() | ||
pypi_token = response.json()["token"] | ||
with open(os.environ["GITHUB_ENV"], "a") as f: | ||
f.write("TWINE_PASSWORD={pypi_token}\n") | ||
shell: python | ||
- run: twine upload dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters