Skip to content
Merged
Changes from 2 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
153 changes: 153 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,156 @@ jobs:
${{ inputs.previous-version-tag }} \
${{ inputs.semver-version }} \
${{ inputs.mobile-build-version }}

bump-main-version:
name: Create Version Bump PR for Main
runs-on: ubuntu-latest
needs: create-release-pr
permissions:
contents: write
pull-requests: write
steps:
# Step 1: Checkout main branch of invoking repository
- name: Checkout main branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ secrets.github-token }}

# Step 2: Checkout github-tools repository
- name: Checkout github-tools repository
uses: actions/checkout@v4
with:
repository: MetaMask/github-tools
ref: ${{ inputs.github-tools-version }}
path: github-tools

# Step 3: Setup environment from github-tools
- name: Checkout and setup environment
uses: ./github-tools/.github/actions/checkout-and-setup
with:
is-high-risk-environment: true

# Step 4: Calculate next version
- name: Calculate next version
id: calc-version
working-directory: github-tools
run: |
# Use Node.js semver to increment the minor version
CURRENT_VERSION="${{ inputs.semver-version }}"
NEXT_VERSION=$(node -e "
const semver = require('semver');
const current = \"$CURRENT_VERSION\";
const next = semver.inc(current, 'minor');
console.log(next);
")
echo "next-version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
echo "Next version will be: $NEXT_VERSION"

# Step 5: Create version bump branch
- name: Create version bump branch
run: |
BRANCH_NAME="bump-main-version-${{ steps.calc-version.outputs.next-version }}"

# Check if branch already exists locally or remotely
if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME" || git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists, checking it out"
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
git fetch origin "$BRANCH_NAME"
git checkout "$BRANCH_NAME"
else
git checkout "$BRANCH_NAME"
fi
else
echo "Creating new branch $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
fi

echo "branch-name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
id: create-branch

# Step 6: Update version using set-semvar-version.sh
- name: Update version files
run: |
# Make script executable
chmod +x ./github-tools/.github/scripts/set-semvar-version.sh

# Run the version update script
./github-tools/.github/scripts/set-semvar-version.sh \
${{ steps.calc-version.outputs.next-version }} \
${{ inputs.platform }}

# Step 7: Commit changes
- name: Commit version bump
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Bump version to ${{ steps.calc-version.outputs.next-version }} after release ${{ inputs.semver-version }}

This automated version bump ensures that:
- Main branch version is ahead of the release branch
- Future nightly builds will have correct versioning

Release version: ${{ inputs.semver-version }}
New main version: ${{ steps.calc-version.outputs.next-version }}
Platform: ${{ inputs.platform }}"

# Step 8: Push branch
- name: Push version bump branch
run: |
if ! git push --set-upstream origin "${{ steps.create-branch.outputs.branch-name }}"; then
echo "No changes to push to ${{ steps.create-branch.outputs.branch-name }}"
# Check if branch exists remotely
if git ls-remote --heads origin "${{ steps.create-branch.outputs.branch-name }}" | grep -q "${{ steps.create-branch.outputs.branch-name }}"; then
echo "Branch ${{ steps.create-branch.outputs.branch-name }} already exists remotely"
else
echo "Error: Failed to push and branch doesn't exist remotely"
exit 1
fi
fi

# Step 9: Create pull request
- name: Create pull request
env:
GH_TOKEN: ${{ secrets.github-token }}
run: |
# Check if PR already exists
if gh pr list --head "${{ steps.create-branch.outputs.branch-name }}" --json number --jq 'length' | grep -q "1"; then
echo "PR for branch ${{ steps.create-branch.outputs.branch-name }} already exists"
else
gh pr create \
--title "🔄 Bump main version to ${{ steps.calc-version.outputs.next-version }}" \
--body "## Version Bump After Release

This PR bumps the main branch version from ${{ inputs.semver-version }} to ${{ steps.calc-version.outputs.next-version }} after cutting the release branch.

### Why this is needed:
- **Nightly builds**: Each nightly build needs to be one minor version ahead of the current release candidate
- **Version conflicts**: Prevents conflicts between nightlies and release candidates
- **Platform alignment**: Maintains version alignment between MetaMask mobile and extension
- **Update systems**: Ensures nightlies are accepted by app stores and browser update systems

### What changed:
- Version bumped from \`${{ inputs.semver-version }}\` to \`${{ steps.calc-version.outputs.next-version }}\`
- Platform: \`${{ inputs.platform }}\`
- Files updated by \`set-semvar-version.sh\` script

### Next steps:
This PR should be **manually reviewed and merged by the release manager** to maintain proper version flow.

### Related:
- Release version: ${{ inputs.semver-version }}
- Base branch for release: ${{ inputs.base-branch }}
- Platform: ${{ inputs.platform }}

---
*This PR was automatically created by the \`create-release-pr\` workflow.*" \
--base main \
--head "${{ steps.create-branch.outputs.branch-name }}" \
--label "release-management" \
--label "version-bump" \
--assignee @me
echo "Version bump PR created successfully"
fi
Loading