From 266b63076bb66f91984736d8b125a642c2d524bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Thu, 12 Feb 2026 23:56:34 +0100 Subject: [PATCH 01/19] Test PR comment and summary features - Enable comment-on-pr in workflow - Enable add-to-summary in workflow - Add pull-requests write permission - Minor README update to trigger workflow --- .github/workflows/test.yml | 11 +++++++++++ README.md | 2 ++ 2 files changed, 13 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f1fc419..b94666a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + pull-requests: write steps: - uses: actions/checkout@v4 with: @@ -24,6 +25,16 @@ jobs: fi echo "Action file validated" + - name: Test PR Features + if: github.event_name == 'pull_request' + id: pr-version + uses: ./ + with: + major-version: "1" + enable-prerelease: "true" + comment-on-pr: "true" + add-to-summary: "true" + - name: Create Release Version if: github.event_name == 'push' && github.ref == 'refs/heads/main' id: version diff --git a/README.md b/README.md index b188757..a1c3704 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ Automatically version your releases based on branch naming conventions. Works on main branch merges with optional pre-release support. +> Testing PR comment and job summary features. + ## Quick Start ```yaml From b738dfb29fc24d54c212fd5c5a74cb7caec46aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Thu, 12 Feb 2026 23:58:58 +0100 Subject: [PATCH 02/19] Simplify PR comment - remove unnecessary note - Remove 'Will be published as pre-release tag' line - Remove 'Will be published when merged to main' line - Keep only version and type information --- action.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 583418f..ab0cf93 100644 --- a/action.yml +++ b/action.yml @@ -155,10 +155,8 @@ runs: if [[ "$IS_PRERELEASE" == "true" ]]; then TYPE="Pre-release" - NOTE="Will be published as pre-release tag" else TYPE="Release" - NOTE="Will be published when merged to main" fi cat > comment.md << EOF @@ -166,8 +164,7 @@ runs: This PR will create version: **$VERSION** - - Type: **$TYPE** - - $NOTE + Type: **$TYPE** EOF gh pr comment ${{ github.event.pull_request.number }} --body-file comment.md From 4c27eeaf7c1ffc51487687e885d22e7bf7fd405f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:01:39 +0100 Subject: [PATCH 03/19] Reuse PR comment and fix wording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update existing bot comment instead of creating new ones - Change wording from 'will create' to 'has been tagged as' - Check for existing comment by searching for '📦 Version' marker --- action.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index ab0cf93..a57979b 100644 --- a/action.yml +++ b/action.yml @@ -159,15 +159,22 @@ runs: TYPE="Release" fi - cat > comment.md << EOF - ## 📦 Version Preview + COMMENT_BODY="## 📦 Version - This PR will create version: **$VERSION** +The latest version for this PR has been tagged as **$VERSION** - Type: **$TYPE** - EOF +Type: **$TYPE**" - gh pr comment ${{ github.event.pull_request.number }} --body-file comment.md + # Check if bot comment already exists + EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("📦 Version"))) | .id' | head -1) + + if [[ -n "$EXISTING_COMMENT" ]]; then + # Update existing comment + gh api -X PATCH "/repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT" -f body="$COMMENT_BODY" + else + # Create new comment + gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" + fi - name: Push Tag if: steps.version.outputs.skip_tag != 'true' From 8cf2d48a07d6f61f025df04f347238cca7ae337a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:03:13 +0100 Subject: [PATCH 04/19] Fix YAML syntax by using heredoc with placeholders - Use heredoc to create comment body file - Use placeholders and sed to substitute values - Avoids YAML parsing issues with multiline strings --- action.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index a57979b..43210d7 100644 --- a/action.yml +++ b/action.yml @@ -159,21 +159,27 @@ runs: TYPE="Release" fi - COMMENT_BODY="## 📦 Version + # Create comment body + cat > comment-body.txt << 'EOF' +## 📦 Version -The latest version for this PR has been tagged as **$VERSION** +The latest version for this PR has been tagged as **VERSION_PLACEHOLDER** -Type: **$TYPE**" +Type: **TYPE_PLACEHOLDER** +EOF + + sed -i "s/VERSION_PLACEHOLDER/$VERSION/g" comment-body.txt + sed -i "s/TYPE_PLACEHOLDER/$TYPE/g" comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("📦 Version"))) | .id' | head -1) if [[ -n "$EXISTING_COMMENT" ]]; then # Update existing comment - gh api -X PATCH "/repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT" -f body="$COMMENT_BODY" + gh api -X PATCH "/repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT" -F body=@comment-body.txt else # Create new comment - gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" + gh pr comment ${{ github.event.pull_request.number }} --body-file comment-body.txt fi - name: Push Tag From cc0ffea9faed2a2ad5eb6ed0e6198aa0caf1845e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:07:04 +0100 Subject: [PATCH 05/19] fix: simplify PR comment generation using direct variable expansion Remove placeholder approach and sed substitution in favor of direct variable expansion in heredoc. This simplifies the code and avoids YAML parsing issues. Co-Authored-By: Claude Sonnet 4.5 --- action.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 43210d7..d4d7666 100644 --- a/action.yml +++ b/action.yml @@ -160,17 +160,14 @@ runs: fi # Create comment body - cat > comment-body.txt << 'EOF' + cat > comment-body.txt << EOF ## 📦 Version -The latest version for this PR has been tagged as **VERSION_PLACEHOLDER** +The latest version for this PR has been tagged as **${VERSION}** -Type: **TYPE_PLACEHOLDER** +Type: **${TYPE}** EOF - sed -i "s/VERSION_PLACEHOLDER/$VERSION/g" comment-body.txt - sed -i "s/TYPE_PLACEHOLDER/$TYPE/g" comment-body.txt - # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("📦 Version"))) | .id' | head -1) From 82de78983787d47f91dca1c27ad53631eef18d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:08:09 +0100 Subject: [PATCH 06/19] fix: simplify comment format to avoid YAML parsing issues Change from 'Type: **X**' to inline format '**VERSION** (TYPE)' to avoid YAML parser confusion with colons. Co-Authored-By: Claude Sonnet 4.5 --- action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/action.yml b/action.yml index d4d7666..f0fa584 100644 --- a/action.yml +++ b/action.yml @@ -163,9 +163,7 @@ runs: cat > comment-body.txt << EOF ## 📦 Version -The latest version for this PR has been tagged as **${VERSION}** - -Type: **${TYPE}** +The latest version for this PR has been tagged as **${VERSION}** (${TYPE}) EOF # Check if bot comment already exists From 682e3e19ac79cdb4dec6f27dd40e3ce34ae8ca87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:08:59 +0100 Subject: [PATCH 07/19] fix: replace heredoc with printf to avoid YAML parsing Use printf instead of heredoc for creating comment body to completely avoid YAML parser confusion with heredoc markers. Co-Authored-By: Claude Sonnet 4.5 --- action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/action.yml b/action.yml index f0fa584..8a983d0 100644 --- a/action.yml +++ b/action.yml @@ -160,11 +160,7 @@ runs: fi # Create comment body - cat > comment-body.txt << EOF -## 📦 Version - -The latest version for this PR has been tagged as **${VERSION}** (${TYPE}) -EOF + printf "## 📦 Version\n\nThe latest version for this PR has been tagged as **%s** (%s)\n" "$VERSION" "$TYPE" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("📦 Version"))) | .id' | head -1) From 1ca80bcbcdb0ea9667b9c3f49beba1d0f4bfa614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:09:49 +0100 Subject: [PATCH 08/19] fix: correct GitHub Actions bot username Change author.login from 'github-actions' to 'github-actions[bot]' to properly match GitHub Actions bot comments. Co-Authored-By: Claude Sonnet 4.5 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8a983d0..388560d 100644 --- a/action.yml +++ b/action.yml @@ -163,7 +163,7 @@ runs: printf "## 📦 Version\n\nThe latest version for this PR has been tagged as **%s** (%s)\n" "$VERSION" "$TYPE" > comment-body.txt # Check if bot comment already exists - EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions" and (.body | contains("📦 Version"))) | .id' | head -1) + EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) if [[ -n "$EXISTING_COMMENT" ]]; then # Update existing comment From 654c1174b29cc7c77ccf0264d5d175d72ebcb6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:13:22 +0100 Subject: [PATCH 09/19] Update PR comment to cleaner one-line format --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 388560d..4ed0ce4 100644 --- a/action.yml +++ b/action.yml @@ -160,7 +160,7 @@ runs: fi # Create comment body - printf "## 📦 Version\n\nThe latest version for this PR has been tagged as **%s** (%s)\n" "$VERSION" "$TYPE" > comment-body.txt + printf "## 📦 Version: **%s** (%s)\n" "$VERSION" "$TYPE" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) From 8caf61ea7396eec0f174c402bc4bd0fd14035774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:14:13 +0100 Subject: [PATCH 10/19] Move type to separate line in PR comment --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4ed0ce4..1ba04f2 100644 --- a/action.yml +++ b/action.yml @@ -160,7 +160,7 @@ runs: fi # Create comment body - printf "## 📦 Version: **%s** (%s)\n" "$VERSION" "$TYPE" > comment-body.txt + printf "## 📦 Version: **%s**\n%s\n" "$VERSION" "$TYPE" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) From 93b40a3833bc5b9975be3d9ee1f16c0235b16fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:16:32 +0100 Subject: [PATCH 11/19] Add comprehensive info to PR comment Add branch name, bump type, and previous version to PR comment for better visibility. Also add these as action outputs. --- action.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1ba04f2..0a58951 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,15 @@ outputs: is-prerelease: description: "Whether this is a pre-release version" value: ${{ steps.version.outputs.is_prerelease }} + branch: + description: "Branch name used for versioning" + value: ${{ steps.version.outputs.branch }} + previous-version: + description: "Previous version tag" + value: ${{ steps.version.outputs.previous_version }} + bump-type: + description: "Type of version bump (Minor or Patch)" + value: ${{ steps.version.outputs.bump_type }} runs: using: "composite" @@ -66,6 +75,12 @@ runs: IFS='.' read -r MAJ MIN PAT <<< "${LATEST#v}" echo "Version base: $MAJ.$MIN.$PAT" + # Determine bump type based on branch + BUMP_TYPE="Patch" + case "$BRANCH" in + feature/*|feat/*) BUMP_TYPE="Minor" ;; + esac + if [[ "$BRANCH" == "main" ]]; then echo "On main branch, checking PR source" SOURCE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ @@ -131,6 +146,9 @@ runs: fi echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "branch=$BRANCH" >> $GITHUB_OUTPUT + echo "previous_version=$LATEST" >> $GITHUB_OUTPUT + echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT # Add to job summary if enabled if [[ "${{ inputs.add-to-summary }}" == "true" ]]; then @@ -152,6 +170,9 @@ runs: run: | VERSION="${{ steps.version.outputs.version }}" IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}" + BRANCH="${{ steps.version.outputs.branch }}" + PREVIOUS="${{ steps.version.outputs.previous_version }}" + BUMP="${{ steps.version.outputs.bump_type }}" if [[ "$IS_PRERELEASE" == "true" ]]; then TYPE="Pre-release" @@ -160,7 +181,7 @@ runs: fi # Create comment body - printf "## 📦 Version: **%s**\n%s\n" "$VERSION" "$TYPE" > comment-body.txt + printf "## 📦 Version: **%s**\nType: %s\nBranch: %s\nBump: %s\nPrevious: %s\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" "$PREVIOUS" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) From e98817d2f6135b88dca8c402c09c2a86ea18e38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:17:18 +0100 Subject: [PATCH 12/19] Format PR comment as table --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 0a58951..cbfc62b 100644 --- a/action.yml +++ b/action.yml @@ -181,7 +181,7 @@ runs: fi # Create comment body - printf "## 📦 Version: **%s**\nType: %s\nBranch: %s\nBump: %s\nPrevious: %s\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" "$PREVIOUS" > comment-body.txt + printf "## 📦 Version: **%s**\n\n| Field | Value |\n|-------|-------|\n| Type | %s |\n| Branch | %s |\n| Bump | %s |\n| Previous | %s |\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" "$PREVIOUS" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) From aa7a79ab82e3a2e76e1874a69c8b3d4eef44dca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:19:14 +0100 Subject: [PATCH 13/19] Only show PR comment when pre-release is enabled --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index cbfc62b..4b3a74b 100644 --- a/action.yml +++ b/action.yml @@ -163,7 +163,7 @@ runs: fi - name: Comment on PR - if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request' + if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request' && inputs.enable-prerelease == 'true' shell: bash env: GH_TOKEN: ${{ inputs.github-token }} From 443767b567fc05b5c82e7061e3c12ebf57f66cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:20:19 +0100 Subject: [PATCH 14/19] Only show job summary when on main or pre-release enabled --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4b3a74b..d2f6c3c 100644 --- a/action.yml +++ b/action.yml @@ -151,7 +151,7 @@ runs: echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT # Add to job summary if enabled - if [[ "${{ inputs.add-to-summary }}" == "true" ]]; then + if [[ "${{ inputs.add-to-summary }}" == "true" ]] && ([[ "$BRANCH" == "main" ]] || [[ "${{ inputs.enable-prerelease }}" == "true" ]]); then echo "## 📦 Version: \`$VERSION\`" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY echo "- **Branch**: \`$BRANCH\`" >> $GITHUB_STEP_SUMMARY From 1b23dcbfdb14e95a50753a748146d568f8e678b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:21:19 +0100 Subject: [PATCH 15/19] Separate job summary into its own step Extract job summary logic into separate step for better organization and consistency with PR comment step. Use same table format for both. --- action.yml | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index d2f6c3c..7591987 100644 --- a/action.yml +++ b/action.yml @@ -150,18 +150,32 @@ runs: echo "previous_version=$LATEST" >> $GITHUB_OUTPUT echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT - # Add to job summary if enabled - if [[ "${{ inputs.add-to-summary }}" == "true" ]] && ([[ "$BRANCH" == "main" ]] || [[ "${{ inputs.enable-prerelease }}" == "true" ]]); then - echo "## 📦 Version: \`$VERSION\`" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "- **Branch**: \`$BRANCH\`" >> $GITHUB_STEP_SUMMARY - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - echo "- **Type**: Pre-release" >> $GITHUB_STEP_SUMMARY - else - echo "- **Type**: Release" >> $GITHUB_STEP_SUMMARY - fi + + - name: Add to Job Summary + if: inputs.add-to-summary == 'true' && (github.ref == 'refs/heads/main' || inputs.enable-prerelease == 'true') + shell: bash + run: | + VERSION="${{ steps.version.outputs.version }}" + IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}" + BRANCH="${{ steps.version.outputs.branch }}" + PREVIOUS="${{ steps.version.outputs.previous_version }}" + BUMP="${{ steps.version.outputs.bump_type }}" + + if [[ "$IS_PRERELEASE" == "true" ]]; then + TYPE="Pre-release" + else + TYPE="Release" fi + echo "## 📦 Version: **$VERSION**" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY + echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY + echo "| Type | $TYPE |" >> $GITHUB_STEP_SUMMARY + echo "| Branch | $BRANCH |" >> $GITHUB_STEP_SUMMARY + echo "| Bump | $BUMP |" >> $GITHUB_STEP_SUMMARY + echo "| Previous | $PREVIOUS |" >> $GITHUB_STEP_SUMMARY + - name: Comment on PR if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request' && inputs.enable-prerelease == 'true' shell: bash From 89a3c3178e2299212bfc5d41fb8f6e08d7f6cf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:21:57 +0100 Subject: [PATCH 16/19] Remove Previous field from PR comment and summary --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 7591987..7c5515a 100644 --- a/action.yml +++ b/action.yml @@ -174,7 +174,6 @@ runs: echo "| Type | $TYPE |" >> $GITHUB_STEP_SUMMARY echo "| Branch | $BRANCH |" >> $GITHUB_STEP_SUMMARY echo "| Bump | $BUMP |" >> $GITHUB_STEP_SUMMARY - echo "| Previous | $PREVIOUS |" >> $GITHUB_STEP_SUMMARY - name: Comment on PR if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request' && inputs.enable-prerelease == 'true' @@ -195,7 +194,7 @@ runs: fi # Create comment body - printf "## 📦 Version: **%s**\n\n| Field | Value |\n|-------|-------|\n| Type | %s |\n| Branch | %s |\n| Bump | %s |\n| Previous | %s |\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" "$PREVIOUS" > comment-body.txt + printf "## 📦 Version: **%s**\n\n| Field | Value |\n|-------|-------|\n| Type | %s |\n| Branch | %s |\n| Bump | %s |\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" > comment-body.txt # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) From 58ef509c72d3bbf32cafd74b47ea954d871eab41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:22:57 +0100 Subject: [PATCH 17/19] Update README with PR comment and job summary documentation - Document new outputs (branch, previous-version, bump-type) - Add section showing PR comment and job summary features - Clarify comment-on-pr requires enable-prerelease - Show table format example --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a1c3704..6c8e7bf 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ When you merge to main, it drops the suffix and creates the final version. | `enable-prerelease` | `false` | Enable pre-release tags on feature branches | | `github-token` | `${{ github.token }}` | Token for API access | | `branch-patterns` | `""` | Custom branch patterns (JSON format, optional) | -| `comment-on-pr` | `false` | Add version preview comment to PRs | +| `comment-on-pr` | `false` | Add version comment to PRs (requires `enable-prerelease: true`) | | `add-to-summary` | `false` | Add version to GitHub Actions job summary | ## Outputs @@ -106,6 +106,39 @@ When you merge to main, it drops the suffix and creates the final version. |--------|-------------| | `version` | The version tag that was created (e.g., `v1.2.3`) | | `is-prerelease` | `true` if it's a pre-release, `false` otherwise | +| `branch` | Branch name used for versioning | +| `previous-version` | Previous version tag | +| `bump-type` | Type of version bump (Minor or Patch) | + +## PR Comments & Job Summaries + +Enable helpful version information directly in your pull requests and workflow summaries: + +```yaml +- uses: TheKathan/semantic-versioning@v1 + with: + major-version: "1" + enable-prerelease: "true" + comment-on-pr: "true" # Adds comment to PRs + add-to-summary: "true" # Adds to workflow summary +``` + +Both features display the same information in a clean table format: + +``` +## 📦 Version: v1.2.0-alpha.1 + +| Field | Value | +|-------|-------| +| Type | Pre-release | +| Branch | feature/new-feature | +| Bump | Minor | +``` + +**Notes:** +- PR comments only appear when `enable-prerelease` is `true` (versions are created on feature branches) +- Job summaries appear on main branch merges or when `enable-prerelease` is `true` +- PR comments are updated in place (no duplicate comments) ## Creating Releases From aa5b17f22bf0034251b4e7531718a9144109f39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:25:03 +0100 Subject: [PATCH 18/19] Add check to skip if tag already exists Prevents 'tag already exists' error when workflow runs multiple times on same commit. --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yml b/action.yml index 7c5515a..156e069 100644 --- a/action.yml +++ b/action.yml @@ -214,6 +214,12 @@ runs: VERSION="${{ steps.version.outputs.version }}" IS_PRERELEASE="${{ steps.version.outputs.is_prerelease }}" + # Check if tag already exists + if git rev-parse "$VERSION" >/dev/null 2>&1; then + echo "Tag $VERSION already exists, skipping" + exit 0 + fi + git tag "$VERSION" git push origin "$VERSION" From 1cf26e6301c8342680d909f5df65406e9a403093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Faria?= Date: Fri, 13 Feb 2026 00:25:46 +0100 Subject: [PATCH 19/19] Remove redundant comments --- action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/action.yml b/action.yml index 156e069..a98d076 100644 --- a/action.yml +++ b/action.yml @@ -193,17 +193,13 @@ runs: TYPE="Release" fi - # Create comment body printf "## 📦 Version: **%s**\n\n| Field | Value |\n|-------|-------|\n| Type | %s |\n| Branch | %s |\n| Bump | %s |\n" "$VERSION" "$TYPE" "$BRANCH" "$BUMP" > comment-body.txt - # Check if bot comment already exists EXISTING_COMMENT=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[] | select(.author.login == "github-actions[bot]" and (.body | contains("📦 Version"))) | .id' | head -1) if [[ -n "$EXISTING_COMMENT" ]]; then - # Update existing comment gh api -X PATCH "/repos/${{ github.repository }}/issues/comments/$EXISTING_COMMENT" -F body=@comment-body.txt else - # Create new comment gh pr comment ${{ github.event.pull_request.number }} --body-file comment-body.txt fi