Repository navigation
67 lines (56 loc) · 2.16 KB
/
Copy pathupdate_version.yaml
File metadata and controls
67 lines (56 loc) · 2.16 KB
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
67
name: update OPG version
on:
workflow_dispatch:
pull_request:
types: [closed]
branches: [master]
jobs:
bump-version:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Bump version
run: |
# Read the version from VERSION file
current_version=$(cat VERSION)
number_version=$(echo "$current_version" | grep -oP '\d+\.\d+\.\d+')
# Check if "release-as-is" suffix is present (skip version bump)
if echo "$current_version" | grep -q "release-as-is"; then
new_version="$number_version"
else
# Increment the last part of the version
parts=(${number_version//./ })
parts[2]=$((parts[2] + 1))
new_version="${parts[0]}.${parts[1]}.${parts[2]}"
fi
# Replace the version in the VERSION file
DATE=`date +%y%m%d|sed 's/\ //g'`
BRANCH=`git rev-parse --abbrev-ref HEAD` ## get active GIT branch
BUILD="v"$new_version"+"$BRANCH""$DATE
# Write the VERSION file
echo $BUILD > VERSION
# Set as environment variable for next steps
echo "NEW_VERSION=$BUILD" >> $GITHUB_ENV
- name: Commit and push version changes
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add VERSION
git commit -m "Update version to $NEW_VERSION"
git pull --ff-only
git push origin
- name: Create and push tag
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git tag $NEW_VERSION
git push origin $NEW_VERSION
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$NEW_VERSION" \
--title "Release $NEW_VERSION"
# --notes-file FEATURES.md