From debd3c2c8e1183f97fb914c7b6110d9151b3c66c Mon Sep 17 00:00:00 2001 From: pnewsam Date: Tue, 23 Jun 2026 16:55:32 -0700 Subject: [PATCH 1/3] Migrate to release train model: auto CalVer releases on push to main Rewrite release.yml to auto-compute CalVer version on every push to main, instead of triggering on manual version bumps to __init__.py. - Remove path filter on anton/__init__.py (version is now auto-computed) - Compute CalVer version from git tags (MAJOR.YY.M.DD.seq) - Write version to __init__.py, commit with [skip ci], tag, release - Publish to PyPI and run e2e tests (preserved from old workflow) Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 82 ++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 65ac87a2..a3845c9f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Auto-release on version bump +name: Auto-release on push to main permissions: contents: write @@ -6,8 +6,6 @@ permissions: on: push: branches: [main] - paths: - - 'anton/__init__.py' workflow_dispatch: concurrency: @@ -17,52 +15,69 @@ concurrency: jobs: auto-release: runs-on: ubuntu-latest + # Skip auto-version commits to prevent loops (belt-and-suspenders; + # GITHUB_TOKEN commits don't trigger workflows anyway) + if: "!contains(github.event.head_commit.message, '[skip ci]')" outputs: tag: ${{ steps.version.outputs.tag }} - created: ${{ steps.tag_check.outputs.exists == 'false' }} steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 # need tags for sequence calculation - - name: Read __version__ from anton/__init__.py + - name: Compute CalVer version id: version run: | - PKG_VERSION=$(grep -oE '__version__\s*=\s*"[^"]+"' anton/__init__.py | grep -oE '"[^"]+"' | tr -d '"') - if [ -z "${PKG_VERSION}" ]; then - echo "::error::Could not parse __version__ from anton/__init__.py" - exit 1 - fi - echo "version=${PKG_VERSION}" >> "$GITHUB_OUTPUT" - echo "tag=v${PKG_VERSION}" >> "$GITHUB_OUTPUT" - - - name: Check if tag already exists - id: tag_check + set -euo pipefail + + MAJOR=2 + YY=$(date -u +%y) # e.g. 26 + M=$(date -u +%-m) # e.g. 6 (no zero-pad) + DD=$(date -u +%-d) # e.g. 23 (no zero-pad) + + # Find the highest sequence for today's date + PREFIX="v${MAJOR}.${YY}.${M}.${DD}." + SEQ=0 + for tag in $(git tag -l "${PREFIX}*" | sort -t. -k5 -n); do + N="${tag##*.}" + if [[ "$N" =~ ^[0-9]+$ ]] && [ "$N" -gt "$SEQ" ]; then + SEQ="$N" + fi + done + SEQ=$((SEQ + 1)) + + VERSION="${MAJOR}.${YY}.${M}.${DD}.${SEQ}" + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" + echo "Computed version: ${VERSION}" + + - name: Update anton/__init__.py version run: | - TAG="${{ steps.version.outputs.tag }}" - if git rev-parse "refs/tags/${TAG}" >/dev/null 2>&1; then - echo "Tag ${TAG} already exists; nothing to do." - echo "exists=true" >> "$GITHUB_OUTPUT" - else - echo "Tag ${TAG} does not exist; will create release." - echo "exists=false" >> "$GITHUB_OUTPUT" - fi - - - name: Create tag and GitHub release - if: steps.tag_check.outputs.exists == 'false' + sed -i 's/^__version__ = ".*"/__version__ = "${{ steps.version.outputs.version }}"/' anton/__init__.py + echo "Updated anton/__init__.py:" + grep __version__ anton/__init__.py + + - name: Commit version bump + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add anton/__init__.py + git commit -m "release: ${{ steps.version.outputs.tag }} [skip ci]" + git push + + - name: Create tag and GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ steps.version.outputs.tag }} run: | - gh release create "${TAG}" \ - --target "${GITHUB_SHA}" \ - --title "${TAG}" \ - --generate-notes + git tag "${{ steps.version.outputs.tag }}" + git push origin "${{ steps.version.outputs.tag }}" + gh release create "${{ steps.version.outputs.tag }}" \ + --generate-notes \ + --title "${{ steps.version.outputs.tag }}" publish: name: Publish to PyPI needs: auto-release - if: needs.auto-release.outputs.created == 'true' runs-on: ubuntu-latest environment: pypi permissions: @@ -87,7 +102,6 @@ jobs: e2e: needs: auto-release - if: needs.auto-release.outputs.created == 'true' uses: ./.github/workflows/tests_e2e_release.yml with: tag: ${{ needs.auto-release.outputs.tag }} From c792327a9cae95ed9c33a199df9bf0b327535f9a Mon Sep 17 00:00:00 2001 From: pnewsam Date: Wed, 24 Jun 2026 19:26:58 -0700 Subject: [PATCH 2/3] Improve auto-release workflow robustness - Move CALVER_MAJOR to workflow-level env var (no magic number) - Remove __init__.py version update + commit to main (avoids branch protection issues and fragile sed) - Switch hatch version source from regex to vcs (hatch-vcs) - Add fetch-depth: 0 to publish checkout so hatch-vcs can read tags Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 20 +++++--------------- pyproject.toml | 6 +++--- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3845c9f..14adfb41 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,9 @@ concurrency: group: auto-release-${{ github.ref }} cancel-in-progress: false +env: + CALVER_MAJOR: 2 + jobs: auto-release: runs-on: ubuntu-latest @@ -30,7 +33,7 @@ jobs: run: | set -euo pipefail - MAJOR=2 + MAJOR=${{ env.CALVER_MAJOR }} YY=$(date -u +%y) # e.g. 26 M=$(date -u +%-m) # e.g. 6 (no zero-pad) DD=$(date -u +%-d) # e.g. 23 (no zero-pad) @@ -51,20 +54,6 @@ jobs: echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT" echo "Computed version: ${VERSION}" - - name: Update anton/__init__.py version - run: | - sed -i 's/^__version__ = ".*"/__version__ = "${{ steps.version.outputs.version }}"/' anton/__init__.py - echo "Updated anton/__init__.py:" - grep __version__ anton/__init__.py - - - name: Commit version bump - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git add anton/__init__.py - git commit -m "release: ${{ steps.version.outputs.tag }} [skip ci]" - git push - - name: Create tag and GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -86,6 +75,7 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ needs.auto-release.outputs.tag }} + fetch-depth: 0 # hatch-vcs needs tags to derive version - name: Setup uv uses: astral-sh/setup-uv@v5 diff --git a/pyproject.toml b/pyproject.toml index 9c0b0a77..b7276312 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] @@ -50,8 +50,8 @@ Issues = "https://github.com/mindsdb/anton/issues" anton = "anton.cli:app" [tool.hatch.version] -source = "regex" -path = "anton/__init__.py" +source = "vcs" +fallback-version = "2.0.0-dev" [tool.pytest.ini_options] asyncio_mode = "auto" From b9d5b89b6a4aa9111f2ee9b3386ec24c0e8893fc Mon Sep 17 00:00:00 2001 From: pnewsam Date: Thu, 25 Jun 2026 12:50:59 -0700 Subject: [PATCH 3/3] Remove redundant [skip ci] guard from auto-release GitHub natively skips workflows when commit messages contain [skip ci], so the explicit `if:` check is unnecessary. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14adfb41..5053fef6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,6 @@ env: jobs: auto-release: runs-on: ubuntu-latest - # Skip auto-version commits to prevent loops (belt-and-suspenders; - # GITHUB_TOKEN commits don't trigger workflows anyway) - if: "!contains(github.event.head_commit.message, '[skip ci]')" outputs: tag: ${{ steps.version.outputs.tag }} steps: