File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Check if remembered to update version
2
+
3
+ on :
4
+ pull_request :
5
+ branches : [ master ]
6
+
7
+ jobs :
8
+ check_if_version_changed :
9
+ runs-on : ubuntu-latest
10
+
11
+ steps :
12
+ - name : Check out Git repository
13
+ uses : actions/checkout@v2
14
+
15
+ - name : Check if version updated
16
+ run : |
17
+ # In case only a shallow clone was done
18
+ git fetch --tags
19
+
20
+ PACKAGE_VERSION=$(cat 'package.json' | jq -r '.version') # E.g. 0.1.1
21
+ LATEST_TAG=$(git tag -l --sort -version:refname | head -n 1) # E.g. v0.1.1
22
+
23
+ if [[ "${PACKAGE_VERSION}" && ! $(git tag | grep "${PACKAGE_VERSION}") ]]; then
24
+ echo "Version has changed!"
25
+ echo "Latest version tag is $LATEST_TAG while package.json has been updated to v${PACKAGE_VERSION}"
26
+ exit 0 # Success
27
+ else
28
+ echo "The version number in package.json is not updated!"
29
+ echo "The version number in package.json (v${PACKAGE_VERSION}) is <= the latest version tag ($LATEST_TAG)"
30
+ exit 1 # Error
31
+ fi
You can’t perform that action at this time.
0 commit comments