@@ -6,46 +6,46 @@ set -euo pipefail
66# Usage: create-archives.sh <bin-directory>
77
88function main {
9- local -r bin_dir=" ${1:- bin} "
10-
11- if [[ ! -d " $bin_dir " ]]; then
12- echo " ERROR: Directory $bin_dir does not exist" >&2
13- exit 1
14- fi
15-
16- # Use pushd/popd to avoid side effects on caller's working directory
17- pushd " $bin_dir " || return 1
18-
19- echo " Creating individual archives for each binary..."
20-
21- # Create individual ZIP and TAR.GZ archives for each binary (preserving execute permissions)
22- for binary in terragrunt_* ; do
23- # Skip if it's already an archive file
24- if [[ " $binary " == * .zip ]] || [[ " $binary " == * .tar.gz ]]; then
25- continue
26- fi
27-
28- # Create ZIP archive
29- zip " $binary .zip" " $binary "
30- echo " Created: $binary .zip"
31-
32- # Create TAR.GZ archive (preserves Unix permissions including +x)
33- tar -czf " $binary .tar.gz" " $binary "
34- echo " Created: $binary .tar.gz"
35- done
36-
37- echo " "
38- echo " All individual archives created:"
39- echo " ZIP archives:"
40- ls -lh * .zip
41- echo " "
42- echo " TAR.GZ archives:"
43- ls -lh * .tar.gz
44-
45- # Return to original directory
46- popd || return 1
47-
48- return 0
9+ local -r bin_dir=" ${1:- bin} "
10+
11+ if [[ ! -d " $bin_dir " ]]; then
12+ echo " ERROR: Directory $bin_dir does not exist" >&2
13+ exit 1
14+ fi
15+
16+ # Use pushd/popd to avoid side effects on caller's working directory
17+ pushd " $bin_dir " || return 1
18+
19+ echo " Creating individual archives for each binary..."
20+
21+ # Create individual ZIP and TAR.GZ archives for each binary (preserving execute permissions)
22+ for binary in terragrunt_* ; do
23+ # Skip if it's already an archive file
24+ if [[ " $binary " == * .zip ]] || [[ " $binary " == * .tar.gz ]]; then
25+ continue
26+ fi
27+
28+ # Create ZIP archive
29+ zip " $binary .zip" " $binary "
30+ echo " Created: $binary .zip"
31+
32+ # Create TAR.GZ archive (preserves Unix permissions including +x)
33+ tar -czf " $binary .tar.gz" " $binary "
34+ echo " Created: $binary .tar.gz"
35+ done
36+
37+ echo " "
38+ echo " All individual archives created:"
39+ echo " ZIP archives:"
40+ ls -lh -- * .zip
41+ echo " "
42+ echo " TAR.GZ archives:"
43+ ls -lh -- * .tar.gz
44+
45+ # Return to original directory
46+ popd || return 1
47+
48+ return 0
4949}
5050
5151main " $@ "
0 commit comments