Skip to content

Cut Release Branch

Cut Release Branch #3

name: Cut Release Branch
on:
workflow_dispatch:
inputs:
release-branch:
description: MapStore branch name to use (YYYY.MM.xx). E.g. 2024.01.xx
required: true
mapfish-version:
description: Mapfish print version to use (e.g. 2.3-SNAPSHOT)
required: true
default: '2.3-SNAPSHOT'
geostore-version:
description: GeoStore version to use (e.g. 2.0.0).
required: true
default: '2.0.0'
http-proxy-version:
description: Http proxy version to use (e.g. 2.4).
required: true
default: '1.4.0'
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@v3
with:
ref: ${{ github.event.inputs.main-branch }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release branch and generate PR body
id: create-branch
env:
MAPFISH_GROUP: org.mapfish.print
MAPFISH_VERSION: ${{ github.event.inputs.mapfish-version }}
GEOSTORE_GROUP: it.geosolutions.geostore
GEOSTORE_VERSION: ${{ github.event.inputs.geostore-version }}
HTTP_PROXY_GROUP: proxy
HTTP_PROXY_VERSION: ${{ github.event.inputs.http-proxy-version }}
RELEASE_BRANCH: ${{ github.event.inputs.release-branch }}
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="${RELEASE_BRANCH}"
echo "creating branch is $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
# Find all pom.xml files and update-dependencies on them
echo "Updating versions on release branch"
# Find all pom.xml files and update-dependencies on them
echo "Updating versions on release branch"
POM_FILES=$(git ls-files . | grep 'pom\.xml$' | grep -v 'project/standard/templates/backend/pom\.xml$'| grep -v 'project/standard/templates/pom\.xml$');# note: exclues one file not involved that is not valid pom.xml, because it is a template
for POM_FILE in $POM_FILES; do
mvn versions:use-dep-version -f $POM_FILE -Dincludes=$MAPFISH_GROUP -DdepVersion=$MAPFISH_VERSION -DforceVersion=true -DgenerateBackupPoms=false -DautoVersionSubmodules=true -Pprinting
mvn versions:use-dep-version -f $POM_FILE -Dincludes=$GEOSTORE_GROUP -DdepVersion=$GEOSTORE_VERSION -DforceVersion=true -DgenerateBackupPoms=false -DautoVersionSubmodules=true -Pprinting
mvn versions:use-dep-version -f $POM_FILE -Dincludes=$HTTP_PROXY_GROUP -DdepVersion=$HTTP_PROXY_VERSION -DforceVersion=true -DgenerateBackupPoms=false -DautoVersionSubmodules=true -Pprinting
done
echo $POM_FILES | xargs git add
if ! git diff-index --quiet HEAD; then
git commit -m "Set versions of main dependencies to a stable version"
else
echo "::notice::No version changes in dependencies to commit. Please make sure to make this version fixed later"
fi
git push --set-upstream origin "$BRANCH_NAME"
echo "branch created"
echo "creating bump changes"
git checkout "$MAIN_BRANCH"
OLD_JAVA_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Incrementing java packages versions"
mvn -B release:update-versions -DautoVersionSubmodules=true -Pprinting,binary,printingbundle
NEXT_JAVA_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Java packages versions updated from $OLD_JAVA_VERSION to $NEXT_JAVA_VERSION"
### increase dependency of project to new version
echo "Updating project dependency to new version"
mvn versions:use-dep-version -f project/standard/templates/web/pom.xml -Dincludes=it.geosolutions.mapstore -DdepVersion=$NEXT_JAVA_VERSION -DforceVersion=true -DgenerateBackupPoms=false
# Increase release minor version
echo "Updating project version to new version in package.json"
npm version minor --git-tag-version=false
pr_branch_name="bump-${release-branch}-${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 add package.json
git commit -m "Bump versions on master for release-branch"
git push origin "${pr_branch_name}"
pr_url=$(gh pr create -B "${MAIN_BRANCH}" -H "${pr_branch_name}" --title "[github-action] ${MAIN_BRANCH} - Bump version for next release" --body "This automatic pull request bumps version of ${MAIN_BRANCH} branch for java packages and for package.json after creating the ${RELEASE_BRANCH}")
sleep 10
#gh pr merge "$pr_url" ${PR_OPTIONS}