-
Notifications
You must be signed in to change notification settings - Fork 33
49 lines (40 loc) · 1.36 KB
/
release.yml
File metadata and controls
49 lines (40 loc) · 1.36 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
name: Release Automation
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
create-release-branches:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Git
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Create release branches
run: |
# Get the pushed tag
TAG=${GITHUB_REF#refs/tags/}
echo ${TAG}
# Extract major, minor, and patch versions
IFS='.' read -r MAJOR MINOR PATCH <<< "${TAG#v}"
echo ${MAJOR}
echo ${MINOR}
echo ${PATCH}
# Create release branch for the exact version
git checkout -b "release/${TAG}"
git push origin "release/${TAG}"
# Update release branch for minor version
git checkout -b "release/v${MAJOR}.${MINOR}" || git checkout "release/v${MAJOR}.${MINOR}"
git merge --ff-only "${TAG}"
git push origin "release/v${MAJOR}.${MINOR}"
# Update release branch for major version
git checkout -b "release/v${MAJOR}" || git checkout "release/v${MAJOR}"
git merge --ff-only "${TAG}"
git push origin "release/v${MAJOR}"