From 501dcc982543c9a74ccfd6f2d6a8fb960babd3f9 Mon Sep 17 00:00:00 2001 From: RensDofferhoff <20978635+RensDofferhoff@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:29:28 +0100 Subject: [PATCH 1/6] Create auto-bump-version.yml --- .github/workflows/auto-bump-version.yml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/auto-bump-version.yml diff --git a/.github/workflows/auto-bump-version.yml b/.github/workflows/auto-bump-version.yml new file mode 100644 index 0000000..602c47e --- /dev/null +++ b/.github/workflows/auto-bump-version.yml @@ -0,0 +1,35 @@ +name: Bump Version in DESCRIPTION + +on: + push: + branches: + - test2 + +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Bump Version Number + run: | + # 1. Extract current version + CURRENT_VERSION=$(grep -i "^Version:" DESCRIPTION | awk '{print $2}') + + # 2. Validate format (e.g., 0.17.0 or 0.17.0.9000) + if [[ ! "$CURRENT_VERSION" =~ ^[0-9]+(\.[0-9]+)+$ ]]; then + echo "❌ Error: Invalid version format in DESCRIPTION: '$CURRENT_VERSION'" + exit 1 + fi + + # 3. Split, increment the last digit, and stitch back together + IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" + LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) + VERSION_PARTS[$LAST_INDEX]=$((VERSION_PARTS[$LAST_INDEX] + 1)) + NEW_VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}") + + # 4. Replace the old version in the DESCRIPTION file + sed -i "s/^Version: [0-9.]\+/Version: $NEW_VERSION/i" DESCRIPTION + + echo "✅ Successfully bumped version from $CURRENT_VERSION to $NEW_VERSION" From 0ce6ffe0f8992235d9bd27c4a0f6d32ae59f13cc Mon Sep 17 00:00:00 2001 From: RensDofferhoff <20978635+RensDofferhoff@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:31:25 +0100 Subject: [PATCH 2/6] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2f52392..e0f2c9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: jaspModuleTemplate -Type: Package +Type: Package Title: A module for JASP Version: 0.1.0 Date: 2020-10-15 From a88bfb041e4c399b0f2d6cf599d22408ade5b303 Mon Sep 17 00:00:00 2001 From: RensDofferhoff <20978635+RensDofferhoff@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:38:18 +0100 Subject: [PATCH 3/6] Update auto-bump-version.yml --- .github/workflows/auto-bump-version.yml | 69 ++++++++++++++++--------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/.github/workflows/auto-bump-version.yml b/.github/workflows/auto-bump-version.yml index 602c47e..0ff27b3 100644 --- a/.github/workflows/auto-bump-version.yml +++ b/.github/workflows/auto-bump-version.yml @@ -1,35 +1,58 @@ -name: Bump Version in DESCRIPTION +name: Auto-bump Version in PR +# Triggers when a PR is opened, or when new commits are pushed to the PR branch on: - push: - branches: - - test2 + pull_request: + types: [opened, synchronize] jobs: - bump-version: + bump-version-pr: runs-on: ubuntu-latest + permissions: + contents: write # Required to push the commit back to the PR branch steps: - - name: Checkout repository + - name: Checkout PR branch uses: actions/checkout@v4 + with: + # Crucial: Check out the actual PR branch, not the merge commit, + # so we can push changes back to it. + ref: ${{ github.head_ref }} + fetch-depth: 0 - - name: Bump Version Number + - name: Check and Bump Version run: | - # 1. Extract current version - CURRENT_VERSION=$(grep -i "^Version:" DESCRIPTION | awk '{print $2}') + # 1. Get the current version on the target branch (e.g., main) + BASE_VERSION=$(git show origin/${{ github.base_ref }}:DESCRIPTION 2>/dev/null | grep -i "^Version:" | awk '{print $2}') - # 2. Validate format (e.g., 0.17.0 or 0.17.0.9000) - if [[ ! "$CURRENT_VERSION" =~ ^[0-9]+(\.[0-9]+)+$ ]]; then - echo "❌ Error: Invalid version format in DESCRIPTION: '$CURRENT_VERSION'" - exit 1 - fi - - # 3. Split, increment the last digit, and stitch back together - IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" - LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) - VERSION_PARTS[$LAST_INDEX]=$((VERSION_PARTS[$LAST_INDEX] + 1)) - NEW_VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}") + # 2. Get the current version in the PR branch + PR_VERSION=$(grep -i "^Version:" DESCRIPTION | awk '{print $2}') - # 4. Replace the old version in the DESCRIPTION file - sed -i "s/^Version: [0-9.]\+/Version: $NEW_VERSION/i" DESCRIPTION + echo "Base branch version: $BASE_VERSION" + echo "PR branch version: $PR_VERSION" - echo "✅ Successfully bumped version from $CURRENT_VERSION to $NEW_VERSION" + # 3. If the PR version is exactly the same as the Base version, bump it + if [ "$PR_VERSION" == "$BASE_VERSION" ]; then + echo "Version has not been bumped yet. Bumping now..." + + # Split, increment, and stitch back together + IFS='.' read -r -a VERSION_PARTS <<< "$BASE_VERSION" + LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) + VERSION_PARTS[$LAST_INDEX]=$((VERSION_PARTS[$LAST_INDEX] + 1)) + NEW_VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}") + + # Replace in file + sed -i "s/^Version: [0-9.]\+/Version: $NEW_VERSION/i" DESCRIPTION + + # Commit and push back to the PR + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add DESCRIPTION + git commit -m "chore: auto-bump version to $NEW_VERSION" + git push + + echo "✅ Successfully pushed bumped version to PR." + else + # If the versions differ, the user either already bumped it manually, + # or it's a major/minor version bump we shouldn't overwrite. + echo "✅ PR version ($PR_VERSION) differs from base ($BASE_VERSION). No action needed." + fi From 338fae6918897f9a8ac4d2a70b7e80e4bbd6382c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 13:38:40 +0000 Subject: [PATCH 4/6] chore: auto-bump version to 0.1.1 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e0f2c9f..02ecb80 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: jaspModuleTemplate Type: Package Title: A module for JASP -Version: 0.1.0 +Version: 0.1.1 Date: 2020-10-15 Author: JASP Team Website: jasp-stats.org From 7eef023bd9ce0835f53f9ac1cf8a323316321369 Mon Sep 17 00:00:00 2001 From: RensDofferhoff <20978635+RensDofferhoff@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:49:13 +0100 Subject: [PATCH 5/6] Update auto-bump-version.yml --- .github/workflows/auto-bump-version.yml | 98 ++++++++++++++----------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/.github/workflows/auto-bump-version.yml b/.github/workflows/auto-bump-version.yml index 0ff27b3..16c1277 100644 --- a/.github/workflows/auto-bump-version.yml +++ b/.github/workflows/auto-bump-version.yml @@ -1,58 +1,70 @@ -name: Auto-bump Version in PR +name: Auto-bump Version on Merge -# Triggers when a PR is opened, or when new commits are pushed to the PR branch +# This triggers ONLY when code is pushed directly to master +# (which includes when a Pull Request is merged into it). on: - pull_request: - types: [opened, synchronize] + push: + branches: + - master # If your default branch is 'main', change this to 'main' jobs: - bump-version-pr: + bump-version: runs-on: ubuntu-latest permissions: - contents: write # Required to push the commit back to the PR branch + contents: write # Required so the bot can push the new commit to your repo steps: - - name: Checkout PR branch + - name: Checkout repository uses: actions/checkout@v4 with: - # Crucial: Check out the actual PR branch, not the merge commit, - # so we can push changes back to it. - ref: ${{ github.head_ref }} fetch-depth: 0 - - name: Check and Bump Version + - name: Calculate and Update Version run: | - # 1. Get the current version on the target branch (e.g., main) - BASE_VERSION=$(git show origin/${{ github.base_ref }}:DESCRIPTION 2>/dev/null | grep -i "^Version:" | awk '{print $2}') - - # 2. Get the current version in the PR branch - PR_VERSION=$(grep -i "^Version:" DESCRIPTION | awk '{print $2}') - - echo "Base branch version: $BASE_VERSION" - echo "PR branch version: $PR_VERSION" - - # 3. If the PR version is exactly the same as the Base version, bump it - if [ "$PR_VERSION" == "$BASE_VERSION" ]; then - echo "Version has not been bumped yet. Bumping now..." - - # Split, increment, and stitch back together - IFS='.' read -r -a VERSION_PARTS <<< "$BASE_VERSION" - LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) - VERSION_PARTS[$LAST_INDEX]=$((VERSION_PARTS[$LAST_INDEX] + 1)) - NEW_VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}") - - # Replace in file - sed -i "s/^Version: [0-9.]\+/Version: $NEW_VERSION/i" DESCRIPTION - - # Commit and push back to the PR - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add DESCRIPTION - git commit -m "chore: auto-bump version to $NEW_VERSION" + # 1. Extract current version from the DESCRIPTION file + CURRENT_VERSION=$(grep -i "^Version:" DESCRIPTION | awk '{print $2}') + + # SECURITY CHECK: Ensure it strictly matches a version number format (e.g., 0.17.0 or 0.17.0.9000) + if [[ ! "$CURRENT_VERSION" =~ ^[0-9]+(\.[0-9]+)+$ ]]; then + echo "❌ Error: Invalid version format in DESCRIPTION: '$CURRENT_VERSION'" + exit 1 + fi + + # 2. Split the version string by periods into an array + IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" + + # 3. Increment the very last number by 1 + LAST_INDEX=$((${#VERSION_PARTS[@]} - 1)) + VERSION_PARTS[$LAST_INDEX]=$((VERSION_PARTS[$LAST_INDEX] + 1)) + + # 4. Stitch the version string back together + NEW_VERSION=$(IFS='.'; echo "${VERSION_PARTS[*]}") + + echo "Bumping version from $CURRENT_VERSION to $NEW_VERSION" + + # 5. Safely replace the old version with the new version in the file + sed -i "s/^Version: [0-9.]\+/Version: $NEW_VERSION/i" DESCRIPTION + + # 6. Securely pass the new version to the next step for the commit message + cat <> "$GITHUB_ENV" + NEW_VERSION=$NEW_VERSION + EOF + + - name: Commit and Push + run: | + # Configure Git to act as the official GitHub Actions bot + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + # Stage the changed file + git add DESCRIPTION + + # Check if there are actually changes to commit (prevents errors if version didn't change) + if ! git diff-index --quiet HEAD; then + # The [skip ci] flag is CRITICAL. It tells GitHub NOT to trigger + # another workflow run from this automated commit, preventing infinite loops. + git commit -m "chore: auto-bump version to ${{ env.NEW_VERSION }} [skip ci]" git push - - echo "✅ Successfully pushed bumped version to PR." + echo "✅ Successfully bumped version and pushed to master." else - # If the versions differ, the user either already bumped it manually, - # or it's a major/minor version bump we shouldn't overwrite. - echo "✅ PR version ($PR_VERSION) differs from base ($BASE_VERSION). No action needed." + echo "No changes needed." fi From a56898f97d5dfe8f2c4be96c1d376f191cd696e0 Mon Sep 17 00:00:00 2001 From: RensDofferhoff <20978635+RensDofferhoff@users.noreply.github.com> Date: Mon, 2 Mar 2026 14:50:27 +0100 Subject: [PATCH 6/6] Update DESCRIPTION --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 02ecb80..e0f2c9f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: jaspModuleTemplate Type: Package Title: A module for JASP -Version: 0.1.1 +Version: 0.1.0 Date: 2020-10-15 Author: JASP Team Website: jasp-stats.org