From bf8790679e9a373b818d0cff7d7e1598133aad61 Mon Sep 17 00:00:00 2001 From: x5iu Date: Tue, 16 Dec 2025 23:43:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Add=20manual=20trigger=20suppor?= =?UTF-8?q?t=20for=20release=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add workflow_dispatch trigger for manual release - Check if version tag exists before creating - For manual trigger: create tag if not exists, then release - For manual trigger with existing tag: directly create release - Use prev_tag for accurate release notes generation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .github/workflows/release.yml | 39 ++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef19955..48dc683 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,7 @@ on: - main paths: - "runtime/version.go" + workflow_dispatch: jobs: release: @@ -24,21 +25,39 @@ jobs: VERSION=$(grep -oP 'const Version = "\K[^"]+' runtime/version.go) echo "version=$VERSION" >> $GITHUB_OUTPUT - # Get latest tag - LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") - echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT + # Check if version tag already exists + if git rev-parse "$VERSION" >/dev/null 2>&1; then + echo "tag_exists=true" >> $GITHUB_OUTPUT + echo "Tag $VERSION already exists" + # Get the tag before this version for release notes + PREV_TAG=$(git describe --tags --abbrev=0 "$VERSION^" 2>/dev/null || echo "") + else + echo "tag_exists=false" >> $GITHUB_OUTPUT + echo "Tag $VERSION does not exist" + # Get latest tag as previous tag + PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + fi + echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT - # Check if version differs from latest tag - if [ "$VERSION" != "$LATEST_TAG" ]; then + # Determine if we should release + # For workflow_dispatch: always release (create tag if needed, or re-release existing tag) + # For push: only release if version differs from latest tag + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then echo "should_release=true" >> $GITHUB_OUTPUT - echo "Version $VERSION differs from latest tag $LATEST_TAG, will create new release" + echo "Manual trigger: will create release for $VERSION" else - echo "should_release=false" >> $GITHUB_OUTPUT - echo "Version $VERSION matches latest tag, skipping release" + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ "$VERSION" != "$LATEST_TAG" ]; then + echo "should_release=true" >> $GITHUB_OUTPUT + echo "Version $VERSION differs from latest tag $LATEST_TAG, will create new release" + else + echo "should_release=false" >> $GITHUB_OUTPUT + echo "Version $VERSION matches latest tag, skipping release" + fi fi - name: Create new tag - if: steps.check_version.outputs.should_release == 'true' + if: steps.check_version.outputs.should_release == 'true' && steps.check_version.outputs.tag_exists == 'false' run: | VERSION="${{ steps.check_version.outputs.version }}" git config user.name "github-actions[bot]" @@ -63,7 +82,7 @@ jobs: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: | CURRENT_TAG="${{ steps.check_version.outputs.version }}" - PREV_TAG="${{ steps.check_version.outputs.latest_tag }}" + PREV_TAG="${{ steps.check_version.outputs.prev_tag }}" claude -p "Generate release notes for defc ${CURRENT_TAG} (a Go code generation tool). Previous version: ${PREV_TAG}. Instructions: 1) Read the git commits between ${PREV_TAG} and ${CURRENT_TAG} using: git log ${PREV_TAG}..HEAD --oneline; 2) Output ONLY the release notes content in Markdown format, nothing else; 3) Do NOT include any preamble, explanation, or commentary about what you are doing; 4) Format: ## Summary, ## New Features, ## Bug Fixes, ## Breaking Changes (omit empty sections); 5) Be concise and professional." --output-format text > release_notes.md - name: Create Release From 1259780558bee01a1d339144e99ecdbd98ba5fa2 Mon Sep 17 00:00:00 2001 From: Xiu <120178620+x5iu@users.noreply.github.com> Date: Tue, 16 Dec 2025 23:48:03 +0800 Subject: [PATCH 2/2] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48dc683..bf995b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: run: | CURRENT_TAG="${{ steps.check_version.outputs.version }}" PREV_TAG="${{ steps.check_version.outputs.prev_tag }}" - claude -p "Generate release notes for defc ${CURRENT_TAG} (a Go code generation tool). Previous version: ${PREV_TAG}. Instructions: 1) Read the git commits between ${PREV_TAG} and ${CURRENT_TAG} using: git log ${PREV_TAG}..HEAD --oneline; 2) Output ONLY the release notes content in Markdown format, nothing else; 3) Do NOT include any preamble, explanation, or commentary about what you are doing; 4) Format: ## Summary, ## New Features, ## Bug Fixes, ## Breaking Changes (omit empty sections); 5) Be concise and professional." --output-format text > release_notes.md + claude --model opus -p "Generate release notes for defc ${CURRENT_TAG} (a Go code generation tool). Previous version: ${PREV_TAG}. Instructions: 1) Read the git commits between ${PREV_TAG} and ${CURRENT_TAG} using: git log ${PREV_TAG}..HEAD --oneline; 2) Output ONLY the release notes content in Markdown format, nothing else; 3) Do NOT include any preamble, explanation, or commentary about what you are doing; 4) Format: ## Summary, ## New Features, ## Bug Fixes, ## Breaking Changes (omit empty sections); 5) Be concise and professional." --output-format text > release_notes.md - name: Create Release if: steps.check_version.outputs.should_release == 'true'