-
Notifications
You must be signed in to change notification settings - Fork 406
66 lines (65 loc) · 3.14 KB
/
cut_major_branch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
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:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_BRANCH: ${{ github.event.inputs.release-branch }}
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"
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:set-property -f project/standard/templates/web/pom.xml -Dproperty=mapstore-services.version -DnewVersion=$NEXT_JAVA_VERSION -DgenerateBackupPoms=false -DautoVersionSubmodules=true -Pprinting
# 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}