Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/bump-minor-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Bump Minor Version

on:
workflow_dispatch:

jobs:
create_minor_release_pr:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- name: 1. Checkout main branch
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to get all tags for versioning
token: ${{ secrets.GITHUB_TOKEN }}

- name: 2. Get and Increment Version
id: bump
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# NOTE: This workflow ignores conventional commit messages and always bumps the minor version.
default_bump: minor # Will go from v1.7.X -> v1.8.0
dry_run: true # Don't create tag yet, just calculate the new version

- name: 3. Set Variables for New Release
id: vars
run: |
# Use the 'new_tag' output, e.g., "v1.8.0"
BUMPED_VERSION="${{ steps.bump.outputs.new_tag }}"

# Extract major and minor version numbers
# Handles formats: v1.8.0, v1.8-dev, v1.8-rc1, etc.
MAJOR=$(echo "$BUMPED_VERSION" | sed -E 's/^v([0-9]+)\.([0-9]+).*/\1/')
MINOR=$(echo "$BUMPED_VERSION" | sed -E 's/^v([0-9]+)\.([0-9]+).*/\2/')

# Validate that we successfully extracted major and minor versions
if [[ -z "$MAJOR" ]] || [[ -z "$MINOR" ]]; then
echo "::error::Failed to extract major/minor version from: $BUMPED_VERSION"
exit 1
fi

# Validate that major and minor are numeric
if ! [[ "$MAJOR" =~ ^[0-9]+$ ]] || ! [[ "$MINOR" =~ ^[0-9]+$ ]]; then
echo "::error::Invalid version format. MAJOR=$MAJOR, MINOR=$MINOR (expected numeric values)"
exit 1
fi

# Create RC version format: v1.8-rc
NEW_V_VERSION="v${MAJOR}.${MINOR}-rc"

# Create branch names
RELEASE_BRANCH="main-v${MAJOR}.${MINOR}"
WORK_BRANCH="gh-actions/bump-version-to-v${MAJOR}.${MINOR}"

echo "NEW_V_VERSION=${NEW_V_VERSION}" >> $GITHUB_OUTPUT
echo "MAJOR=${MAJOR}" >> $GITHUB_OUTPUT
echo "MINOR=${MINOR}" >> $GITHUB_OUTPUT
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_OUTPUT
echo "WORK_BRANCH=${WORK_BRANCH}" >> $GITHUB_OUTPUT

echo "::notice::Extracted versions - MAJOR: ${MAJOR}, MINOR: ${MINOR}"
echo "::notice::Creating release branch: ${RELEASE_BRANCH}"
echo "::notice::Creating work branch: ${WORK_BRANCH}"
echo "::notice::New version: ${NEW_V_VERSION}"

- name: 4. Create Release Branch
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did we get this one from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default action bot's email, see https://github.com/orgs/community/discussions/119597


RELEASE_BRANCH="${{ steps.vars.outputs.RELEASE_BRANCH }}"

# Create the release branch from main (use -B to reset if exists)
git checkout -B "$RELEASE_BRANCH"
git push origin "$RELEASE_BRANCH"

# The release branch is already checked out; no need to checkout again.


echo "::notice::Created and pushed release branch: $RELEASE_BRANCH"

- name: 5. Modify App Version in Code
run: |
VERSION_FILE="app/version/version.go"
NEW_VERSION="${{ steps.vars.outputs.NEW_V_VERSION }}"

echo "::notice file=$VERSION_FILE,line=18::Bumping version in $VERSION_FILE to $NEW_VERSION"

# Use sed to find the line and replace only the version string
sed -i -E "s/^(var version = ).*/\1\"$NEW_VERSION\"/" "$VERSION_FILE"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will essentially update v1.8-dev to v1.8.0.
What we'd like so make it v1.8-rc, no?
The v1.8.0 we should make with a git tag and change the version in this file to v1.8.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overlooked the -rc part..

Update version/version.go line 18 from var version = "<FULL_VERSION>-dev" to var version = "<FULL_VERSION>-rc". Commit and push the change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


# Verify the change
echo "--- Verifying change in $VERSION_FILE"
grep "var version" "$VERSION_FILE"
echo "---"

- name: 6. Create Pull Request to Release Branch
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v7.0.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "app: bump minor version to ${{ steps.vars.outputs.NEW_V_VERSION }}"
committer: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
branch: ${{ steps.vars.outputs.WORK_BRANCH }}
base: ${{ steps.vars.outputs.RELEASE_BRANCH }}
delete-branch: true
title: "app: bump minor version to ${{ steps.vars.outputs.NEW_V_VERSION }}"
body: |
This pull request was automatically generated by the 'Bump Minor Version' GitHub Action.

- **Previous Release:** ${{ steps.bump.outputs.previous_tag }}
- **New Version:** ${{ steps.vars.outputs.NEW_V_VERSION }}
- **Target Branch:** `${{ steps.vars.outputs.RELEASE_BRANCH }}`

## Changes
- Updated version in `app/version/version.go` from `${{ steps.bump.outputs.previous_tag }}` to `${{ steps.vars.outputs.NEW_V_VERSION }}`

## Next Steps
After this PR is merged, the `${{ steps.vars.outputs.RELEASE_BRANCH }}` branch will have the updated version and can be used for further release processes.

category: misc
ticket: none
Loading