forked from pellepelster/solidblocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdo
executable file
·158 lines (128 loc) · 4.08 KB
/
do
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
set -eu -o pipefail
DIR="$(cd "$(dirname "$0")" ; pwd -P)"
source "${DIR}/solidblocks-shell/lib/download.sh"
source "${DIR}/solidblocks-shell/lib/software.sh"
source "${DIR}/solidblocks-shell/lib/file.sh"
source "${DIR}/solidblocks-shell/lib/log.sh"
VERSION="${GITHUB_REF_NAME:-snapshot}"
COMPONENTS="solidblocks-shell solidblocks-hetzner solidblocks-cloud-init solidblocks-debug-container solidblocks-sshd solidblocks-minio solidblocks-rds-postgresql"
function ensure_environment {
software_ensure_shellcheck
software_ensure_hugo
software_ensure_semver
software_set_export_path
}
function task_build {
for component in ${COMPONENTS}; do
(
cd "${DIR}/${component}"
VERSION=${VERSION} "./do" build
)
done
}
function task_clean_aws {
docker run \
--rm -it \
-v $(pwd)/contrib/aws-nuke.yaml:/home/aws-nuke/config.yml \
quay.io/rebuy/aws-nuke:v2.22.1 \
--access-key-id "$(pass solidblocks/aws/admin/access_key)" \
--secret-access-key "$(pass solidblocks/aws/admin/secret_access_key)" \
--config /home/aws-nuke/config.yml \
--no-dry-run \
--force
}
function task_clean {
rm -rf "${DIR}/build"
for component in ${COMPONENTS}; do
(
cd "${DIR}/${component}"
"./do" clean
)
done
}
function task_test {
if [[ -n "${SKIP_TESTS:-}" ]]; then
exit 0
fi
for component in ${COMPONENTS}; do
(
cd "${DIR}/${component}"
VERSION=${VERSION} "./do" test
)
done
}
function task_release_docker {
for component in ${COMPONENTS}; do
(
cd "${DIR}/${component}"
VERSION=${VERSION} "./do" release-docker
)
done
}
function task_build_documentation {
ensure_environment
mkdir -p "${DIR}/doc/snippets"
if [[ -n "${CI:-}" ]]; then
rsync -rv --exclude=".terraform" --exclude="*.tfstate*" --exclude=".terraform.lock.hcl" ${DIR}/*/snippets/* "${DIR}/doc/snippets"
else
rsync -rv --exclude=".terraform" --exclude="*.tfstate*" --exclude=".terraform.lock.hcl" ${DIR}/*/snippets/* "${DIR}/doc/snippets"
rsync -rv --exclude=".terraform" --exclude="*.tfstate*" --exclude=".terraform.lock.hcl" ${DIR}/*/build/snippets/* "${DIR}/doc/snippets"
fi
export VERSION="$(semver get release)"
mkdir -p "${DIR}/build/documentation"
(
cd "${DIR}/build/documentation"
cp -r ${DIR}/doc/* ./
source "${DIR}/solidblocks-shell/lib/software.sh"
sed -i "s/__TERRAFORM_VERSION__/${TERRAFORM_VERSION}/g" content/shell/software/_index.md
sed -i "s/__CONSUL_VERSION__/${CONSUL_VERSION}/g" content/shell/software/_index.md
sed -i "s/__HUGO_VERSION__/${HUGO_VERSION}/g" content/shell/software/_index.md
sed -i "s/__SHELLCHECK_VERSION__/${SHELLCHECK_VERSION}/g" content/shell/software/_index.md
sed -i "s/__SEMVER_VERSION__/${SEMVER_VERSION}/g" content/shell/software/_index.md
sed -i "s/__TERRAGRUNT_VERSION__/${TERRAGRUNT_VERSION}/g" content/shell/software/_index.md
sed -i "s/__RESTIC_VERSION__/${RESTIC_VERSION}/g" content/shell/software/_index.md
sed -i "s/__SOLIDBLOCKS_VERSION__/${VERSION}/g" content/rds/_index.md
hugo
)
}
function task_serve_documentation {
ensure_environment
(
cd "${DIR}/doc"
hugo serve --baseURL "/"
)
}
function task_release {
if [[ ! -f ".semver.yaml" ]]; then
semver init --release v0.0.1
fi
local version="$(semver get release)"
git tag -a "${version}" -m "${version}"
git push --tags
semver up release
git add .semver.yaml
git commit -m "bump version to $(semver get release)"
git push
}
function task_usage {
echo "Usage: $0 ..."
exit 1
}
ARG=${1:-}
shift || true
case "${ARG}" in
bootstrap) ;;
*) ensure_environment ;;
esac
case ${ARG} in
build) task_build "$@" ;;
clean) task_clean "$@" ;;
clean-aws) task_clean_aws "$@" ;;
test) task_test "$@" ;;
build-documentation) task_build_documentation "$@" ;;
serve-documentation) task_serve_documentation "$@" ;;
release) task_release "$@" ;;
release-docker) task_release_docker "$@" ;;
*) task_usage ;;
esac