11#! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ # Expected files that must be present after downloads
5+ EXPECTED_NODE_TARBALLS=(
6+ " node-*-linux-x64-pc-LATEST.tar.xz"
7+ " node-*-linux-arm64-pc-LATEST.tar.xz"
8+ " node-*-darwin-x64-pc-LATEST.tar.xz"
9+ " node-*-darwin-arm64-pc-LATEST.tar.xz"
10+ )
11+
12+ EXPECTED_FIBERS_BINARIES=(
13+ " linux-x64-*.tar.gz"
14+ " linux-arm64-*.tar.gz"
15+ " darwin-x64-*.tar.gz"
16+ " darwin-arm64-*.tar.gz"
17+ )
18+
19+ check_files_exist () {
20+ local pattern=" $1 "
21+ local description=" $2 "
22+ # shellcheck disable=SC2086
23+ if ! ls $pattern 1> /dev/null 2>&1 ; then
24+ echo " ERROR: Missing expected file matching pattern: $pattern ($description )" >&2
25+ return 1
26+ fi
27+ echo " ✓ Found: $pattern "
28+ }
229
330mkdir stage
4- cd stage || exit
31+ cd stage || exit 1
532
633TIMESTAMP=$( date ' +%Y%m%d.%H%M' )
734
835echo " Current timestamp is $TIMESTAMP "
36+ echo " "
37+ echo " === Downloading Node.js release artifacts ==="
938
1039gh release download -p " *.gz"
1140gh release download -p " *.xz"
1241
13- curl " https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz
42+ echo " "
43+ echo " === Validating Node.js tarballs ==="
44+ for pattern in " ${EXPECTED_NODE_TARBALLS[@]} " ; do
45+ check_files_exist " $pattern " " Node.js tarball"
46+ done
47+
48+ echo " "
49+ echo " === Validating fibers binaries from release ==="
50+ for pattern in " ${EXPECTED_FIBERS_BINARIES[@]} " ; do
51+ check_files_exist " $pattern " " fibers binary"
52+ done
53+
54+ echo " "
55+ echo " === Downloading fibers package from S3 ==="
56+ curl --fail -sS " https://asana-oss-cache.s3.us-east-1.amazonaws.com/node-fibers/fibers-5.0.4.pc.tgz" --output fibers-5.0.4.tar.gz
57+
58+ if [[ ! -f fibers-5.0.4.tar.gz ]]; then
59+ echo " ERROR: Failed to download fibers package from S3" >&2
60+ exit 1
61+ fi
62+ echo " ✓ Downloaded fibers-5.0.4.tar.gz"
63+
1464tar -xzf fibers-5.0.4.tar.gz
1565
66+ if [[ ! -d package ]]; then
67+ echo " ERROR: fibers tarball did not contain expected 'package' directory" >&2
68+ exit 1
69+ fi
70+
71+ echo " "
72+ echo " === Extracting fibers binaries into package ==="
1673find . -name " *.gz" | while read -r a
1774do
75+ echo " Extracting: $a "
1876 tar -xzf " $a " -C package/bin
1977 rm " $a "
2078done
@@ -27,6 +85,9 @@ UNIQUE="pc-${TIMESTAMP}-${SHORT_HASH}"
2785
2886mv temp.tgz " fibers-5.0.4-${UNIQUE} .tgz"
2987
88+ echo " "
89+ echo " === Processing Node.js tarballs ==="
90+ processed_count=0
3091for file in * .tar.xz; do
3192 if [[ " $file " == * -LATEST.tar.xz ]]; then
3293 base=" ${file% -LATEST.tar.xz} "
@@ -43,28 +104,35 @@ for file in *.tar.xz; do
43104
44105 echo " Target Dir: $target_dir "
45106 mkdir " $target_dir "
46- tar -xzf " $new_name " -C " $target_dir "
47- mv " $target_dir /usr/local/* " " $target_dir "
48- rm -fr " $target_dir /usr/local "
107+ tar -xJf " $new_name " -C " $target_dir "
108+ mv " $target_dir /usr/local/" * " $target_dir / "
109+ rm -fr " $target_dir /usr"
49110
50111 tar -cJf " $new_name " " $target_dir "
51112
52113 rm -fr " $target_dir "
53114
54- echo " ✅ Done: Archive now contains:"
115+ echo " ✓ Done: Archive now contains:"
55116 tar -tf " $new_name " | head
56-
117+ echo " "
118+ (( processed_count++ ))
57119 else
58120 echo " Warning: Skipped $new_name due to unexpected filename format."
59121 fi
60122 fi
61123done
62124
125+ if [[ $processed_count -lt 4 ]]; then
126+ echo " ERROR: Expected to process at least 4 Node.js tarballs, but only processed $processed_count " >&2
127+ exit 1
128+ fi
63129
64130cd ..
65131mv stage " node-${UNIQUE} "
66132
133+ echo " "
134+ echo " === SUCCESS ==="
67135echo " Files are in node-${UNIQUE} , please upload to s3"
68-
69-
70-
136+ echo " "
137+ echo " Final contents: "
138+ ls -la " node- ${UNIQUE} / "
0 commit comments