Skip to content

ci: add Dependabot config, update GitHub Actions workflows with pinne… #18

ci: add Dependabot config, update GitHub Actions workflows with pinne…

ci: add Dependabot config, update GitHub Actions workflows with pinne… #18

Workflow file for this run

name: Publish 📦 to PyPI
on:
push:
tags:
- "v*"
permissions:
contents: read
jobs:
metadata:
name: Release Metadata
runs-on: ubuntu-latest
outputs:
package_version: ${{ steps.version.outputs.package_version }}
git_tag: ${{ steps.version.outputs.git_tag }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Read package version
id: version
run: |
python3 - <<'PY'
import os
import tomllib
from pathlib import Path
git_tag = os.environ["GITHUB_REF_NAME"]
version = tomllib.loads(Path("pyproject.toml").read_text(encoding="utf-8"))["project"]["version"]
expected_tag = f"v{version}"
if git_tag != expected_tag:
raise SystemExit(f"Tag {git_tag!r} does not match project version {expected_tag!r}")
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
fh.write(f"package_version={version}\n")
fh.write(f"git_tag={git_tag}\n")
print(f"{git_tag} -> {version}")
PY
verify:
name: Verify Release Candidate
uses: ./.github/workflows/ci.yml
build:
name: Build Release (${{ needs.metadata.outputs.package_version }})
runs-on: ubuntu-latest
needs: [metadata, verify]
permissions:
contents: read
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.13"
- uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
- name: Sync dependencies
run: make sync
- name: Build package
run: make build
- name: Upload distribution artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: dist-${{ needs.metadata.outputs.package_version }}
path: dist/*
if-no-files-found: error
publish:
name: Publish Release (${{ needs.metadata.outputs.package_version }})
runs-on: ubuntu-latest
needs: [metadata, build]
permissions:
contents: read
id-token: write
environment: pypi
steps:
- name: Download distribution artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: dist-${{ needs.metadata.outputs.package_version }}
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@106e0b0b7c337fa67ed433972f777c6357f78598 # v1.13.0
with:
packages-dir: dist