name: Release on: push: tags: - 'v*.*.*' permissions: contents: read jobs: build: name: Build and check the release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v7 - name: Set up uv and Python 3.12 uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0 with: python-version: "3.12" - name: Check that the tag matches the package version env: TAG: ${{ github.ref_name }} run: | version="$(uv version --short)" if [ "v$version" != "$TAG" ]; then echo "::error::tag $TAG does not match the version in pyproject.toml ($version)" exit 1 fi - name: Install dependencies run: uv sync --locked - name: Run tests run: uv run pytest - name: Package project run: uv build - name: Keep the distributions for the upload uses: actions/upload-artifact@v7 with: name: dist path: dist/ pypi-publish: name: Upload release to PyPI needs: build runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/project/agents-tree/ permissions: id-token: write # PyPI trusted publishing; no token is stored anywhere steps: - name: Fetch the distributions uses: actions/download-artifact@v8 with: name: dist path: dist/ - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2 github-release: name: Create GitHub Release needs: pypi-publish runs-on: ubuntu-latest permissions: contents: write steps: - name: Fetch the distributions uses: actions/download-artifact@v8 with: name: dist path: dist/ - name: Create the release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" dist/* --generate-notes --title "$GITHUB_REF_NAME"