Skip to content

Commit

Permalink
fix(scripts): address shellcheck errs
Browse files Browse the repository at this point in the history
Signed-off-by: Vaughn Dice <vaughn.dice@fermyon.com>
  • Loading branch information
vdice committed Jun 20, 2024
1 parent 260577d commit 96e9bdb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions scripts/bump-spin-formula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ usage() {
echo "Example: $0 v3.0.0"
}

if [ $# -ne 1 ]; then
if [[ $# -ne 1 ]]; then
usage
exit 1
fi
Expand All @@ -28,20 +28,20 @@ if [[ ! "${VERSION}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then
fi

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

# Remove the 'v' prefix from the version
ERSION="${VERSION:1}"
$SED_INPLACE -e "s/version \"[^\"]*\"/version \"$ERSION\"/" $FORMULA
${SED_INPLACE} -e "s/version \"[^\"]*\"/version \"${ERSION}\"/" "${FORMULA}"
# Update the sha256 checksums for each OS/Arch
while read -r line; do
filename=$(echo "$line" | awk '{print $2}')
sha256=$(echo "$line" | awk '{print $1}')
os_arch=$(echo ${filename} | sed "s/spin-v${ERSION}-//g")
if grep -q "$os_arch" $FORMULA; then
$SED_INPLACE -E "/url \".*$os_arch\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"$sha256\"/; }" $FORMULA
filename=$(echo "${line}" | awk '{print $2}')
sha256=$(echo "${line}" | awk '{print $1}')
os_arch="${filename//spin-v${ERSION}-/}"
if grep -q "${os_arch}" "${FORMULA}"; then
${SED_INPLACE} -E "/url \".*${os_arch}\"/ { n; s/sha256 \"[^\"]*\"/sha256 \"${sha256}\"/; }" "${FORMULA}"
fi
done < checksums.txt

echo "Formula updated to version $VERSION with new checksums."
echo "Formula updated to version ${VERSION} with new checksums."

0 comments on commit 96e9bdb

Please sign in to comment.