forked from anothrNick/github-tag-action
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathentrypoint.sh
executable file
·69 lines (63 loc) · 1.86 KB
/
entrypoint.sh
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
#!/bin/bash
# config
with_v=${WITH_V:-false}
# get latest tag
git checkout master
git pull
old_tag=$(git tag --sort=-creatordate | head -n 1)
echo ::tag before latest check: $old_tag
tag_commit=$(git rev-list -n 1 $old_tag)
# get current commit hash for tag
commit=$(git rev-parse HEAD)
git_refs_url=$(jq .repository.git_refs_url $GITHUB_EVENT_PATH | tr -d '"' | sed 's/{\/sha}//g')
if [ "$tag_commit" == "$commit" ]; then
echo "No new commits since previous tag. Skipping..."
exit 0
fi
new=$(git show $commit:VERSION)
#if [ "$tag" == "latest" ]; then
# tag=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
#fi
echo ::new tag: $new
#echo ::tag before update: $tag
# if there are none, start tags at 0.0.0
#if [ -z "$tag" ]
#then
# log=$(git log --pretty=oneline)
# tag=0.0.0
#else
# log=$(git log $tag..HEAD --pretty=oneline)
#fi
#echo ::commit message: $log
# get commit logs and determine home to bump the version
# supports #major, #minor, #patch (anything else will be 'minor')
#case "$log" in
# *#major* ) new=$(semver bump major $tag);;
# *#minor* ) new=$(semver bump minor $tag);;
# *#patch* ) new=$(semver bump patch $tag);;
# * ) new="none";;
#esac
#echo ::setting user and email
git config user.email "[email protected]"
git config user.name "user"
echo ::checking if new tag exists
if [ "$new" != "none" ]; then
# prefix with 'v'
if $with_v
then
new="v$new"
fi
echo ::new tag: $new
# push new tag ref to github
dt=$(date '+%Y-%m-%dT%H:%M:%SZ')
full_name=$GITHUB_REPOSITORY
echo "$dt: **pushing tag $new to repo $full_name"
#curl -s -X POST $git_refs_url \
#-H "Authorization: token $GITHUB_TOKEN" \
#-d '{"ref": "refs/tags/'$new'", "sha": "'$commit'"}'
git tag -a -m "release: ${new}" $new $commit
fi
echo ::pushing new tag
git push origin :refs/tags/latest
git tag -fa -m "latest release" latest $commit
git push --follow-tag