| name: Publish to PyPI | |
| on: | |
| workflow_call: | |
| inputs: | |
| tag_name: | |
| description: "release tag: tag that will be released" | |
| required: true | |
| type: string | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| publish_pypi: | |
| name: Publish runfiles to PyPI | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate release tag | |
| shell: bash | |
| env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| run: | | |
| if [[ ! "$TAG_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?$ ]]; then | |
| echo "::error::Publishing to PyPI requires a valid release tag, got: '$TAG_NAME'" | |
| exit 1 | |
| fi | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ inputs.tag_name || github.ref_name }} | |
| - name: Setup Bazel | |
| uses: ./.github/actions/setup-bazel | |
| - env: | |
| TAG_NAME: ${{ inputs.tag_name || github.ref_name }} | |
| # This special value tells pypi that the user identity is supplied within the token | |
| TWINE_USERNAME: __token__ | |
| # Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on | |
| # https://github.com/bazel-contrib/rules_python/settings/secrets/actions | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: bazel run --stamp "--embed_label=$TAG_NAME" //python/runfiles:wheel.publish |