-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks
executable file
·72 lines (65 loc) · 1.97 KB
/
tasks
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
#!/bin/bash
set -e
SECRET_OPS_VERSION="0.6.2"
RELEASER_VERSION="2.1.0"
RELEASER_FILE="ops/releaser-${RELEASER_VERSION}"
SECRET_OPS_FILE="ops/secret-ops"
SECRET_OPS_TAR_FILE="ops/secret-ops-${SECRET_OPS_VERSION}.tar.gz"
mkdir -p ops
if [[ ! -f $RELEASER_FILE ]];then
wget --quiet -O $RELEASER_FILE https://github.com/kudulab/releaser/releases/download/${RELEASER_VERSION}/releaser
fi
source $RELEASER_FILE
if [[ ! -f $SECRET_OPS_TAR_FILE ]];then
wget --quiet -O $SECRET_OPS_TAR_FILE https://github.com/kudulab/secret-ops/releases/download/${SECRET_OPS_VERSION}/secret-ops.tar.gz
tar -xf $SECRET_OPS_TAR_FILE -C ops
fi
source $SECRET_OPS_FILE
command="$1"
case "${command}" in
set_version)
releaser::bump_changelog_version "$2" "$3"
;;
verify_version)
releaser::verify_release_ready
;;
itest)
time bats ./test/integration/*.bats
;;
test)
./tasks itest
;;
release)
releaser::verify_release_ready
releaser::git_tag_from_changelog
;;
publish)
# publish the just released version
GITHUB_TOKEN=$(vault read -field=token secret/gocd/github_releases)
export GITHUB_TOKEN
VERSION=$(releaser::get_last_git_tagged_version)
releaser::prepare_github_release_bin
$GHRELEASE_BIN release \
--user kudulab \
--repo docker-ops \
--tag $VERSION \
--name $VERSION
$GHRELEASE_BIN upload \
--user kudulab \
--repo docker-ops \
--tag $VERSION \
--name "docker-ops" \
--file src/docker-ops
;;
generate_vault_token)
vault_token=$(vault token create -ttl=48h -policy=gocd -field token -metadata gocd_renew=true)
secured_token_gocd=$(secret_ops::encrypt_with_gocd_top "${vault_token}")
echo "Generated token: ${vault_token} and encrypted by GoCD server"
secret_ops::insert_vault_token_gocd_yaml "${secured_token_gocd}"
;;
*)
echo "Invalid command: '${command}'"
exit 1
;;
esac
set +e