-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks
executable file
·77 lines (71 loc) · 1.91 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
73
74
75
76
77
#!/bin/bash
set -Eeo pipefail
RELEASER_VERSION="2.1.0"
RELEASER_FILE="ops/releaser-${RELEASER_VERSION}"
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
source ./src/secret-ops
command="$1"
case "${command}" in
set_version)
releaser::bump_changelog_version "$2" "$3"
;;
verify_version)
releaser::verify_release_ready
;;
test_bash)
bats test/bats/
;;
test_python)
python3 test_secret_ops.py
;;
test)
./tasks test_bash
./tasks test_python
;;
package)
rm -rf pkg/
mkdir -p pkg/
cp src/* pkg/
cp secret_ops.py pkg/
cd pkg
tar -cvzf ../secret-ops.tar.gz *
;;
release)
releaser::verify_release_ready
releaser::git_tag_from_changelog
;;
publish)
# publish the just released version
./tasks package
GITHUB_TOKEN=$(vault read -field=token secret/gocd/github_releases)
export GITHUB_TOKEN
VERSION=$(releaser::get_last_version_from_changelog)
releaser::prepare_github_release_bin
$GHRELEASE_BIN release \
--user kudulab \
--repo secret-ops \
--tag $VERSION \
--name $VERSION \
--pre-release
$GHRELEASE_BIN upload \
--user kudulab \
--repo secret-ops \
--tag $VERSION \
--name "secret-ops.tar.gz" \
--file secret-ops.tar.gz
;;
generate_vault_token)
vault_token=$(vault token create -orphan -ttl=168h -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}"
;;
*)
python3 tasks.py "$@"
;;
esac
set +e