fix: use GitHub API to find Roc tarball URL (inconsistent naming) and fix default version to 0.0.0-alpha1
Build and Publish OCI Images / build-and-push (push) Failing after 4s
Build and Publish OCI Images / build-and-push (push) Failing after 4s
This commit is contained in:
+28
-4
@@ -11,16 +11,40 @@ case "$TARGETARCH" in
|
||||
*) echo "Unsupported architecture: $TARGETARCH" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
TARBALL="roc-linux_${ROC_ARCH}-${ROC_VERSION}.tar.gz"
|
||||
URL="https://github.com/roc-lang/roc/releases/download/${ROC_VERSION}/${TARBALL}"
|
||||
# Use the GitHub API to find the correct asset URL for this version + arch.
|
||||
# We can't construct the URL from the version string because Roc release
|
||||
# tarball naming is inconsistent across releases (e.g. 0.0.0-alpha1 uses
|
||||
# "roc-linux_x86_64-0-alpha1.tar.gz" while alpha4-rolling uses
|
||||
# "roc-linux_x86_64-alpha4-rolling.tar.gz").
|
||||
# awk is used instead of jq/python because neither is guaranteed in slim images.
|
||||
API_URL="https://api.github.com/repos/roc-lang/roc/releases/tags/${ROC_VERSION}"
|
||||
echo "Looking up release ${ROC_VERSION} via GitHub API..."
|
||||
curl -fsSL "$API_URL" -o /tmp/gh-release.json
|
||||
|
||||
ASSET_URL=$(awk -v arch="roc-linux_${ROC_ARCH}" '
|
||||
/"browser_download_url"/ {
|
||||
url = $2
|
||||
gsub(/[",]/, "", url)
|
||||
if (index(url, arch) > 0 && url ~ /\.tar\.gz$/) {
|
||||
print url
|
||||
exit
|
||||
}
|
||||
}
|
||||
' /tmp/gh-release.json)
|
||||
rm -f /tmp/gh-release.json
|
||||
|
||||
if [ -z "$ASSET_URL" ]; then
|
||||
echo "ERROR: No linux ${ROC_ARCH} tarball found for release ${ROC_VERSION}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Downloading Roc ${ROC_VERSION} for ${ROC_ARCH}..."
|
||||
curl -fsSL "$URL" -o /tmp/roc.tar.gz
|
||||
curl -fsSL "$ASSET_URL" -o /tmp/roc.tar.gz
|
||||
|
||||
echo "Extracting..."
|
||||
tar -xzf /tmp/roc.tar.gz -C /tmp/
|
||||
|
||||
# The tarball contains a single directory with an unpredictable nightly name
|
||||
# The tarball contains a single directory with an unpredictable name
|
||||
# e.g. roc_nightly-linux_x86_64-2025-09-09-d73ea109/
|
||||
EXTRACTED_DIR=$(find /tmp -maxdepth 1 -type d -name "roc_*" | head -1)
|
||||
if [ -z "$EXTRACTED_DIR" ]; then
|
||||
|
||||
Reference in New Issue
Block a user