PyPi releases #53
Workflow file for this run
This file contains hidden or 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
| # Copyright 2025 Google LLC | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # https://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License | |
| # Note: Name of this file needs to be build_wheels.yaml as this is the value that has been specified in pypi | |
| # If you want to change the name of this file, please update pypi publisher: | |
| # https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
| name: PyPi releases | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| workflow_dispatch: | |
| jobs: | |
| validate_tag: | |
| name: Validate Tag Pattern | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check ref | |
| run: | | |
| # When workflow is dispatched through workflow_dispatch, it could be launched on branches instead of tags. | |
| # We want to make sure it is launched with the tag that additionally is a valid version tag. | |
| if [[ "${{ github.ref_type }}" != "tag" ]]; then | |
| echo "::error::This workflow must be run on a Tag, not a Branch." | |
| exit 1 | |
| fi | |
| if [[ ! "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "::error::Tag '${{ github.ref_name }}' does not match the required pattern v[0-9]+.[0-9]+.[0-9]+" | |
| exit 1 | |
| fi | |
| build_wheel: | |
| needs: [validate_tag] | |
| uses: ./.github/workflows/reusable_build_wheel.yaml | |
| approval: | |
| name: Wait for approval | |
| needs: [build_wheel] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: release | |
| steps: | |
| - run: echo "Deployment approved!" | |
| github_release: | |
| name: Create GitHub release | |
| runs-on: ubuntu-latest | |
| needs: [approval] | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Create Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: gh release create ${{ github.ref_name }} --generate-notes --draft=false --prerelease=false | |
| publish-to-pypi: | |
| name: Publish Python distribution to PyPI | |
| needs: [approval] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| environment: | |
| # We should configure trusted publishing as specified here: | |
| # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing | |
| name: pypi | |
| url: https://pypi.org/p/xpk # Replace <package-name> with your PyPI project name | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |