Release to PyPI #21
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
name: "Release to PyPI" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.type }} | |
cancel-in-progress: true | |
on: | |
release: | |
types: [published] | |
workflow_run: | |
workflows: [Build_Wheels] | |
branches: [main] | |
types: [completed] # This ensures it triggers only after the workflow completes | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
pypi: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
permissions: | |
id-token: write | |
steps: | |
- name: Get run ID of "Build_Wheels" workflow | |
id: get-run-id | |
run: | | |
OTHER_REPO="${{ github.repository }}" | |
WF_NAME="Build_Wheels" | |
RUN_ID=`gh run --repo ${OTHER_REPO} list --workflow ${WF_NAME} --json databaseId --jq .[0].databaseId` | |
echo "Detected latest run id of ${RUN_ID} for workflow ${WF_NAME}" | |
echo "run-id=${RUN_ID}" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Download artifact from "Build_Wheels" workflow | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist # Match name used in build_wheels.yml upload artifact step | |
path: dist | |
github-token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
run-id: ${{ steps.get-run-id.outputs.run-id }} | |
- name: Show downloaded files | |
run: ls -la | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |