-
Notifications
You must be signed in to change notification settings - Fork 8
56 lines (50 loc) · 2.22 KB
/
master-push.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
---
name: 'Bump Release'
on:
push:
branches:
- 'master'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
version-bump:
name: 'Version Bump and Start Release'
runs-on: ubuntu-latest
steps:
- name: 'Check out code'
uses: actions/checkout@v4
with:
token: ${{ secrets.JENKINS_GITHUB_PAT }}
# fetch-depth 0 means deep clone the repo
fetch-depth: 0
- name: 'Configure GitHub user'
run: |
git config user.name rv-jenkins
git config user.email [email protected]
- name: 'Update version'
run: |
# Check out the release branch and create it if it doesn't exist
git checkout -B release origin/release
# Get the common ancestor commit between master and release branches
old_master="$(git merge-base origin/master origin/release)"
# Get the latest commit hash on the master branch
new_master="$(git rev-parse origin/master)"
# Check if there are changes in the package/version file between the common ancestor and the latest master commit
if git diff --exit-code ${old_master} ${new_master} -- package/version; then
# If there are no changes, bump the version based on the current version in master
git merge --no-edit origin/master
./package/version.sh bump
else
# If there are changes, merge master into release with 'theirs' strategy to resolve conflicts
git merge --no-edit --strategy-option=theirs origin/master
fi
# Substitute the version in the package/version file
./package/version.sh sub
# Add changes to the staging area and commit them if there are any changes
if git add --update && git commit --no-edit --allow-empty --message "Set Version: $(cat package/version)"; then
# Push the changes to the release branch -- Trigger the Release Process and Testing
git push origin release
git tag "release-$(cat package/version)" origin/master
git push origin "release-$(cat package/version)"
fi