diff --git a/.github/workflows/homebrew-bump.yml b/.github/workflows/homebrew-bump.yml index cb954da..bd32894 100644 --- a/.github/workflows/homebrew-bump.yml +++ b/.github/workflows/homebrew-bump.yml @@ -37,6 +37,7 @@ jobs: id: sha run: | echo "darwin_arm64=$(grep 'floci-darwin-arm64' sha256sums.txt | awk '{print $1}')" >> "$GITHUB_OUTPUT" + echo "darwin_amd64=$(grep 'floci-darwin-amd64' sha256sums.txt | awk '{print $1}')" >> "$GITHUB_OUTPUT" echo "linux_amd64=$(grep 'floci-linux-amd64' sha256sums.txt | awk '{print $1}')" >> "$GITHUB_OUTPUT" echo "linux_arm64=$(grep 'floci-linux-arm64' sha256sums.txt | awk '{print $1}')" >> "$GITHUB_OUTPUT" @@ -56,10 +57,12 @@ jobs: sed -i "s|releases/download/[^/]*/|releases/download/${VERSION}/|g" "$FORMULA" sed -i "s/{{VERSION}}/${VERSION}/g" "$FORMULA" sed -i "s/{{SHA256_DARWIN_ARM64}}/${{ steps.sha.outputs.darwin_arm64 }}/g" "$FORMULA" + sed -i "s/{{SHA256_DARWIN_AMD64}}/${{ steps.sha.outputs.darwin_amd64 }}/g" "$FORMULA" sed -i "s/{{SHA256_LINUX_AMD64}}/${{ steps.sha.outputs.linux_amd64 }}/g" "$FORMULA" sed -i "s/{{SHA256_LINUX_ARM64}}/${{ steps.sha.outputs.linux_arm64 }}/g" "$FORMULA" sed -i "/darwin-arm64/ { n; s/sha256 \".*\"/sha256 \"${{ steps.sha.outputs.darwin_arm64 }}\"/ }" "$FORMULA" + sed -i "/darwin-amd64/ { n; s/sha256 \".*\"/sha256 \"${{ steps.sha.outputs.darwin_amd64 }}\"/ }" "$FORMULA" sed -i "/linux-amd64/ { n; s/sha256 \".*\"/sha256 \"${{ steps.sha.outputs.linux_amd64 }}\"/ }" "$FORMULA" sed -i "/linux-arm64/ { n; s/sha256 \".*\"/sha256 \"${{ steps.sha.outputs.linux_arm64 }}\"/ }" "$FORMULA" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fca43f5..3f12f34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,6 +73,45 @@ jobs: name: floci-darwin-arm64 path: target/floci-darwin-arm64 + build-darwin-amd64: + name: Build — darwin/amd64 (Rosetta) + # GraalVM native-image cannot cross-compile architectures, and GitHub's Intel + # macOS runners (macos-13) queue for hours and are being deprecated — a past + # release sat 9.5h on macos-13 before being cancelled. Instead we run an + # x86_64 GraalVM under Rosetta 2 on the reliable Apple Silicon runner. + # setup-graalvm has no arch override, so the x86_64 JDK is installed manually. + runs-on: macos-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + + - name: Install Rosetta 2 + run: sudo softwareupdate --install-rosetta --agree-to-license + + - name: Install x86_64 GraalVM + run: | + curl -fsSL -o "$RUNNER_TEMP/graalvm-x64.tar.gz" \ + https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_macos-x64_bin.tar.gz + mkdir -p "$RUNNER_TEMP/graalvm-x64" + tar -xzf "$RUNNER_TEMP/graalvm-x64.tar.gz" -C "$RUNNER_TEMP/graalvm-x64" --strip-components 1 + echo "JAVA_HOME=$RUNNER_TEMP/graalvm-x64/Contents/Home" >> "$GITHUB_ENV" + echo "$RUNNER_TEMP/graalvm-x64/Contents/Home/bin" >> "$GITHUB_PATH" + + - name: Verify x86_64 toolchain + run: arch -x86_64 "$JAVA_HOME/bin/java" -XshowSettings:properties -version 2>&1 | grep 'os.arch' + + - name: Build native binary (x86_64 under Rosetta) + run: arch -x86_64 mvn clean package -Pnative -DskipTests -B + + - name: Verify binary is x86_64 + run: file target/floci | grep -q x86_64 + + - run: mv target/floci target/floci-darwin-amd64 + - uses: actions/upload-artifact@v4 + with: + name: floci-darwin-amd64 + path: target/floci-darwin-amd64 + build-windows-amd64: name: Build — windows/amd64 runs-on: windows-latest @@ -111,7 +150,7 @@ jobs: release: name: Create GitHub Release - needs: [build-linux-amd64, build-linux-arm64, build-darwin-arm64, build-windows-amd64, build-jar] + needs: [build-linux-amd64, build-linux-arm64, build-darwin-amd64, build-darwin-arm64, build-windows-amd64, build-jar] runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -159,6 +198,7 @@ jobs: files: | dist/floci-linux-amd64/floci-linux-amd64 dist/floci-linux-arm64/floci-linux-arm64 + dist/floci-darwin-amd64/floci-darwin-amd64 dist/floci-darwin-arm64/floci-darwin-arm64 dist/floci-windows-amd64/floci-windows-amd64.exe dist/floci-jar/floci.jar diff --git a/.github/workflows/test-darwin-amd64.yml b/.github/workflows/test-darwin-amd64.yml new file mode 100644 index 0000000..82829bf --- /dev/null +++ b/.github/workflows/test-darwin-amd64.yml @@ -0,0 +1,49 @@ +name: Test — darwin/amd64 (Rosetta) + +# TEMPORARY: manual smoke test for the x86_64-under-Rosetta native build used by +# release.yml's build-darwin-amd64 job. Trigger it from the Actions tab (or +# `gh workflow run`) to validate the toolchain without cutting a tag/release. +# Delete this file once the approach is confirmed working. + +on: + workflow_dispatch: + +permissions: + contents: read + +jobs: + build-darwin-amd64: + name: Build — darwin/amd64 (Rosetta) + runs-on: macos-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v4 + + - name: Install Rosetta 2 + run: sudo softwareupdate --install-rosetta --agree-to-license + + - name: Install x86_64 GraalVM + run: | + curl -fsSL -o "$RUNNER_TEMP/graalvm-x64.tar.gz" \ + https://download.oracle.com/graalvm/25/latest/graalvm-jdk-25_macos-x64_bin.tar.gz + mkdir -p "$RUNNER_TEMP/graalvm-x64" + tar -xzf "$RUNNER_TEMP/graalvm-x64.tar.gz" -C "$RUNNER_TEMP/graalvm-x64" --strip-components 1 + echo "JAVA_HOME=$RUNNER_TEMP/graalvm-x64/Contents/Home" >> "$GITHUB_ENV" + echo "$RUNNER_TEMP/graalvm-x64/Contents/Home/bin" >> "$GITHUB_PATH" + + - name: Verify x86_64 toolchain + run: | + arch -x86_64 "$JAVA_HOME/bin/java" -XshowSettings:properties -version 2>&1 | grep 'os.arch' + arch -x86_64 "$JAVA_HOME/bin/native-image" --version + + - name: Build native binary (x86_64 under Rosetta) + run: arch -x86_64 mvn clean package -Pnative -DskipTests -B + + - name: Verify binary is x86_64 + run: file target/floci | tee /dev/stderr | grep -q x86_64 + + - run: mv target/floci target/floci-darwin-amd64 + - uses: actions/upload-artifact@v4 + with: + name: floci-darwin-amd64 + path: target/floci-darwin-amd64 diff --git a/CHANGELOG.md b/CHANGELOG.md index a027adf..66ab892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ This project uses [Semantic Versioning](https://semver.org/). ### Added - `floci start` (and `floci az`/`floci gcp start`) now honor the standard `DOCKER_HOST` environment variable, so Podman, rootless setups, and remote Docker contexts work without assuming `/var/run/docker.sock`. `DOCKER_HOST` is resolved into a unix socket, remote TCP daemon, or Windows named pipe — unix sockets are bind-mounted, remote TCP daemons are passed through to the container via `DOCKER_HOST`. Precedence is `DOCKER_HOST` → `DOCKER_SOCK` (legacy override) → OS default. `floci doctor`'s `docker.socket` check reports the resolved endpoint ([#3](https://github.com/floci-io/floci-cli/issues/3)) +- Release ships a `darwin/amd64` (Intel macOS) native binary again — built with an x86_64 GraalVM under Rosetta 2 on the Apple Silicon runner, avoiding the unreliable/queue-bound `macos-13` Intel runner that previously caused the target to be dropped (a past release sat 9.5h on `macos-13` before being cancelled). The Homebrew formula bump again wires the `darwin/amd64` SHA, so `brew install` and the install script resolve a real Intel binary instead of 404ing ([#2](https://github.com/floci-io/floci-cli/issues/2)) +### Fixed + +- `install.sh` no longer reports a misleading "Checksum mismatch" when a download transiently fails. A failed `sha256sums.txt` fetch inside a command-substitution pipeline was masked by `set -e`, leaving the expected checksum empty and falsely flagging a mismatch against a correctly-downloaded binary. The installer now retries every download with backoff — an explicit loop (4 attempts by default, tunable via `FLOCI_DOWNLOAD_RETRIES`) that treats both transient HTTP errors and 0-byte responses as retryable, on top of `curl --retry` — fetches checksums to a file so download failures are caught, and emits distinct errors for "couldn't fetch checksum" vs. an actual mismatch. Adds `FLOCI_SKIP_CHECKSUM=1` to bypass verification (floci-io/floci#1236) ## [0.1.4] — 2026-06-02 diff --git a/installer/install.sh b/installer/install.sh index 53eb283..368fc02 100644 --- a/installer/install.sh +++ b/installer/install.sh @@ -6,6 +6,31 @@ VERSION="${FLOCI_CLI_VERSION:-latest}" INSTALL_DIR="${FLOCI_INSTALL_DIR:-/usr/local/bin}" BINARY="floci" REPO="floci-io/floci-cli" +SKIP_CHECKSUM="${FLOCI_SKIP_CHECKSUM:-0}" +DOWNLOAD_RETRIES="${FLOCI_DOWNLOAD_RETRIES:-4}" + +# Download $1 to $2, retrying on transient failures. GitHub's CDN intermittently +# returns 5xx (e.g. 504) on release assets, and can hand back a 0-byte body, so +# we wrap curl in our own loop with backoff: an empty file is treated as a +# failure and retried. curl's own --retry handles mid-transfer hiccups; the +# outer loop covers cases it doesn't and works uniformly across curl versions. +download() { + _url="$1" + _out="$2" + _attempt=1 + while :; do + if curl -fsSL --retry 2 --retry-delay 1 "$_url" -o "$_out" && [ -s "$_out" ]; then + return 0 + fi + if [ "$_attempt" -ge "$DOWNLOAD_RETRIES" ]; then + return 1 + fi + _delay=$((_attempt * 2)) + echo " download failed (attempt ${_attempt}/${DOWNLOAD_RETRIES}), retrying in ${_delay}s..." >&2 + sleep "$_delay" + _attempt=$((_attempt + 1)) + done +} detect_platform() { OS=$(uname -s | tr '[:upper:]' '[:lower:]') @@ -24,8 +49,20 @@ detect_platform() { } fetch_latest_version() { - curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ - | grep '"tag_name"' | sed 's/.*"tag_name": "\(.*\)".*/\1/' + _tmp=$(mktemp) + if ! download "https://api.github.com/repos/${REPO}/releases/latest" "$_tmp"; then + rm -f "$_tmp" + echo "Error: could not reach GitHub to determine the latest version." >&2 + echo "Check your connection, or pin a version with FLOCI_CLI_VERSION=." >&2 + exit 1 + fi + _version=$(grep '"tag_name"' "$_tmp" | sed 's/.*"tag_name": "\(.*\)".*/\1/') + rm -f "$_tmp" + if [ -z "$_version" ]; then + echo "Error: could not parse the latest version from the GitHub API response." >&2 + exit 1 + fi + echo "$_version" } main() { @@ -40,17 +77,45 @@ main() { TMP=$(mktemp) echo "Downloading floci ${VERSION} for ${PLATFORM}..." - curl -fsSL "$DOWNLOAD_URL" -o "$TMP" + if ! download "$DOWNLOAD_URL" "$TMP"; then + rm -f "$TMP" + echo "Error: failed to download the Floci binary from:" >&2 + echo " $DOWNLOAD_URL" >&2 + echo "GitHub may be returning a temporary error (e.g. HTTP 504). Please retry shortly." >&2 + exit 1 + fi chmod +x "$TMP" # Verify checksum if sha256sum is available - if command -v sha256sum >/dev/null 2>&1; then + if [ "$SKIP_CHECKSUM" != "1" ] && command -v sha256sum >/dev/null 2>&1; then SUMS_URL="https://github.com/${REPO}/releases/download/${VERSION}/sha256sums.txt" - EXPECTED=$(curl -fsSL "$SUMS_URL" | grep "floci-${PLATFORM}" | awk '{print $1}') + SUMS_TMP=$(mktemp) + # Fetch to a file so a failed download is caught here, not silently + # swallowed inside a pipeline (which would yield an empty expected sum + # and a misleading "checksum mismatch"). + if ! download "$SUMS_URL" "$SUMS_TMP"; then + rm -f "$TMP" "$SUMS_TMP" + echo "Error: failed to download checksums from:" >&2 + echo " $SUMS_URL" >&2 + echo "Cannot verify the binary's integrity. Please retry, or set" >&2 + echo "FLOCI_SKIP_CHECKSUM=1 to install without verification." >&2 + exit 1 + fi + EXPECTED=$(grep "floci-${PLATFORM}\$" "$SUMS_TMP" | awk '{print $1}') + rm -f "$SUMS_TMP" + if [ -z "$EXPECTED" ]; then + rm -f "$TMP" + echo "Error: no checksum entry for floci-${PLATFORM} in sha256sums.txt." >&2 + echo "Please report this at https://github.com/${REPO}/issues." >&2 + exit 1 + fi ACTUAL=$(sha256sum "$TMP" | awk '{print $1}') if [ "$EXPECTED" != "$ACTUAL" ]; then - echo "Checksum mismatch! Expected: $EXPECTED Got: $ACTUAL" >&2 rm -f "$TMP" + echo "Checksum mismatch for floci-${PLATFORM} — the download may be corrupted." >&2 + echo " expected: $EXPECTED" >&2 + echo " actual: $ACTUAL" >&2 + echo "Please retry the install." >&2 exit 1 fi echo "Checksum verified."