Skip to content

Commit 4dd6f4d

Browse files
committed
chore: add dependency checks to release scripts
1 parent e09edfd commit 4dd6f4d

10 files changed

+114
-4
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ jobs:
4949
restore-keys: |
5050
js-${{ runner.os }}-
5151
52+
- name: Install nfpm
53+
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
54+
5255
- name: Build Site
5356
run: make site/out/index.html
5457

scripts/archive.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ if [[ ! -f "$1" ]]; then
7272
fi
7373
input_file="$(realpath "$1")"
7474

75+
# Check dependencies
76+
if [[ "$format" == "zip" ]] && ! command -v zip; then
77+
error "The 'zip' binary is required."
78+
fi
79+
if [[ "$format" == "tar.gz" ]] && ! command -v tar; then
80+
error "The 'tar' binary is required."
81+
fi
82+
if [[ "$sign_darwin" == 1 ]]; then
83+
if ! command -v jq; then
84+
error "The 'jq' binary is required."
85+
fi
86+
if ! command -v codesign; then
87+
error "The 'codesign' binary is required."
88+
fi
89+
if ! command -v gon; then
90+
error "The 'gon' binary is required."
91+
fi
92+
fi
93+
7594
# Determine default output path.
7695
if [[ "$output_path" == "" ]]; then
7796
output_path="${input_file%.exe}"

scripts/build_docker.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ if [[ "$arch" == "" ]]; then
5656
error "The --arch parameter is required"
5757
fi
5858

59+
# Check dependencies
60+
if ! command -v docker; then
61+
error "The 'docker' binary is required."
62+
fi
63+
5964
# Remove the "v" prefix.
6065
version="${version#v}"
6166
if [[ "$version" == "" ]]; then

scripts/build_docker_multiarch.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,21 @@ while true; do
4444
esac
4545
done
4646

47+
if [[ "$#" == 0 ]]; then
48+
error "At least one argument must be provided to this script, $# were supplied"
49+
fi
50+
51+
# Check dependencies
52+
if ! command -v docker; then
53+
error "The 'docker' binary is required."
54+
fi
55+
4756
# Remove the "v" prefix.
4857
version="${version#v}"
4958
if [[ "$version" == "" ]]; then
5059
version="$(execrelative ./version.sh)"
5160
fi
5261

53-
if [[ "$#" == 0 ]]; then
54-
error "At least one argument must be provided to this script, $# were supplied"
55-
fi
56-
5762
create_args=()
5863
for image_tag in "$@"; do
5964
create_args+=(--amend "$image_tag")

scripts/build_go.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,22 @@ if [[ "$version" == "" ]]; then
7979
version="$(execrelative ./version.sh)"
8080
fi
8181

82+
# Check dependencies
83+
if ! command -v go; then
84+
error "The 'go' binary is required."
85+
fi
86+
if [[ "$sign_darwin" == 1 ]]; then
87+
if ! command -v jq; then
88+
error "The 'jq' binary is required."
89+
fi
90+
if ! command -v codesign; then
91+
error "The 'codesign' binary is required."
92+
fi
93+
if ! command -v gon; then
94+
error "The 'gon' binary is required."
95+
fi
96+
fi
97+
8298
build_args=(
8399
-ldflags "-s -w -X 'github.com/coder/coder/buildinfo.tag=$version'"
84100
)

scripts/build_go_matrix.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,21 @@ fi
109109

110110
# Parse the os:arch specs into an array.
111111
specs=()
112+
may_zip=0
113+
may_tar=0
112114
for spec in "$@"; do
113115
spec_os="$(echo "$spec" | cut -d ":" -f 1)"
114116
if [[ "$spec_os" == "" ]] || [[ "$spec_os" == *" "* ]]; then
115117
error "Could not parse matrix build spec '$spec': invalid OS '$spec_os'"
116118
fi
117119

120+
# Determine which dependencies we need.
121+
if [[ "$spec_os" == "windows" ]] || [[ "$spec_os" == "darwin" ]]; then
122+
may_zip=1
123+
else
124+
may_tar=1
125+
fi
126+
118127
# No quoting is important here.
119128
for spec_arch in $(echo "$spec" | cut -d ":" -f 2 | tr "," "\n"); do
120129
if [[ "$spec_arch" == "" ]] || [[ "$spec_os" == *" "* ]]; then
@@ -132,6 +141,33 @@ for s in $(echo "$specs_str" | tr " " "\n" | awk '!a[$0]++'); do
132141
specs+=("$s")
133142
done
134143

144+
# Check dependencies
145+
if ! command -v go; then
146+
error "The 'go' binary is required."
147+
fi
148+
if [[ "$sign_darwin" == 1 ]]; then
149+
if ! command -v jq; then
150+
error "The 'jq' binary is required."
151+
fi
152+
if ! command -v codesign; then
153+
error "The 'codesign' binary is required."
154+
fi
155+
if ! command -v gon; then
156+
error "The 'gon' binary is required."
157+
fi
158+
fi
159+
if [[ "$archive" == 1 ]]; then
160+
if [[ "$may_zip" == 1 ]] && ! command -v zip; then
161+
error "The 'zip' binary is required."
162+
fi
163+
if [[ "$may_tar" == 1 ]] && ! command -v tar; then
164+
error "The 'zip' binary is required."
165+
fi
166+
fi
167+
if [[ "$package_linux" == 1 ]] && ! command -v nfpm; then
168+
error "The 'nfpm' binary is required."
169+
fi
170+
135171
build_args=()
136172
if [[ "$slim" == 1 ]]; then
137173
build_args+=(--slim)

scripts/build_go_slim.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ while true; do
4545
esac
4646
done
4747

48+
# Check dependencies
49+
if ! command -v go; then
50+
error "The 'go' binary is required."
51+
fi
52+
4853
# Remove the "v" prefix.
4954
version="${version#v}"
5055
if [[ "$version" == "" ]]; then

scripts/package.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ if [[ ! -f "$1" ]]; then
5050
fi
5151
input_file="$(realpath "$1")"
5252

53+
# Check dependencies
54+
if ! command -v nfpm; then
55+
error "The 'nfpm' binary is required."
56+
fi
57+
5358
# Remove the "v" prefix.
5459
version="${version#v}"
5560
if [[ "$version" == "" ]]; then

scripts/publish_release.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ while true; do
5050
esac
5151
done
5252

53+
# Check dependencies
54+
if ! command -v gh; then
55+
error "The 'gh' binary is required."
56+
fi
57+
5358
# Remove the "v" prefix.
5459
version="${version#v}"
5560
if [[ "$version" == "" ]]; then

scripts/sign_darwin.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ if [[ "${AC_APPLICATION_IDENTITY:-}" == "" ]]; then
2020
error "AC_APPLICATION_IDENTITY must be set for ./sign_darwin.sh"
2121
fi
2222

23+
# Check dependencies
24+
if ! command -v jq; then
25+
error "The 'jq' binary is required."
26+
fi
27+
if ! command -v codesign; then
28+
error "The 'codesign' binary is required."
29+
fi
30+
if ! command -v gon; then
31+
error "The 'gon' binary is required."
32+
fi
33+
2334
# Create the gon config.
2435
config="$(mktemp -d)/gon.json"
2536
jq -r --null-input --arg path "$(pwd)/$1" '{

0 commit comments

Comments
 (0)