File tree Expand file tree Collapse file tree 2 files changed +72
-2
lines changed Expand file tree Collapse file tree 2 files changed +72
-2
lines changed Original file line number Diff line number Diff line change @@ -12,8 +12,47 @@ permissions:
12
12
pull-requests : write
13
13
14
14
jobs :
15
+ check-version :
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - name : Checkout main
19
+ uses : actions/checkout@v2
20
+ with :
21
+ ref : main
22
+ fetch-depth : 0
23
+
24
+ - name : Extract Major.Minor Version and setup Env variable
25
+ run : |
26
+ echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
27
+ echo "MAJOR_MINOR=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')" >> $GITHUB_ENV
28
+
29
+ - name : Get current major.minor version from main branch
30
+ id : get_version
31
+ run : |
32
+ CURRENT_VERSION=$(grep '__version__' aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py | sed -E 's/__version__ = "([0-9]+\.[0-9]+)\.[0-9]+.*"/\1/')
33
+ echo "CURRENT_MAJOR_MINOR_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
34
+
35
+ - name : Set major and minor for current version
36
+ run : |
37
+ echo "CURRENT_MAJOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f1)" >> $GITHUB_ENV
38
+ echo "CURRENT_MINOR=$(echo $CURRENT_MAJOR_MINOR_VERSION | cut -d. -f2)" >> $GITHUB_ENV
39
+
40
+ - name : Set major and minor for input version
41
+ run : |
42
+ echo "INPUT_MAJOR=$(echo $MAJOR_MINOR | cut -d. -f1)" >> $GITHUB_ENV
43
+ echo "INPUT_MINOR=$(echo $MAJOR_MINOR | cut -d. -f2)" >> $GITHUB_ENV
44
+
45
+ - name : Compare major.minor version and skip if behind
46
+ run : |
47
+ if [ "$CURRENT_MAJOR" -gt "$INPUT_MAJOR" ] || { [ "$CURRENT_MAJOR" -eq "$INPUT_MAJOR" ] && [ "$CURRENT_MINOR" -gt "$INPUT_MINOR" ]; }; then
48
+ echo "Input version is behind main's current major.minor version, don't need to update major version"
49
+ exit 1
50
+ fi
51
+
52
+
15
53
prepare-main :
16
54
runs-on : ubuntu-latest
55
+ needs : check-version
17
56
steps :
18
57
- name : Setup Git
19
58
uses : actions/checkout@v2
Original file line number Diff line number Diff line change 6
6
version :
7
7
description : ' Version number (e.g., 1.0.1)'
8
8
required : true
9
+ is_patch :
10
+ description : ' Is this a patch? (true or false)'
11
+ required : true
12
+ default : ' false'
9
13
10
14
permissions :
11
15
contents : write
33
37
34
38
- name : Create branches
35
39
run : |
36
- git checkout -b "release/${MAJOR_MINOR}.x"
37
- git push origin "release/${MAJOR_MINOR}.x"
40
+ IS_PATCH=${{ github.event.inputs.is_patch }}
41
+ if [[ "$IS_PATCH" != "true" && "$IS_PATCH" != "false" ]]; then
42
+ echo "Invalid input for IS_PATCH. Must be 'true' or 'false'."
43
+ exit 1
44
+ fi
45
+
46
+
47
+ if git ls-remote --heads origin release/${MAJOR_MINOR}.x | grep -q "release/${MAJOR_MINOR}.x"; then
48
+ if [ "$IS_PATCH" = "true" ]; then
49
+ git fetch origin release/${MAJOR_MINOR}.x
50
+ echo "Branch release/${MAJOR_MINOR}.x already exists, checking out."
51
+ git checkout "release/${MAJOR_MINOR}.x"
52
+ else
53
+ echo "Error, release series branch release/${MAJOR_MINOR}.x exist for non-patch release"
54
+ echo "Check your input or branch"
55
+ exit 1
56
+ fi
57
+ else
58
+ if [ "$IS_PATCH" = "true" ]; then
59
+ echo "Error, release series branch release/${MAJOR_MINOR}.x NOT exist for patch release"
60
+ echo "Check your input or branch"
61
+ exit 1
62
+ else
63
+ echo "Creating branch release/${MAJOR_MINOR}.x."
64
+ git checkout -b "release/${MAJOR_MINOR}.x"
65
+ git push origin "release/${MAJOR_MINOR}.x"
66
+ fi
67
+ fi
68
+
38
69
git checkout -b "${VERSION}_release"
39
70
git push origin "${VERSION}_release"
40
71
You can’t perform that action at this time.
0 commit comments