Create Release branch #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Release branch | |
on: | |
workflow_dispatch: | |
inputs: | |
version-bump: | |
required: false | |
type: choice | |
options: | |
- major | |
- minor | |
- patch | |
default: patch | |
description: 'Major, Minor, or Patch version bump' | |
jobs: | |
create_branch: | |
name: 'Create Release Branch' | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
actions: write | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
name: Checkout | |
with: | |
ref: main | |
fetch-depth: 0 | |
- name: Install Node.js | |
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 | |
- name: Install semver | |
run: npm install -g semver | |
- name: Get Latest Release Version | |
id: get-version | |
run: | | |
RELEASE_BRANCH=$(git branch -r | grep -Eo 'releases/[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n 1) | |
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV | |
- name: Set Branch Name | |
id: set_branch | |
run: | | |
if [ -z "${RELEASE_BRANCH}" ]; then | |
NEW_BRANCH_NAME="releases/0.0.1" | |
else | |
OLD_VERSION=$(echo "${RELEASE_BRANCH}" | sed 's/releases\///') | |
NEW_VERSION=$(semver --increment ${{ inputs.version-bump }} "${OLD_VERSION}") | |
echo "Bumping $OLD_VERSION to $NEW_VERSION" | |
NEW_BRANCH_NAME="releases/${NEW_VERSION}" | |
fi | |
echo "NEW_BRANCH_NAME=${NEW_BRANCH_NAME}" >> $GITHUB_ENV | |
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV | |
echo "OLD_VERSION=${OLD_VERSION}" >> $GITHUB_ENV | |
- name: Create Branch | |
run: | | |
git checkout -b $NEW_BRANCH_NAME | |
- name: Push Branch | |
run: | | |
git push origin $NEW_BRANCH_NAME | |
- name: Create Repository Release | |
run: | | |
gh release create v${{ env.NEW_VERSION }} \ | |
--title v${{ env.NEW_VERSION }} \ | |
--target ${{ env.NEW_BRANCH_NAME }} \ | |
--generate-notes \ | |
--notes-start-tag v${{ env.OLD_VERSION }} \ | |
--prerelease | |
- name: Create Release Variables | |
run: | | |
gh variable set CURRENT_UAT_VERSION \ | |
--body "${{ env.NEW_VERSION }}" | |
gh variable set CURRENT_PROD_VERSION \ | |
--body "${{ env.OLD_VERSION }}" | |
env: | |
GH_TOKEN: ${{ secrets.GH_PAT_VARIABLES }} | |
- name: Trigger Functions Infra UAT Release | |
run: | | |
gh workflow run release_functions_infra.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger Mongo Infra UAT Release | |
run: | | |
gh workflow run release_mongo_infra.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger PNPG Functions Infra UAT Release | |
run: | | |
gh workflow run release_functions_pnpg_infra.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger PNPG Mongo Infra UAT Release | |
run: | | |
gh workflow run release_mongo_pnpg_infra.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger Functions UAT Release | |
run: | | |
gh workflow run release_functions.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger Onboarding ms UAT Release | |
run: | | |
gh workflow run release_ms.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger PNPG Functions UAT Release | |
run: | | |
gh workflow run release_pnpg_functions.yml \ | |
--ref $NEW_BRANCH_NAME | |
- name: Trigger PNPG Onboarding ms UAT Release | |
run: | | |
gh workflow run release_pnpg_ms.yml \ | |
--ref $NEW_BRANCH_NAME |