Add PyPI Trusted Publishing release flow #1
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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| name: Test, build, publish | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/glasskit.ai | |
| permissions: | |
| contents: write | |
| id-token: write | |
| defaults: | |
| run: | |
| working-directory: cli | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: cli/uv.lock | |
| working-directory: cli | |
| - name: Install Python | |
| run: uv python install 3.12 | |
| - name: Sync dependencies | |
| run: uv sync --locked --dev | |
| - name: Verify tag matches package version | |
| shell: bash | |
| run: | | |
| PACKAGE_VERSION="$(uv version --short)" | |
| TAG_VERSION="${GITHUB_REF_NAME#v}" | |
| if [[ "${PACKAGE_VERSION}" != "${TAG_VERSION}" ]]; then | |
| echo "::error::pyproject.toml version ${PACKAGE_VERSION} does not match tag ${TAG_VERSION}" | |
| exit 1 | |
| fi | |
| - name: Type check | |
| run: uv run ty check | |
| - name: Run tests | |
| run: uv run pytest | |
| - name: Lint | |
| run: uv run ruff check | |
| - name: Check formatting | |
| run: uv run ruff format --check | |
| - name: Smoke test CLI help | |
| run: | | |
| uv run glasskit --help | |
| uv run glasskit eval --help | |
| - name: Build distributions | |
| run: uv build --no-sources --clear | |
| - name: Smoke test wheel | |
| run: uv run --isolated --no-project --with dist/*.whl glasskit --help | |
| - name: Smoke test source distribution | |
| run: uv run --isolated --no-project --with dist/*.tar.gz glasskit --help | |
| - name: Publish to PyPI | |
| run: uv publish --trusted-publishing always | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release create "${GITHUB_REF_NAME}" dist/* \ | |
| --repo "${GITHUB_REPOSITORY}" \ | |
| --verify-tag \ | |
| --title "${GITHUB_REF_NAME}" \ | |
| --generate-notes |