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:
+1
-1
@@ -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/*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
+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