Cut Release Branch #4
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: Cut Release Branch | |
on: | |
workflow_dispatch: | |
inputs: | |
current-version: | |
description: Current version (e.g. 2.1) | |
required: true | |
next-version: | |
description: Next version (e.g. 2.2). | |
required: true | |
main-branch: | |
description: main branch | |
default: master | |
pr-options: | |
description: Options for Pull request | |
default: --squash --auto --delete-branch | |
jobs: | |
cut-release: | |
name: Create release branch and PRs into main main branch | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: master | |
- name: Create release branch and generate PR body | |
id: create-branch | |
env: | |
CURR: ${{ github.event.inputs.current-version }} | |
NEXT: ${{ github.event.inputs.next-version }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MAIN_BRANCH: ${{ github.event.inputs.main-branch }} | |
PR_OPTIONS: ${{ github.event.inputs.pr-options }} | |
RUN_ID: ${{ github.run_id }} | |
run: | | |
# script will go here | |
echo "Initializing git" | |
# Optional | |
git config user.name github-actions | |
git config user.email [email protected] | |
BRANCH_NAME="${CURR}.x" | |
echo "creating branch is $BRANCH_NAME" | |
git checkout -b "$BRANCH_NAME" | |
git push --set-upstream origin "$BRANCH_NAME" | |
echo "branch created" | |
echo "creating bump changes" | |
git checkout "$MAIN_BRANCH" | |
mvn -q -B release:update-versions -DautoVersionSubmodules=true -DdevelopmentVersion=${NEXT}-SNAPSHOT # sets the internal verison | |
mvn -q -B versions:set-property -B -Dproperty=geostore-version -DnewVersion=${NEXT}-SNAPSHOT # sets geostore-version property | |
pr_branch_name="bump-${NEXT}-${RUN_ID}" | |
echo "Creating a temp PR on branch: ${pr_branch_name}" | |
git checkout -b "${pr_branch_name}" | |
find . -name 'pom.xml' | xargs git add | |
git commit -m "Bump version to ${NEXT}" | |
git push origin "${pr_branch_name}" | |
pr_url=$(gh pr create -B "${MAIN_BRANCH}" -H "${pr_branch_name}" --title "[github-action] Bump version to ${NEXT}" --body "This automatic pull request bumps version of ${MAIN_BRANCH} branch to ${NEXT}") | |
sleep 10 | |
gh pr merge "$pr_url" ${PR_OPTIONS} | |