v2026.05.10 #6
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: Publish Release | |
| on: | |
| release: | |
| types: | |
| - published | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate: | |
| name: Validate Release | |
| uses: ./.github/workflows/validate.yaml | |
| build: | |
| name: Build Distributions | |
| needs: | |
| - validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v8.1.0 | |
| with: | |
| enable-cache: true | |
| cache-dependency-glob: "uv.lock" | |
| - name: Validate release tag format | |
| id: version | |
| env: | |
| VERSION: ${{ github.event.release.tag_name }} | |
| run: | | |
| python - <<'PY' | |
| import os | |
| import re | |
| import sys | |
| version = os.environ["VERSION"] | |
| match = re.fullmatch(r"v(\d{4})\.(\d{1,2})\.(\d{1,2})(?:\.(\d+))?", version) | |
| if match is None: | |
| print( | |
| f"Release tag must use the form vYYYY.M.D or vYYYY.M.D.N, got {version}.", | |
| file=sys.stderr, | |
| ) | |
| raise SystemExit(1) | |
| year, month, day, serial = match.groups() | |
| normalized = ".".join( | |
| part | |
| for part in ( | |
| str(int(year)), | |
| str(int(month)), | |
| str(int(day)), | |
| str(int(serial)) if serial is not None else None, | |
| ) | |
| if part is not None | |
| ) | |
| output_path = os.environ["GITHUB_OUTPUT"] | |
| with open(output_path, "a", encoding="utf-8") as fh: | |
| fh.write(f"normalized={normalized}\n") | |
| PY | |
| - name: Build distribution packages | |
| run: uv build | |
| - name: Ensure built artifact versions match the release tag | |
| env: | |
| VERSION: ${{ steps.version.outputs.normalized }} | |
| run: | | |
| for artifact in dist/*; do | |
| case "$(basename "${artifact}")" in | |
| schnee-"${VERSION}".tar.gz|schnee-"${VERSION}"-*.whl) ;; | |
| *) | |
| echo "Built artifact does not match release version ${VERSION}: ${artifact}" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| - name: Store distribution packages | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| if-no-files-found: error | |
| publish: | |
| name: Publish to PyPI | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| environment: | |
| name: pypi | |
| steps: | |
| - name: Download distribution packages | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0 |