Publish Official Package #1
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
| name: Publish Official Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ref_name: | |
| description: 'Git reference (branch or tag) to build and publish' | |
| required: true | |
| type: string | |
| jobs: | |
| build-and-upload: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout the specified ref | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.ref_name }} | |
| # Verify version consistency between tag and version.py | |
| - name: Check version.py matches ref_name | |
| run: | | |
| FILE_VERSION=$(python -c 'exec(open("version.py").read()); print(VERSION)') | |
| INPUT_REF="${{ inputs.ref_name }}" | |
| TAG_VERSION="${INPUT_REF#v}" # Strip leading 'v' from ref_name | |
| echo "VERSION in version.py: $FILE_VERSION" | |
| echo "VERSION from ref_name: $TAG_VERSION" | |
| if [ "$FILE_VERSION" != "$TAG_VERSION" ]; then | |
| echo "::error::VERSION in version.py ($FILE_VERSION) does not match ref_name ($INPUT_REF)" | |
| exit 1 | |
| fi | |
| - name: "Build package" | |
| run: | | |
| ./ccex build | |
| - name: "Upload artifact" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "wheel" | |
| path: "./dist/" | |
| publish-to-pypi: | |
| needs: | |
| - build-and-upload | |
| runs-on: ubuntu-22.04 | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/TICO | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: "Download all the dists" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: "wheel" | |
| path: "./dist/" | |
| - name: "Publish distribution to PyPI" | |
| uses: pypa/gh-action-pypi-publish@release/v1 |