Skip to content

Commit 50e8223

Browse files
authored
build: package a development and latest build for darwin architectures (#114)
1 parent 625a457 commit 50e8223

File tree

3 files changed

+146
-153
lines changed

3 files changed

+146
-153
lines changed

.circleci/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ commands:
6464
name: Generate dev and prod archives
6565
command: |
6666
./scripts/archive.sh << parameters.artifact_dir >> $BUILD_VERSION
67+
- run:
68+
name: Check expected artifacts exist
69+
command: |
70+
./scripts/archive-test.sh << parameters.artifact_dir >> $BUILD_VERSION
6771
retrieve-oidc-secrets:
6872
description: "Retrieves secrets from Slack"
6973
parameters:
@@ -276,7 +280,7 @@ jobs:
276280
- run:
277281
name: Delete non-signed archive
278282
command: |
279-
rm << parameters.artifact_dir >>/slack_*_macOS_64-bit.tar.gz
283+
rm << parameters.artifact_dir >>/slack_*_macOS_*.tar.gz
280284
- generate-archives:
281285
artifact_dir: << parameters.artifact_dir >>
282286
- run:

scripts/archive-test.sh

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Copyright 2022-2025 Salesforce, Inc.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,88 +12,96 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
15+
set -e
1616

1717
#
1818
# USAGE:
1919
# ./scripts/archive-test.sh <release version>
2020
#
2121
# EXAMPLES:
22-
# This script now executed inside goreleaser, if you need to run the script alone, make sure you have macOS and Linux original archives in ./dist
23-
# - ./scripts/archive-test.sh 1.5.0
24-
# DESCRIPTION:
25-
# Create the development tar.gz archives used by the `install-dev.sh` script.
22+
# Artifacts are built with GoReleaser and should be packaged into various
23+
# release archives before running this script:
2624
#
27-
# Generates macOS and Linux archives.
25+
# $ make build-snapshot
26+
# $ ./scripts/archive.sh ./dist 3.3.0
27+
# $ ./scripts/archive-test.sh ./dist 3.3.0
2828
#
29-
# After generating the archive, the script will test the archive by
30-
# extracting it and looking for `bin/slack` for macOS binary
31-
# Linux archive is generated directorily from original binary
29+
# DESCRIPTION:
30+
# Confirm the expected tar.gz and zip bundles exist for a packaged version.
31+
#
32+
# Various binaries are extracted and checked for existence and permissions.
3233

33-
DIST_DIR="dist"
34+
DIST_DIR=${1}
3435

3536
main() {
36-
if [ $# -lt 1 ]; then
37-
echo "Release version is required"
37+
if [ $# -lt 2 ]; then
38+
echo "Missing parameters: $0 <path> <version>"
3839
exit 1
3940
fi
4041

41-
VERSION=${1}
42-
43-
echo "Creating macOS archive:"
44-
45-
src_file_path="$DIST_DIR/slack-macos_darwin_amd64/slack_cli_${VERSION}_macos.zip"
46-
echo "-> Source archive: $src_file_path"
47-
48-
targz_dir_path="$DIST_DIR/slack_mac_dev_64-bit"
49-
targz_file_path="$DIST_DIR/slack_mac_dev_64-bit.tar.gz"
50-
51-
echo "-> Creating dist directory: $targz_dir_path"
52-
mkdir -p "$targz_dir_path"
53-
54-
echo "-> Extracting: $targz_dir_path"
55-
unzip "$src_file_path" -d "$targz_dir_path"
56-
57-
echo "-> Moving $targz_dir_path/slack to $targz_dir_path/bin/slack"
58-
mkdir "$targz_dir_path/bin"
59-
mv "$targz_dir_path/slack" "$targz_dir_path/bin/slack"
42+
VERSION=${2}
43+
44+
echo "Checking macOS archives"
45+
check_tar "$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.tar.gz"
46+
check_tar "$DIST_DIR/slack_cli_${VERSION}_macOS_amd64.tar.gz"
47+
check_tar "$DIST_DIR/slack_cli_${VERSION}_macOS_arm64.tar.gz"
48+
check_tar "$DIST_DIR/slack_cli_dev_macOS_64-bit.tar.gz"
49+
check_tar "$DIST_DIR/slack_cli_dev_macOS_amd64.tar.gz"
50+
check_tar "$DIST_DIR/slack_cli_dev_macOS_arm64.tar.gz"
51+
check_tar "$DIST_DIR/slack_cli_latest_macOS_64-bit.tar.gz"
52+
check_tar "$DIST_DIR/slack_cli_latest_macOS_amd64.tar.gz"
53+
check_tar "$DIST_DIR/slack_cli_latest_macOS_arm64.tar.gz"
54+
55+
check_zip "$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.zip"
56+
check_zip "$DIST_DIR/slack_cli_${VERSION}_macOS_amd64.zip"
57+
check_zip "$DIST_DIR/slack_cli_${VERSION}_macOS_arm64.zip"
58+
check_zip "$DIST_DIR/slack_cli_${VERSION}_macos.zip"
59+
60+
echo "Checking Linux archives"
61+
check_tar "$DIST_DIR/slack_cli_${VERSION}_linux_64-bit.tar.gz"
62+
check_tar "$DIST_DIR/slack_cli_dev_linux_64-bit.tar.gz"
63+
check_tar "$DIST_DIR/slack_cli_latest_linux_64-bit.tar.gz"
64+
65+
echo "Checking Windows archives"
66+
check_exe "$DIST_DIR/slack_cli_${VERSION}_windows_64-bit.zip"
67+
68+
echo "Success! Archives exist!"
69+
}
6070

61-
echo "-> Creating tar.gz file: $targz_file_path"
62-
tar -C "$targz_dir_path" -zcvf "$targz_file_path" .
71+
check_exe() {
72+
echo "-> Testing executable exists: $1"
73+
tmpdir="$(mktemp -d)"
74+
trap 'rm -rf "$tmpdir"' EXIT
75+
unzip -q "$1" -d "$tmpdir"
6376

64-
echo "-> Cleaning up: $targz_dir_path"
65-
rm -R "$targz_dir_path"
77+
file "$tmpdir/bin/slack.exe" | grep -q 'PE32' || {
78+
echo "-> Failed to find executable: $1"
79+
exit 1
80+
}
81+
}
6682

67-
echo "-> Testing tar.gz file..."
68-
mkdir "$targz_dir_path"
69-
tar -zxvf "$targz_file_path" -C "$targz_dir_path"
83+
check_tar() {
84+
echo "-> Testing executable exists: $1"
85+
tmpdir="$(mktemp -d)"
86+
trap 'rm -rf "$tmpdir"' EXIT
87+
tar -xzf "$1" -C "$tmpdir"
7088

71-
if [ $(command -v "$targz_dir_path/bin/slack") ]; then
72-
echo "-> Found bin/slack"
73-
rm -R "$targz_dir_path"
74-
else
75-
echo "-> Missing bin/slack"
89+
if ! [[ -x "$tmpdir/bin/slack" ]]; then
90+
echo "-> Failed to find executable: $1"
91+
return 1
7692
fi
93+
}
7794

78-
echo "-> Everything looks good!"
79-
echo "-> macOS archive: $targz_file_path"
80-
81-
echo "Creating Linux archive:"
82-
83-
linux_src_file_path="$DIST_DIR/slack_linux_amd64/"
84-
linux_targz_file_path="$DIST_DIR/slack_linux_dev_64-bit.tar.gz"
95+
check_zip() {
96+
echo "-> Testing executable exists: $1"
97+
tmpdir="$(mktemp -d)"
98+
trap 'rm -rf "$tmpdir"' EXIT
99+
unzip -q "$1" -d "$tmpdir"
85100

86-
if [ $(command -v "$linux_src_file_path/bin/slack") ]; then
87-
echo "-> Found bin/slack"
88-
else
89-
echo "-> Missing bin/slack"
90-
exit
101+
if ! [[ -x "$tmpdir/slack" ]]; then
102+
echo "-> Failed to find executable: $1"
103+
return 1
91104
fi
92-
93-
echo "-> Creating tar.gz file: $targz_file_path"
94-
tar -czvf "$linux_targz_file_path" -C "$linux_src_file_path" .
95-
96-
echo "-> Linux archive: $linux_targz_file_path"
97105
}
98106

99107
main "$@"

scripts/archive.sh

Lines changed: 72 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Copyright 2022-2025 Salesforce, Inc.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,115 +12,96 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
set -eo
15+
set -e
1616

1717
# USAGE:
1818
# ./scripts/archive.sh <artifact path> <release version>
1919
#
2020
# EXAMPLES:
21-
# This script now executed inside goreleaser, if you need to run the script alone, make sure you have macOS and Linux original archives in your artificate path
22-
# - ./scripts/archive.sh /artifacts 1.5.0
21+
# Artifacts are built with GoReleaser and must exist before running this
22+
# script:
23+
#
24+
# $ make build-snapshot
25+
# $ ./scripts/archive.sh ./dist 3.3.0
2326
#
2427
# DESCRIPTION:
25-
# Create the development and production tar.gz archives used by the `install.sh` and `install-dev.sh`scripts.
28+
# Create the development and production tar.gz and zip archives. These are
29+
# used in the `install.sh` and `install-dev.sh` scripts.
2630
#
27-
# Generates macOS and Linux archives.
28-
29-
# After generating the archive for macOS, the script will test the archive by
30-
# extracting it and looking for `bin/slack`
31-
# Linux archive is generated directorily from original binary,
32-
# the script will check if `bin/slack` for Linux exits or not first
31+
# Tests for correct packaging is done with the `archive-test.sh` script.
3332

3433
DIST_DIR=${1}
3534

3635
main() {
3736
if [ $# -lt 2 ]; then
38-
echo "Missing parameters"
37+
echo "Missing parameters: $0 <path> <version>"
3938
exit 1
4039
fi
4140

4241
VERSION=${2}
4342

44-
echo "Creating macOS archives:"
45-
46-
mac_src_file_path="$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.zip"
47-
echo "-> Source archive: $mac_src_file_path"
48-
49-
mac_targz_dir_path="$DIST_DIR/slack_mac_64-bit"
50-
macos_dev_targz_file_path="$DIST_DIR/slack_cli_dev_macOS_64-bit.tar.gz"
51-
macos_prod_targz_file_path="$DIST_DIR/slack_cli_latest_macOS_64-bit.tar.gz"
52-
macos_prod_targz_file_path_2="$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.tar.gz"
53-
macos_prod_zip_file_path="$DIST_DIR/slack_cli_${VERSION}_macos.zip"
54-
55-
echo "-> Creating dist directory: $mac_targz_dir_path"
56-
mkdir -p "$mac_targz_dir_path"
57-
58-
echo "-> Extracting: $mac_targz_dir_path"
59-
unzip "$mac_src_file_path" -d "$mac_targz_dir_path"
60-
61-
echo "-> Moving $mac_targz_dir_path/slack to $mac_targz_dir_path/bin/slack"
62-
mkdir "$mac_targz_dir_path/bin"
63-
mv "$mac_targz_dir_path/slack" "$mac_targz_dir_path/bin/slack"
64-
65-
echo "-> Creating macOS development tar.gz file: $macos_dev_targz_file_path"
66-
tar -C "$mac_targz_dir_path" -zcvf "$macos_dev_targz_file_path" .
67-
68-
echo "-> Creating macOS production tar.gz file: $macos_prod_targz_file_path"
69-
tar -C "$mac_targz_dir_path" -zcvf "$macos_prod_targz_file_path" .
70-
tar -C "$mac_targz_dir_path" -zcvf "$macos_prod_targz_file_path_2" .
71-
72-
echo "-> Creating macOS .zip file with old name for auto-update:
73-
$macos_prod_zip_file_path"
74-
cp -i "$mac_src_file_path" "$macos_prod_zip_file_path"
75-
76-
echo "-> Cleaning up: $mac_targz_dir_path"
77-
rm -R "$mac_targz_dir_path"
78-
79-
echo "-> Testing macOs development tar.gz file..."
80-
mkdir "$mac_targz_dir_path"
81-
tar -zxvf "$macos_dev_targz_file_path" -C "$mac_targz_dir_path"
82-
83-
if [ $(command -v "$mac_targz_dir_path/bin/slack") ]; then
84-
echo "-> Found bin/slack"
85-
rm -R "$mac_targz_dir_path"
86-
else
87-
echo "-> Missing development bin/slack"
88-
fi
89-
90-
echo "-> Testing macOs production tar.gz file..."
91-
mkdir "$mac_targz_dir_path"
92-
tar -zxvf "$macos_prod_targz_file_path" -C "$mac_targz_dir_path"
93-
94-
if [ $(command -v "$mac_targz_dir_path/bin/slack") ]; then
95-
echo "-> Found bin/slack"
96-
rm -R "$mac_targz_dir_path"
97-
else
98-
echo "-> Missing production bin/slack"
99-
fi
100-
101-
echo "-> Everything looks good!"
102-
echo "-> macOS archive: $targz_file_path"
103-
104-
echo "Creating Linux archives:"
105-
106-
linux_src_file_path="$DIST_DIR/slack_cli_${VERSION}_linux_64-bit.tar.gz"
107-
linux_dev_targz_file_path="$DIST_DIR/slack_cli_dev_linux_64-bit.tar.gz"
108-
linux_prod_targz_file_path="$DIST_DIR/slack_cli_latest_linux_64-bit.tar.gz"
109-
110-
if [ -f "$linux_src_file_path" ]; then
111-
echo "-> Found linux binary archive"
112-
else
113-
echo "-> Missing linux binary archive"
114-
exit
115-
fi
116-
117-
echo "-> Creating development Linux tar.gz file: $linux_dev_targz_file_path"
118-
cp "$linux_src_file_path" "$linux_dev_targz_file_path"
119-
echo "-> Linux development archive: $linux_dev_targz_file_path"
43+
echo "Creating macOS archives"
44+
45+
macos_targz_file_path_version_universal="$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.tar.gz"
46+
macos_targz_file_path_version_amd64="$DIST_DIR/slack_cli_${VERSION}_macOS_amd64.tar.gz"
47+
macos_targz_file_path_version_arm64="$DIST_DIR/slack_cli_${VERSION}_macOS_arm64.tar.gz"
48+
macos_targz_file_path_dev_universal="$DIST_DIR/slack_cli_dev_macOS_64-bit.tar.gz"
49+
macos_targz_file_path_dev_amd64="$DIST_DIR/slack_cli_dev_macOS_amd64.tar.gz"
50+
macos_targz_file_path_dev_arm64="$DIST_DIR/slack_cli_dev_macOS_arm64.tar.gz"
51+
macos_targz_file_path_latest_universal="$DIST_DIR/slack_cli_latest_macOS_64-bit.tar.gz"
52+
macos_targz_file_path_latest_amd64="$DIST_DIR/slack_cli_latest_macOS_amd64.tar.gz"
53+
macos_targz_file_path_latest_arm64="$DIST_DIR/slack_cli_latest_macOS_arm64.tar.gz"
54+
55+
macos_zip_file_path_universal="$DIST_DIR/slack_cli_${VERSION}_macOS_64-bit.zip"
56+
macos_zip_file_path_amd64="$DIST_DIR/slack_cli_${VERSION}_macOS_amd64.zip"
57+
macos_zip_file_path_arm64="$DIST_DIR/slack_cli_${VERSION}_macOS_arm64.zip"
58+
macos_zip_file_path_universal_legacy="$DIST_DIR/slack_cli_${VERSION}_macos.zip"
59+
60+
echo "-> Creating macOS versioned tar.gz files"
61+
unzip_tar "$macos_zip_file_path_universal" "$macos_targz_file_path_version_universal"
62+
unzip_tar "$macos_zip_file_path_amd64" "$macos_targz_file_path_version_amd64"
63+
unzip_tar "$macos_zip_file_path_arm64" "$macos_targz_file_path_version_arm64"
64+
ls -l "$DIST_DIR"/*_"$VERSION"_macOS*
65+
66+
echo "-> Creating macOS development tar.gz files"
67+
cp "$macos_targz_file_path_version_universal" "$macos_targz_file_path_dev_universal"
68+
cp "$macos_targz_file_path_version_amd64" "$macos_targz_file_path_dev_amd64"
69+
cp "$macos_targz_file_path_version_arm64" "$macos_targz_file_path_dev_arm64"
70+
ls -l "$DIST_DIR"/*dev_macOS*
71+
72+
echo "-> Creating macOS latest tar.gz files"
73+
cp "$macos_targz_file_path_version_universal" "$macos_targz_file_path_latest_universal"
74+
cp "$macos_targz_file_path_version_amd64" "$macos_targz_file_path_latest_amd64"
75+
cp "$macos_targz_file_path_version_arm64" "$macos_targz_file_path_latest_arm64"
76+
ls -l "$DIST_DIR"/*latest_macOS*
77+
78+
echo "-> Creating macOS legacy .zip file for auto-update"
79+
cp "$macos_zip_file_path_universal" "$macos_zip_file_path_universal_legacy"
80+
ls -l "$DIST_DIR"/*_macos.zip
81+
82+
echo "Creating Linux archives"
83+
84+
linux_targz_file_path_version="$DIST_DIR/slack_cli_${VERSION}_linux_64-bit.tar.gz"
85+
linux_targz_file_path_dev="$DIST_DIR/slack_cli_dev_linux_64-bit.tar.gz"
86+
linux_targz_file_path_latest="$DIST_DIR/slack_cli_latest_linux_64-bit.tar.gz"
87+
88+
echo "-> Creating Linux development tar.gz file"
89+
cp "$linux_targz_file_path_version" "$linux_targz_file_path_dev"
90+
ls -l "$DIST_DIR"/*dev_linux*
91+
92+
echo "-> Creating Linux production tar.gz file"
93+
cp "$linux_targz_file_path_version" "$linux_targz_file_path_latest"
94+
ls -l "$DIST_DIR"/*latest_linux*
95+
}
12096

121-
echo "-> Creating production Linux tar.gz file: $linux_prod_targz_file_path"
122-
cp "$linux_src_file_path" "$linux_prod_targz_file_path"
123-
echo "-> Linux development archive: $linux_prod_targz_file_path"
97+
# Repackage tarballs with the signed zip
98+
unzip_tar() {
99+
tmpdir="$(mktemp -d)"
100+
trap 'rm -rf "$tmpdir"' EXIT
101+
unzip "$1" -d "$tmpdir"
102+
mkdir "$tmpdir/bin"
103+
mv "$tmpdir/slack" "$tmpdir/bin/slack"
104+
tar -C "$tmpdir" -zcvf "$2" .
124105
}
125106

126107
main "$@"

0 commit comments

Comments
 (0)