Release GQLAlchemy #16
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: Release GQLAlchemy | |
| # Phase 2 of the release process. Run this against main AFTER the | |
| # "Prepare release" PR (prepare-release.yml) has been reviewed and merged. | |
| # The version comes from main's pyproject.toml (set and reviewed in phase 1), | |
| # so there is no version input here. main was already tested in phase 1, so | |
| # this only builds, publishes, tags, deploys the docs, and creates the | |
| # GitHub release. | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| publish_packages: | |
| description: "Publish packages" | |
| required: false | |
| type: boolean | |
| default: true | |
| publish_docs: | |
| description: "Publish docs (mkdocs gh-deploy)" | |
| required: false | |
| type: boolean | |
| default: true | |
| test: | |
| description: "Publish to Test PyPI instead of PyPI" | |
| required: false | |
| type: boolean | |
| default: true | |
| dry_run: | |
| description: "Dry run (skip creating the release tag, docs deploy and GitHub release)" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish-packages: | |
| name: Build and Publish Packages | |
| if: ${{ inputs.publish_packages == true }} | |
| runs-on: ["ubuntu-latest"] | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: "3.12" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| version: "0.11.3" | |
| - name: Build packages | |
| run: | | |
| uv build | |
| - name: Publish packages | |
| if: ${{ inputs.test == false }} | |
| run: | | |
| uv publish --token ${{ secrets.PYPI_API_TOKEN }} | |
| - name: Publish Packages (Test PyPI) | |
| if: ${{ inputs.test == true }} | |
| continue-on-error: true | |
| run: | | |
| uv publish --token ${{ secrets.TEST_PYPI_API_TOKEN }} --publish-url https://test.pypi.org/legacy/ | |
| create-tag: | |
| needs: publish-packages | |
| name: Create Release Tag | |
| # Tag main HEAD only on a real release, after publishing succeeded (or was | |
| # intentionally skipped via publish_packages=false). always() lets this run | |
| # even when publish-packages was skipped. | |
| if: >- | |
| ${{ always() && inputs.dry_run == false | |
| && (needs.publish-packages.result == 'success' || needs.publish-packages.result == 'skipped') }} | |
| runs-on: ["ubuntu-latest"] | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Read version from pyproject.toml | |
| id: version | |
| run: | | |
| version=$(grep -m1 -E '^version = ' pyproject.toml | sed -E 's/^version = "(.*)"/\1/') | |
| if [ -z "$version" ]; then | |
| echo "::error::Could not read version from pyproject.toml" | |
| exit 1 | |
| fi | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| echo "Releasing version: $version" | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| - name: Create and push tag | |
| run: | | |
| tag="v${{ steps.version.outputs.version }}" | |
| if git rev-parse "$tag" >/dev/null 2>&1; then | |
| echo "::error::Tag $tag already exists!" | |
| exit 1 | |
| fi | |
| git tag -a "$tag" -m "Release $tag" | |
| git push origin "$tag" | |
| publish-docs: | |
| name: Publish Docs | |
| if: ${{ inputs.dry_run == false && inputs.publish_docs == true }} | |
| uses: ./.github/workflows/publish-docs.yml | |
| secrets: inherit | |
| create-github-release: | |
| needs: create-tag | |
| name: Create GitHub Release | |
| uses: ./.github/workflows/create-github-release.yml | |
| with: | |
| version: ${{ needs.create-tag.outputs.version }} | |
| secrets: inherit |