From 6c6e087b55a9032c87c9dafdeb8b87297bcef40e Mon Sep 17 00:00:00 2001 From: James Brechtel Date: Thu, 4 Jun 2026 15:35:52 -0400 Subject: [PATCH] fix: use GitHub API to find Roc tarball URL (inconsistent naming) and fix default version to 0.0.0-alpha1 --- Containerfile | 2 +- Makefile | 2 +- scripts/{build.sh => build} | 5 +++-- scripts/download-roc.sh | 32 ++++++++++++++++++++++++++++---- 4 files changed, 33 insertions(+), 8 deletions(-) rename scripts/{build.sh => build} (89%) diff --git a/Containerfile b/Containerfile index 1b3d7d5..f8c23f7 100644 --- a/Containerfile +++ b/Containerfile @@ -1,7 +1,7 @@ # Roc compiler base image # Provides just the Roc compiler binary and WASI runtime library. -ARG ROC_VERSION=0.0.0-alpha2 +ARG ROC_VERSION=0.0.0-alpha1 FROM debian:bookworm-slim AS curl-stage RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/* diff --git a/Makefile b/Makefile index 7c2b8f7..7956d46 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -ROC_VERSION ?= 0.0.0-alpha2 +ROC_VERSION ?= 0.0.0-alpha1 REGISTRY ?= git.roo.lol/jbrechtel # Use podman by default; override with: make BUILD_CMD=docker BUILD_CMD ?= podman diff --git a/scripts/build.sh b/scripts/build similarity index 89% rename from scripts/build.sh rename to scripts/build index fbeb88e..444c617 100755 --- a/scripts/build.sh +++ b/scripts/build @@ -4,7 +4,8 @@ # Usage: # ./scripts/build.sh [roc-version] # -# Default ROC_VERSION is "0.0.0-alpha2". +# Default ROC_VERSION is "0.0.0-alpha1". +# Valid values: 0.0.0-alpha1, 0.0.0-alpha2-rolling, alpha3-rolling, alpha4-rolling # Uses podman by default. Override with: BUILD_CMD=docker ./scripts/build.sh # # Builds all three targets: base, dev, ci @@ -15,7 +16,7 @@ set -euo pipefail -ROC_VERSION="${1:-0.0.0-alpha2}" +ROC_VERSION="${1:-0.0.0-alpha1}" REGISTRY="${REGISTRY:-git.roo.lol/jbrechtel}" BUILD_CMD="${BUILD_CMD:-podman}" BUILD_FLAGS="-f Containerfile" diff --git a/scripts/download-roc.sh b/scripts/download-roc.sh index 23fdd98..d01b865 100755 --- a/scripts/download-roc.sh +++ b/scripts/download-roc.sh @@ -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