Skip to content

ci(release): make changelog builder non-fatal #19

ci(release): make changelog builder non-fatal

ci(release): make changelog builder non-fatal #19

Workflow file for this run

name: Python uv Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write # required for GitHub Release
id-token: write # required for PyPI Trusted Publishing
actions: write # required for tag deletion
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Sync dependencies
run: uv sync --all-groups
- name: Install dependencies
run: uv pip install -e ".[neo4j]"
# Keep generated docs in lockstep with the code being released: regenerate the
# README `canpy --help` block and the Neo4j schema.json from source, and commit
# them back to main. Releases are cut from main HEAD, so this fast-forwards;
# best-effort if main moved.
- name: Sync generated docs (README --help + Neo4j schema)
if: startsWith(github.ref, 'refs/tags/')
run: |
uv run python scripts/update_readme.py
uv run canpy --emit schema > schema.neo4j.json
if git diff --quiet README.md schema.neo4j.json; then
echo "Generated docs already current."
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md schema.neo4j.json
git commit -m "docs: sync README --help and Neo4j schema for ${GITHUB_REF#refs/tags/}"
git push origin HEAD:main || echo "::warning::could not push doc sync to main (diverged?)"
fi
- name: Run tests
id: test
continue-on-error: true
run: uv run pytest
- name: Delete tag on failure
if: steps.test.conclusion == 'failure'
run: |
echo "Tests failed. Deleting tag ${GITHUB_REF#refs/tags/}..."
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git push --delete origin ${GITHUB_REF#refs/tags/}
exit 1
- name: Build package
run: uv build
# Platform-independent, version-locked release assets published alongside the
# wheels/sdist: the Neo4j schema contract (so a consumer can validate
# producer/consumer compatibility without installing the package) and the
# cargo-dist-style install script.
- name: Stage release assets (Neo4j schema + installer script)
run: |
mkdir -p release-assets
uv run canpy --emit schema > release-assets/schema.json
cp packaging/install/canpy-installer.sh release-assets/canpy-installer.sh
ls -lh release-assets
- name: Get version from tag
id: tag_name
run: |
echo "current_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
shell: bash
- name: Read Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: warn
version: ${{ steps.tag_name.outputs.current_version }}
path: ./CHANGELOG.md
- name: Build changelog
id: gen_changelog
continue-on-error: true # auto-PR-diff is best-effort; CHANGELOG.md is the source of truth
uses: mikepenz/release-changelog-builder-action@v5
with:
failOnError: "false"
configuration: .github/workflows/release_config.json
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish release on GitHub
uses: softprops/action-gh-release@v1
with:
files: |
dist/*
release-assets/*
body: |
## Release Notes (from CHANGELOG.md)
${{ steps.changelog_reader.outputs.changes }}
---
## Detailed Changes (auto-generated)
${{ steps.gen_changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI via Trusted Publishing
run: uv publish