Skip to content

Commit a20c89e

Browse files
committed
fix(scripts): address shellcheck/shfmt errs
Signed-off-by: Vaughn Dice <[email protected]>
1 parent 260577d commit a20c89e

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

scripts/bump-spin-formula.sh

+20-20
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@ SED_INPLACE='sed -i.bak'
1111
trap 'rm checksums.txt **/*.bak &>/dev/null' EXIT
1212

1313
usage() {
14-
echo "Usage: $0 <VERSION> [<FORMULA_PATH>]"
15-
echo "Updates the Spin Formula for the specified release version"
16-
echo "Example: $0 v3.0.0"
14+
echo "Usage: $0 <VERSION> [<FORMULA_PATH>]"
15+
echo "Updates the Spin Formula for the specified release version"
16+
echo "Example: $0 v3.0.0"
1717
}
1818

19-
if [ $# -ne 1 ]; then
20-
usage
21-
exit 1
19+
if [[ $# -ne 1 ]]; then
20+
usage
21+
exit 1
2222
fi
2323

2424
# Ensure version is prefixed with 'v' and an 'official' release
2525
if [[ ! "${VERSION}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
26-
echo "VERSION doesn't match v[0-9]+.[0-9]+.[0-9]+ and may be a prerelease; skipping."
27-
exit 1
26+
echo "VERSION doesn't match v[0-9]+.[0-9]+.[0-9]+ and may be a prerelease; skipping."
27+
exit 1
2828
fi
2929

3030
# Get the checksum file for the release
31-
wget -qO checksums.txt "https://github.com/fermyon/spin/releases/download/$VERSION/checksums-$VERSION.txt" || \
32-
(echo "Checksum file not found for version $VERSION" && exit 1)
31+
wget -qO checksums.txt "https://github.com/fermyon/spin/releases/download/${VERSION}/checksums-${VERSION}.txt" ||
32+
(echo "Checksum file not found for version ${VERSION}" && exit 1)
3333

3434
# Remove the 'v' prefix from the version
3535
ERSION="${VERSION:1}"
36-
$SED_INPLACE -e "s/version \"[^\"]*\"/version \"$ERSION\"/" $FORMULA
36+
${SED_INPLACE} -e "s/version \"[^\"]*\"/version \"${ERSION}\"/" "${FORMULA}"
3737
# Update the sha256 checksums for each OS/Arch
3838
while read -r line; do
39-
filename=$(echo "$line" | awk '{print $2}')
40-
sha256=$(echo "$line" | awk '{print $1}')
41-
os_arch=$(echo ${filename} | sed "s/spin-v${ERSION}-//g")
42-
if grep -q "$os_arch" $FORMULA; then
43-
$SED_INPLACE -E "/url \".*$os_arch\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"$sha256\"/; }" $FORMULA
44-
fi
45-
done < checksums.txt
46-
47-
echo "Formula updated to version $VERSION with new checksums."
39+
filename=$(echo "${line}" | awk '{print $2}')
40+
sha256=$(echo "${line}" | awk '{print $1}')
41+
os_arch="${filename//spin-v${ERSION}-/}"
42+
if grep -q "${os_arch}" "${FORMULA}"; then
43+
${SED_INPLACE} -E "/url \".*${os_arch}\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"${sha256}\"/; }" "${FORMULA}"
44+
fi
45+
done <checksums.txt
46+
47+
echo "Formula updated to version ${VERSION} with new checksums."

0 commit comments

Comments
 (0)