Skip to content

Commit 4edb649

Browse files
committed
fixup! chore: write build_go_matrix.sh and archive.sh
1 parent e847230 commit 4edb649

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

scripts/archive.sh

100644100755
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

3-
# This script creates an archive containing the given binary, as well as the
4-
# README.md and LICENSE files.
3+
# This script creates an archive containing the given binary renamed to
4+
# `coder(.exe)?`, as well as the README.md and LICENSE files from the repo root.
55
#
66
# Usage: ./archive.sh --format tar.gz [--output path/to/output.tar.gz] [--sign-darwin] path/to/binary
77
#
@@ -24,7 +24,7 @@ format=""
2424
output_path=""
2525
sign_darwin=0
2626

27-
args="$(getopt -o "" -l version:,output:,slim,sign-darwin -- "$@")"
27+
args="$(getopt -o "" -l format:,output:,sign-darwin -- "$@")"
2828
eval set -- "$args"
2929
while true; do
3030
case "$1" in
@@ -58,8 +58,12 @@ while true; do
5858
esac
5959
done
6060

61+
if [[ "$format" == "" ]]; then
62+
error "--format is a required parameter"
63+
fi
64+
6165
if [[ "$#" != 1 ]]; then
62-
error "Exactly one argument must be provided to this script"
66+
error "Exactly one argument must be provided to this script, $# were supplied"
6367
fi
6468
if [[ ! -f "$1" ]]; then
6569
error "File '$1' does not exist or is not a regular file"
@@ -82,18 +86,21 @@ fi
8286
# be symlinked from.
8387
cdroot
8488
temp_dir="$(mktemp -d)"
85-
ln -s "$input_file" "$temp_dir/$output_path"
86-
ln -s README.md "$temp_dir/"
87-
ln -s LICENSE "$temp_dir/"
89+
ln -s "$input_file" "$temp_dir/$output_file"
90+
ln -s "$(realpath README.md)" "$temp_dir/"
91+
ln -s "$(realpath LICENSE)" "$temp_dir/"
8892

89-
# Ensure parent output dir.
93+
# Ensure parent output dir and non-existent output file.
9094
mkdir -p "$(dirname "$output_path")"
95+
if [[ -e "$output_path" ]]; then
96+
error "Output path '$output_path' already exists!"
97+
fi
9198

9299
cd "$temp_dir"
93100
if [[ "$format" == "zip" ]]; then
94101
zip "$output_path" ./*
95102
else
96-
tar -czvf "$output_path" ./*
103+
tar --dereference -czvf "$output_path" ./*
97104
fi
98105

99106
rm -rf "$temp_dir"

0 commit comments

Comments
 (0)