From 178a1bd439af61035ccc9d742a0ec0ca80848a21 Mon Sep 17 00:00:00 2001 From: Ashmit Biswas Date: Sun, 31 May 2026 07:12:46 +0530 Subject: [PATCH] =?UTF-8?q?infra:=20add=20Release=20workflow=20(manual=20d?= =?UTF-8?q?ispatch=20=E2=86=92=20tag=20from=20=5F=5Fversion=5F=5F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a workflow_dispatch action that reads __version__ from src/canopy/__init__.py, refuses if the corresponding tag already exists, and pushes vN.N.N. The existing publish.yml fires on the tag push and ships canopy-cli to PyPI. New release flow: 1. Merge a PR that bumps __version__ (and CHANGELOG) 2. Actions → "Release (tag from __version__)" → Run workflow 3. Done. Replaces the manual `git tag vN.N.N && git push origin vN.N.N` step. --- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..deb78ca --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release (tag from __version__) + +on: + workflow_dispatch: + +permissions: + contents: write # needed to push the tag + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Read __version__ + id: ver + run: | + V=$(python -c "import re,pathlib; print(re.search(r'__version__\s*=\s*\"([^\"]+)\"', pathlib.Path('src/canopy/__init__.py').read_text()).group(1))") + echo "version=$V" >> "$GITHUB_OUTPUT" + echo "Will release v$V" + + - name: Refuse if tag already exists + run: | + if git rev-parse -q --verify "refs/tags/v${{ steps.ver.outputs.version }}" >/dev/null; then + echo "::error::Tag v${{ steps.ver.outputs.version }} already exists. Bump __version__ first." + exit 1 + fi + + - name: Configure git identity + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + - name: Tag and push + run: | + git tag "v${{ steps.ver.outputs.version }}" + git push origin "v${{ steps.ver.outputs.version }}"