Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New workflow for creating release branches #7444

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
114 changes: 114 additions & 0 deletions .github/workflows/create-release-branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# This workflow should only be ran if we intend on creating a new release branch off the current release branch.
# This should happen if we are going to begin developing a new minor for the previous major release.

name: Create Release Branch

on:
workflow_dispatch:
inputs:
releaseBranch:
description: 'The name of the release branch to create'
required: true

jobs:
create-release-branch:
name: Create Release Branch
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.IMJS_ADMIN_GH_TOKEN }}
ref: ${{ github.ref }} # checkouts the branch that triggered the workflow
fetch-depth: 0

- name: Set Git Config
run: |
git config --local user.email [email protected]
git config --local user.name imodeljs-admin

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Create Release Branch
run: |
git checkout -b ${{ inputs.releaseBranch }}
shell: bash {0}

- name: Update 'gather-docs.yaml'
run: |
docsYamlPath="common/config/azure-pipelines/templates/gather-docs.yaml"
releaseBranch=$(getBranchName.releaseBranchName)

# delimiter
IFS="."
read -ra splitArray <<< "$releaseBranch"

currentMinorVersion=${splitArray[1]}
previousMinorVersion=$((currentMinorVersion - 1))

# check if this release is major or minor version release
# if minor version bump, use last recent minor version
# if major version bump, `gather-docs.yaml` needs to be edited
# manually to be the most recent previous major release
# e.g. if this release is `release/5.0.x`, value in `gather-docs.yaml`
# should be `release/4.<whatever_last_minor_release_version_was>.x`
if [ $((previousMinorVersion)) -lt 0 ]
then
echo "This is is a major release. Edit \"gather-docs.yaml\" manually."
else
previousReleaseBranch="${releaseBranch/"$currentMinorVersion.x"/"$previousMinorVersion.x"}"
escapedReleaseBranchName="${previousReleaseBranch//\//\\\/}"
search="branchName: refs\/heads\/master"
replace="branchName: refs\/heads\/"$escapedReleaseBranchName""
echo "$search"
echo "$replace"
# The replacement here is global instead of first match since the logic is that
# if something is being pulled from master but needs to be changed to being pulled from release branch instead,
# it is likely that any other thing that was being pulled from master probably also needs to be pulled from release branch instead
sed -i "s/$search/$replace/g" "$docsYamlPath"
git add "$docsYamlPath"
git commit -m "Update 'gather-docs.yaml' to previous release branch name"
fi
shell: bash {0}

- name: Update to new dev version
run: |
node common/scripts/install-run-rush version --override-bump minor --version-policy prerelease-monorepo-lockStep --bump
shell: bash {0}

- name: Git Add Changelog deletion
run: |
git add common
shell: bash {0}

- name: Reset all other changes
run: |
# Resets all changes, other than the deletion of the changelogs.
git checkout -- .

# Cleans up all untracked files. This could happen if there are new packages that do not have change logs yet.
git clean -f -d

git status
shell: bash {0}

- name: Rush version to new pre-release version
run: |
node common/scripts/install-run-rush version --override-bump preminor --version-policy prerelease-monorepo-lockStep --bump --override-prerelease-id dev
shell: bash {0}

- name: Clear current NextVersion.md
run: |
echo "# NextVersion" > common/config/rush/NextVersion.md
shell: bash {0}

- name: git add, commit, and push changes
run: |
git add .
newVersion=$(node -pe "require('./common/config/rush/version-policies.json')[0].version.trim()") && echo $newVersion
# FIXME temp commit message while testing. Otherwise I might trigger a new build
git commit -m "$newVersion" --author="imodeljs-admin <[email protected]>"
git push origin ${{ inputs.releaseBranch }}
shell: bash {0}
Loading