forked from tomzo/gocd-yaml-config-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.sh
executable file
·86 lines (76 loc) · 2.69 KB
/
tasks.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -e
source .build/docker-ops
source .build/releaser
releaser_init
function get_version_tag {
changelog_first_line=$(cat ${changelog_file} | head -1)
changelog_version=$(get_last_version_from_changelog "${changelog_file}")
short_sha=$(git rev-parse --short=8 HEAD)
if [[ "${changelog_first_line}" == "#"*"Unreleased"* ]] || [[ "${changelog_first_line}" == "#"*"unreleased"* ]] || [[ "${changelog_first_line}" == "#"*"UNRELEASED"* ]];then
log_info "Top of changelog has 'Unreleased' flag"
echo "$changelog_version-$short_sha"
else
echo "$changelog_version"
fi
}
command="$1"
case "${command}" in
set_version)
if [[ -n "$2" ]]; then
next_version="$2"
else
changelog_version=$(get_last_version_from_changelog "${changelog_file}")
next_version=$(bump_patch_version $changelog_version)
fi
set_version_in_changelog "${changelog_file}" "${next_version}" "true"
set_version_in_file "version " "build.gradle" "${next_version}"
;;
commit)
git add "${changelog_file}"
git add "build.gradle"
git commit --author "Tomasz Setkowski <[email protected]>" -m "Version bump"
;;
prepare_release)
next_version=$(get_last_version_from_changelog "${changelog_file}")
set_version_in_changelog "${changelog_file}" "${next_version}" "false"
set_version_in_file "version " "build.gradle" "${next_version}"
;;
build)
dojo "gradle test jar"
;;
github_release)
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is unset";
exit 1;
fi
if [ ! -f linux-amd64-github-release.tar.bz2 ]; then
wget https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2 -O linux-amd64-github-release.tar.bz2
fi
tar xf linux-amd64-github-release.tar.bz2
VERSION=$(ls build/libs/yaml-config-plugin-*.jar | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
GHRELEASE_BIN="./bin/linux/amd64/github-release"
changelog_version=$(get_last_version_from_changelog "${changelog_file}")
if [ $changelog_version != $VERSION ]; then
echo "changelog version $changelog_version does not match file version $VERSION"
exit 2
fi
$GHRELEASE_BIN release \
--user tomzo \
--repo gocd-yaml-config-plugin \
--tag $VERSION \
--name $VERSION \
--description "$changelog_version<br>docker image kudulab/gocd-cli-dojo:yaml-$VERSION" \
--pre-release
$GHRELEASE_BIN upload \
--user tomzo \
--repo gocd-yaml-config-plugin \
--tag $VERSION \
--name "yaml-config-plugin-$VERSION.jar" \
--file build/libs/yaml-config-plugin-$VERSION.jar
;;
*)
echo "Invalid command: '${command}'"
exit 1
;;
esac