1
1
#! /usr/bin/env bash
2
2
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 .
5
5
#
6
6
# Usage: ./archive.sh --format tar.gz [--output path/to/output.tar.gz] [--sign-darwin] path/to/binary
7
7
#
@@ -24,7 +24,7 @@ format=""
24
24
output_path=" "
25
25
sign_darwin=0
26
26
27
- args=" $( getopt -o " " -l version :,output:,slim ,sign-darwin -- " $@ " ) "
27
+ args=" $( getopt -o " " -l format :,output:,sign-darwin -- " $@ " ) "
28
28
eval set -- " $args "
29
29
while true ; do
30
30
case " $1 " in
@@ -58,8 +58,12 @@ while true; do
58
58
esac
59
59
done
60
60
61
+ if [[ " $format " == " " ]]; then
62
+ error " --format is a required parameter"
63
+ fi
64
+
61
65
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 "
63
67
fi
64
68
if [[ ! -f " $1 " ]]; then
65
69
error " File '$1 ' does not exist or is not a regular file"
82
86
# be symlinked from.
83
87
cdroot
84
88
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 /"
88
92
89
- # Ensure parent output dir.
93
+ # Ensure parent output dir and non-existent output file .
90
94
mkdir -p " $( dirname " $output_path " ) "
95
+ if [[ -e " $output_path " ]]; then
96
+ error " Output path '$output_path ' already exists!"
97
+ fi
91
98
92
99
cd " $temp_dir "
93
100
if [[ " $format " == " zip" ]]; then
94
101
zip " $output_path " ./*
95
102
else
96
- tar -czvf " $output_path " ./*
103
+ tar --dereference - czvf " $output_path " ./*
97
104
fi
98
105
99
106
rm -rf " $temp_dir "
0 commit comments