Publish Official Package #7
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 }} | |
| fetch-depth: 0 # Import all commit history and tag | |
| - name: "Build package" | |
| run: | | |
| ./ccex build | |
| - name: "Check requested version (ref_name)" | |
| run: | | |
| INPUT_REF="${{ inputs.ref_name }}" | |
| TAG_VERSION="${INPUT_REF#v}" # Strip leading 'v' from ref_name | |
| VERSION="$(versioningit)" | |
| CLEAN_VERSION="$(echo "$VERSION" | cut -d'.' -f1-3)" | |
| echo "$CLEAN_VERSION" | |
| echo "VERSION from prepared package: $CLEAN_VERSION" | |
| echo "VERSION from ref_name: $TAG_VERSION" | |
| if [ "$CLEAN_VERSION" != "$TAG_VERSION" ]; then | |
| echo "::error::VERSION($CLEAN_VERSION) of current package does not match your requested ref_name ($INPUT_REF)" | |
| exit 1 | |
| fi | |
| - 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: testpypi | |
| url: https://test.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 | |
| with: | |
| repository-url: https://test.pypi.org/legacy/ |