-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix updating of homebrew tap (AMD64 and ARM64)
- Loading branch information
Showing
2 changed files
with
46 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,17 @@ set -e | |
|
||
echo "[INF] Running $0" | ||
|
||
if [ "$HOMEBREW_TAP_DEPLOY_KEY" = "" ] || [ "$TAG" = "" ] || [ "$TRIPLET" = "" ]; then | ||
if [ "$HOMEBREW_TAP_DEPLOY_KEY" = "" ] || [ "$TAG" = "" ]; then | ||
echo "[ERR] One or more environment variable(s) are not set!" | ||
echo "[ERR] Set HOMEBREW_TAP_DEPLOY_KEY, TAG, and TRIPLET before running $0 script." | ||
echo "[ERR] Set HOMEBREW_TAP_DEPLOY_KEY and TAG before running $0 script." | ||
exit 1 | ||
fi | ||
|
||
TAR="zsv-$TAG-$TRIPLET.tar.gz" | ||
TAR_URL="https://github.com/liquidaty/zsv/releases/download/v$TAG/$TAR" | ||
AMD64_ZIP="zsv-$TAG-amd64-macosx-gcc.zip" | ||
AMD64_URL="https://github.com/liquidaty/zsv/releases/download/v$TAG/$AMD64_ZIP" | ||
ARM64_ZIP="zsv-$TAG-arm64-macosx-gcc.zip" | ||
ARM64_URL="https://github.com/liquidaty/zsv/releases/download/v$TAG/$AMD64_ZIP" | ||
|
||
HOMEBREW_TAP_REPO="[email protected]:liquidaty/homebrew-zsv.git" | ||
HOMEBREW_TAP_DIR="homebrew-zsv" | ||
HOMEBREW_TAP_FORMULA="formula/zsv.rb" | ||
|
@@ -21,20 +24,25 @@ echo "[INF] Updating homebrew tap" | |
|
||
echo "[INF] PWD: $PWD" | ||
echo "[INF] TAG: $TAG" | ||
echo "[INF] TAR: $TAR" | ||
echo "[INF] TAR_URL: $TAR_URL" | ||
echo "[INF] AMD64_ZIP: $AMD64_ZIP" | ||
echo "[INF] AMD64_URL: $AMD64_URL" | ||
echo "[INF] ARM64_ZIP: $ARM64_ZIP" | ||
echo "[INF] ARM64_URL: $ARM64_URL" | ||
echo "[INF] HOMEBREW_TAP_REPO: $HOMEBREW_TAP_REPO" | ||
echo "[INF] HOMEBREW_TAP_DIR: $HOMEBREW_TAP_DIR" | ||
echo "[INF] HOMEBREW_TAP_FORMULA: $HOMEBREW_TAP_FORMULA" | ||
|
||
echo "[INF] Downloading release tar file [$TAR_URL]" | ||
wget -q "$TAR_URL" | ||
ls -hl "$TAR" | ||
echo "[INF] Downloading release archives [$AMD64_URL, $ARM64_URL]" | ||
wget -q "$AMD64_URL" "$ARM64_URL" | ||
ls -hl "$AMD64_ZIP" "$ARM64_ZIP" | ||
|
||
echo "[INF] Calculating SHA256 hashes [$AMD64_ZIP, $ARM64_ZIP]" | ||
AMD64_HASH=$(openssl dgst -sha256 "$AMD64_ZIP" | cut -d ' ' -f2 | tr -d '\n') | ||
ARM64_HASH=$(openssl dgst -sha256 "$ARM64_ZIP" | cut -d ' ' -f2 | tr -d '\n') | ||
rm -f "$AMD64_ZIP" "$ARM64_ZIP" | ||
|
||
echo "[INF] Calculating SHA256 of $TAR" | ||
SHA256=$(openssl dgst -sha256 "$TAR" | cut -d ' ' -f2 | tr -d '\n') | ||
echo "[INF] SHA256: $SHA256" | ||
rm -f "$TAR" | ||
echo "[INF] AMD64_HASH: $AMD64_HASH" | ||
echo "[INF] ARM64_HASH: $ARM64_HASH" | ||
|
||
echo "[INF] Setting up GitHub credentials" | ||
echo "$HOMEBREW_TAP_DEPLOY_KEY" >$HOMEBREW_TAP_DEPLOY_KEY_FILE | ||
|
@@ -48,13 +56,14 @@ rm -rf "$HOMEBREW_TAP_DIR" | |
git clone "$HOMEBREW_TAP_REPO" | ||
cd "$HOMEBREW_TAP_DIR" | ||
|
||
echo "[INF] Replacing 'url' and 'sha256' fields [$HOMEBREW_TAP_FORMULA]" | ||
sed -i -e "s|url .*|url '$TAR_URL'|" $HOMEBREW_TAP_FORMULA | ||
sed -i -e "s|sha256 .*|sha256 '$SHA256'|" $HOMEBREW_TAP_FORMULA | ||
echo "[INF] Updating URLs and SHA256 hashes [$HOMEBREW_TAP_FORMULA]" | ||
sed -i -e "s|AMD64_URL = .*|AMD64_URL = '$AMD64_URL'|" "$HOMEBREW_TAP_FORMULA" | ||
sed -i -e "s|AMD64_HASH = .*|AMD64_HASH = '$AMD64_HASH'|" "$HOMEBREW_TAP_FORMULA" | ||
sed -i -e "s|ARM64_URL = .*|ARM64_URL = '$AMD64_URL'|" "$HOMEBREW_TAP_FORMULA" | ||
sed -i -e "s|ARM64_HASH = .*|ARM64_HASH = '$AMD64_HASH'|" "$HOMEBREW_TAP_FORMULA" | ||
|
||
DIFF=$(git diff "$HOMEBREW_TAP_FORMULA") | ||
if [ "$DIFF" = "" ]; then | ||
echo "[INF] 'url' and 'sha256' fields are the same." | ||
echo "[INF] Homebrew tap formula is already updated." | ||
echo "[INF] No changes required. Exiting!" | ||
exit 0 | ||
|
@@ -64,7 +73,7 @@ echo "[INF] --- git diff $HOMEBREW_TAP_FORMULA STARTS ---" | |
echo "$DIFF" | ||
echo "[INF] ---- git diff $HOMEBREW_TAP_FORMULA ENDS ----" | ||
|
||
echo "[INF] Commiting and pushing changes" | ||
echo "[INF] Committing and pushing changes" | ||
git add "$HOMEBREW_TAP_FORMULA" | ||
git commit -m "Automatic bump version to v$TAG." | ||
git push origin main | ||
|