v1.23.1 #61
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
| --- | |
| # yamllint disable rule:truthy rule:line-length | |
| name: New Release | |
| on: | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| prepare-environment: | |
| uses: ./.github/workflows/define-versions.yml | |
| check_release: | |
| runs-on: ubuntu-22.04 | |
| needs: prepare-environment | |
| outputs: | |
| is_prerelease: ${{ steps.release.outputs.is_prerelease }} | |
| is_devrelease: ${{ steps.release.outputs.is_devrelease }} | |
| version: ${{ steps.release.outputs.version }} | |
| major_minor_version: ${{ steps.release.outputs.major_minor_version }} | |
| latest_tag: ${{ steps.release.outputs.latest_tag }} | |
| steps: | |
| - name: "Check out repository code" | |
| uses: "actions/checkout@v7" | |
| with: | |
| submodules: true | |
| # Full history + tags so hatch-vcs resolves the exact tag version from installed metadata | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: "Set up Python" | |
| uses: "actions/setup-python@v7" | |
| with: | |
| python-version: "3.12" | |
| - name: Install UV | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| version: "${{ needs.prepare-environment.outputs.UV_VERSION }}" | |
| - name: Install dependencies | |
| run: uv sync --all-groups --all-extras | |
| - name: Check prerelease type | |
| id: release | |
| run: | | |
| VERSION=$(uv run python -c "import importlib.metadata; print(importlib.metadata.version('infrahub-sdk'))") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo is_prerelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_prerelease))") >> "$GITHUB_OUTPUT" | |
| echo is_devrelease=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').is_devrelease))") >> "$GITHUB_OUTPUT" | |
| echo is_local=$(uv run python -c "from packaging.version import Version; print(int(Version('$VERSION').local is not None))") >> "$GITHUB_OUTPUT" | |
| echo base_version=$(uv run python -c "from packaging.version import Version; print(Version('$VERSION').base_version)") >> "$GITHUB_OUTPUT" | |
| echo fallback_base=$(uv run python -c "import tomllib; from packaging.version import Version; print(Version(tomllib.load(open('pyproject.toml', 'rb'))['tool']['hatch']['version']['fallback-version']).base_version)") >> "$GITHUB_OUTPUT" | |
| echo major_minor_version=$(uv run python -c "from packaging.version import Version; v = Version('$VERSION'); print(f'{v.major}.{v.minor}')") >> "$GITHUB_OUTPUT" | |
| echo latest_tag=$(curl -L \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ github.token }}" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases/latest \ | |
| | jq -r '.tag_name') >> "$GITHUB_OUTPUT" | |
| - name: "Publish guard: resolved version must match the release tag" | |
| run: | | |
| EXPECTED_TAG="v${{ steps.release.outputs.version }}" | |
| if [ "${{ github.event.release.tag_name }}" != "$EXPECTED_TAG" ]; then | |
| echo "Resolved version (${{ steps.release.outputs.version }}) does not match release tag ${{ github.event.release.tag_name }}" | |
| echo "Expected: $EXPECTED_TAG" | |
| echo "Got: ${{ github.event.release.tag_name }}" | |
| exit 1 | |
| fi | |
| - name: "Publish guard: reject unreleased fallback version" | |
| # fallback_base is read from pyproject.toml at run time; the fallback is a static sentinel (0.0.0.dev0) | |
| if: steps.release.outputs.base_version == steps.release.outputs.fallback_base && (steps.release.outputs.is_devrelease == 1 || steps.release.outputs.is_local == 1) | |
| run: | | |
| echo "Resolved version (${{ steps.release.outputs.version }}) is an unreleased fallback (base ${{ steps.release.outputs.fallback_base }}, dev/local build): no v* tag is reachable. Refusing to publish." | |
| exit 1 | |
| - name: Check prerelease and project version | |
| if: github.event.release.prerelease == true && steps.release.outputs.is_prerelease == 0 && steps.release.outputs.is_devrelease == 0 | |
| run: | | |
| echo "Cannot pre-release a non pre-release or non dev-release version (${{ steps.release.outputs.version }})" | |
| exit 1 | |
| - name: Check release and project version | |
| if: github.event.release.prerelease == false && (steps.release.outputs.is_prerelease == 1 || steps.release.outputs.is_devrelease == 1) | |
| run: | | |
| echo "Cannot release a pre-release or dev-release version (${{ steps.release.outputs.version }})" | |
| exit 1 | |
| publish-pypi: | |
| needs: check_release | |
| uses: ./.github/workflows/publish-pypi.yml | |
| secrets: inherit | |
| with: | |
| publish: true | |
| update-submodule: | |
| needs: check_release | |
| uses: ./.github/workflows/update-submodule.yml | |
| secrets: inherit | |
| with: | |
| version: ${{ github.ref_name }} | |
| repository-dispatch: | |
| needs: | |
| - check_release | |
| - publish-pypi | |
| uses: ./.github/workflows/repository-dispatch.yml | |
| secrets: inherit | |
| with: | |
| version: ${{ needs.check_release.outputs.version }} |