-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
77 lines (72 loc) · 3.25 KB
/
action.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
67
68
69
70
71
72
73
74
75
76
77
name: twgit-release-version-generator
description: This is an action to generate a semver version number from a github push on a project using twgit
author: Dominic Watson
branding:
icon: 'thumbs-up'
color: 'white'
inputs:
build_number_start:
description: Allows you to bump the Github build number by some predermined value
required: false
outputs:
semver_release_string:
description: 'The full semver release string. e.g. 1.0.0+000598 or 2.1.0-SNAPSHOT004994.'
value: ${{ steps.version-generator.outputs.semver_release_string }}
semver_release_number:
description: 'Just the release number part, e.g. 1.0.0 or 2.1.0'
value: ${{ steps.version-generator.outputs.semver_release_number }}
semver_build_number:
description: 'Just the build number, i.e. 000598'
value: ${{ steps.version-generator.outputs.semver_build_number }}
semver_is_stable:
description: 'True or false, whether or not this release is a stable released version or an upcoming snapshot release.'
value: ${{ steps.version-generator.outputs.semver_is_stable }}
semver_is_snapshot:
description: 'True or false, whether or not this release is an upcoming snapshot release or a stable released version.'
value: ${{ steps.version-generator.outputs.semver_is_snapshot }}
runs:
using: "composite"
steps:
- id: version-generator
env:
BUILD_NUMBER_START: ${{ inputs.build_number_start }}
run: |
GIT_BRANCH=${GITHUB_REF##*/}
BUILD_NUMBER=$(( $GITHUB_RUN_NUMBER + ${BUILD_NUMBER_START:-0} ))
BUILD_NUMBER=`printf %07d $BUILD_NUMBER`
echo "Using build number start: ${BUILD_NUMBER_START:-0}"
if [[ $GIT_BRANCH == v* ]] ; then
VERSION_NUMBER="${GIT_BRANCH//v}"
VERSION_NUMBER_FULL="${VERSION_NUMBER}+${BUILD_NUMBER}"
VERSION_IS_STABLE=true
VERSION_IS_SNAPSHOT=false
elif [[ $GIT_BRANCH == release* ]] ; then
VERSION_NUMBER="${GIT_BRANCH//release-}"
VERSION_NUMBER_FULL="${VERSION_NUMBER}-SNAPSHOT${BUILD_NUMBER}"
VERSION_IS_STABLE=false
VERSION_IS_SNAPSHOT=true
elif [[ $GIT_BRANCH == demo* ]] ; then
VERSION_NUMBER="0.0.0"
VERSION_NUMBER_FULL="${VERSION_NUMBER}-DEMO-${GIT_BRANCH//demo-}-${BUILD_NUMBER}"
VERSION_IS_STABLE=false
VERSION_IS_SNAPSHOT=true
else
VERSION_NUMBER="unknown"
VERSION_NUMBER_FULL="unknown"
VERSION_IS_STABLE=false
VERSION_IS_SNAPSHOT=false
fi
echo "Setting output variables:"
echo "-------------------------"
echo "semver_release_string: ${VERSION_NUMBER_FULL}"
echo "semver_release_number: ${VERSION_NUMBER}"
echo "semver_build_number: ${BUILD_NUMBER}"
echo "semver_is_stable: ${VERSION_IS_STABLE}"
echo "semver_is_snapshot: ${VERSION_IS_SNAPSHOT}"
echo "-------------------------"
echo "semver_release_string=$VERSION_NUMBER_FULL" >> $GITHUB_OUTPUT
echo "semver_release_number=$VERSION_NUMBER" >> $GITHUB_OUTPUT
echo "semver_build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
echo "semver_is_stable=$VERSION_IS_STABLE" >> $GITHUB_OUTPUT
echo "semver_is_snapshot=$VERSION_IS_SNAPSHOT" >> $GITHUB_OUTPUT
shell: bash