Light, fluffy, and always free - The AWS Local Emulator alternative
chore(release): publish standalone floci-aws binaries as release assets (#5844)
Hector Ventura537092001226
diff --git a/.github/scripts/check-glibc-floor.sh b/.github/scripts/check-glibc-floor.shnew file mode 100755index 0000000000..578d319041--- /dev/null+++ b/.github/scripts/check-glibc-floor.sh@@ -0,0 +1,34 @@+#!/usr/bin/env bash+# check-glibc-floor.sh <binary> [floor]+#+# A Linux release binary links glibc dynamically and must run on glibc 2.34 (RHEL 9, Debian 12,+# Ubuntu 22.04, Amazon Linux 2023). Two checks, so a toolchain change that raises the floor fails+# the release instead of the user:+# 1. the newest GLIBC_x.y symbol version the binary requires is at most the floor (readelf reads+# any architecture's ELF, so this covers the arm64 builds too);+# 2. the binary starts in UBI 9, whose glibc is exactly 2.34 (skipped when Docker is absent).+set -euo pipefail++BIN=$1+FLOOR=${2:-2.34}++newest=$(readelf --version-info --wide "$BIN" | grep -o 'GLIBC_[0-9][0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -1)+if [ -z "$newest" ]; then+ echo "FAIL: no GLIBC_ symbol versions found in $BIN"+ exit 1+fi+if [ "$(printf '%s\n%s\n' "$newest" "$FLOOR" | sort -V | tail -1)" != "$FLOOR" ]; then+ echo "FAIL: $BIN requires GLIBC_$newest, newer than the $FLOOR floor"+ exit 1+fi+echo "ok: newest required glibc symbol is GLIBC_$newest (floor $FLOOR)"++if ! command -v docker >/dev/null 2>&1; then+ echo "skip: no Docker, start check not run"+ exit 0+fi+docker run --rm -v "$(cd "$(dirname "$BIN")" && pwd)/$(basename "$BIN"):/floci-aws:ro" \+ registry.access.redhat.com/ubi9/ubi:latest sh -c \+ '/floci-aws -Dquarkus.http.port=0 > /tmp/out 2>&1 & pid=$!; sleep 5+ if kill -0 "$pid" 2>/dev/null; then echo "ok: starts on $(ldd --version | head -1)"; kill "$pid"+ else cat /tmp/out; exit 1; fi'diff --git a/.github/scripts/smoke-binary.sh b/.github/scripts/smoke-binary.shnew file mode 100755index 0000000000..35885540d3--- /dev/null+++ b/.github/scripts/smoke-binary.sh@@ -0,0 +1,121 @@+#!/usr/bin/env bash+# Smoke-tests one standalone floci-aws binary before it is published.+#+# smoke-binary.sh <binary> <expected-version>+#+# Starts the binary on a free port with in-memory storage and a scratch data+# directory, then checks that:+# 1. /_floci/health answers and reports <expected-version> (never "dev"),+# 2. SQS and DynamoDB round-trip through the AWS CLI (no Docker needed),+# 3. SIGTERM stops it cleanly within the grace period (skipped on Windows,+# where Git Bash cannot deliver a console signal to a native process).+# Requires bash, curl, Python and the AWS CLI. Exits non-zero on the first failure.+set -euo pipefail++BIN=${1:?usage: smoke-binary.sh <binary> <expected-version>}+EXPECTED=${2:?usage: smoke-binary.sh <binary> <expected-version>}+GRACE_SECONDS=${SMOKE_GRACE_SECONDS:-30}++case "$(uname -s)" in+ MINGW*|MSYS*|CYGWIN*) WINDOWS=true ;;+ *) WINDOWS=false ;;+esac++# Windows runners ship python, not python3.+PYTHON=$(command -v python3 || command -v python)++free_port() {+ "$PYTHON" -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1", 0)); print(s.getsockname()[1]); s.close()'+}++PORT=${SMOKE_PORT:-$(free_port)}+WORK=$(mktemp -d)+LOG="$WORK/floci.log"+ENDPOINT="http://127.0.0.1:$PORT"+PID=""++cleanup() {+ if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then+ kill -9 "$PID" 2>/dev/null || true+ fi+ rm -rf "$WORK"+}+trap cleanup EXIT++fail() {+ echo "FAIL: $*" >&2+ echo "--- floci log (last 60 lines) ---" >&2+ tail -n 60 "$LOG" >&2 || true+ exit 1+}++aws_local() {+ AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=us-east-1 AWS_PAGER="" \+ aws --endpoint-url "$ENDPOINT" "$@"+}++chmod +x "$BIN" 2>/dev/null || true+echo "smoke: $BIN on port $PORT, expecting version $EXPECTED"++FLOCI_STORAGE_MODE=memory \+FLOCI_STORAGE_PERSISTENT_PATH="$WORK/data" \+FLOCI_PORT="$PORT" \+QUARKUS_HTTP_PORT="$PORT" \+ "$BIN" > "$LOG" 2>&1 &+PID=$!++for _ in $(seq 1 120); do+ if curl -sf "$ENDPOINT/_floci/health" > "$WORK/health.json" 2>/dev/null; then+ break+ fi+ kill -0 "$PID" 2>/dev/null || fail "the binary exited before answering /_floci/health"+ sleep 0.5+done+[ -s "$WORK/health.json" ] || fail "/_floci/health did not answer within 60s"++VERSION=$("$PYTHON" -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' "$WORK/health.json")+[ "$VERSION" = "$EXPECTED" ] || fail "/_floci/health reports version '$VERSION', expected '$EXPECTED'"+echo "ok: version $VERSION"++QUEUE_URL=$(aws_local sqs create-queue --queue-name smoke --query QueueUrl --output text) \+ || fail "sqs create-queue"+aws_local sqs send-message --queue-url "$QUEUE_URL" --message-body hello > /dev/null || fail "sqs send-message"+BODY=$(aws_local sqs receive-message --queue-url "$QUEUE_URL" --query 'Messages[0].Body' --output text) \+ || fail "sqs receive-message"+[ "$BODY" = "hello" ] || fail "sqs round trip returned '$BODY'"+echo "ok: sqs"++aws_local dynamodb create-table --table-name smoke --billing-mode PAY_PER_REQUEST \+ --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH \+ > /dev/null || fail "dynamodb create-table"+aws_local dynamodb put-item --table-name smoke --item '{"id":{"S":"1"},"v":{"S":"world"}}' || fail "dynamodb put-item"+VALUE=$(aws_local dynamodb get-item --table-name smoke --key '{"id":{"S":"1"}}' --query 'Item.v.S' --output text) \+ || fail "dynamodb get-item"+[ "$VALUE" = "world" ] || fail "dynamodb round trip returned '$VALUE'"+echo "ok: dynamodb"++if [ "$WINDOWS" = true ]; then+ echo "skip: graceful-shutdown check on Windows"+ exit 0+fi++kill -TERM "$PID"+for _ in $(seq 1 $((GRACE_SECONDS * 2))); do+ kill -0 "$PID" 2>/dev/null || break+ sleep 0.5+done+if kill -0 "$PID" 2>/dev/null; then+ fail "still running ${GRACE_SECONDS}s after SIGTERM"+fi+set +e+wait "$PID"+STATUS=$?+set -e+PID=""+# A JVM-style exit on SIGTERM is 143 (128 + 15); Quarkus exits 0 after a clean shutdown.+case "$STATUS" in+ 0|143) echo "ok: stopped on SIGTERM (exit $STATUS)" ;;+ *) fail "exit status $STATUS after SIGTERM" ;;+esac+grep -q "stopped in" "$LOG" || fail "no Quarkus 'stopped in' line after SIGTERM"+echo "smoke passed: $BIN"diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex c39f2bde95..37eb26823c 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -2,7 +2,8 @@ name: Release# Triggered when a version tag (e.g. 1.2.3) is pushed.# Builds native (amd64 + arm64) Docker images and pushes them to Docker Hub-# and Amazon ECR Public.+# and Amazon ECR Public, and publishes standalone floci-aws binaries for Linux,+# macOS and Windows as GitHub Release assets.## Published tags:# Native: floci/floci:1.2.3 floci/floci:latest@@ -57,6 +58,17 @@ jobs:# The flag only exists on Mandrel, so it is passed here rather than in application.yml.run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-march=x86-64-v2,-H:-AOTSingleCallsiteInline"+ - name: Smoke-test the standalone binary+ # The same binary is published as a release asset (publish-binaries), so it is checked+ # the way a user runs it: on the host, no Docker image around it.+ run: .github/scripts/smoke-binary.sh "$(ls target/*-runner)" "$GITHUB_REF_NAME"++ - name: Check the glibc floor of the standalone binary+ # The release asset links glibc dynamically and must run on 2.34 (RHEL 9, Debian 12,+ # Ubuntu 22.04, Amazon Linux 2023). The script checks the symbol versions it requires and+ # starts it in UBI 9, whose glibc is exactly 2.34.+ run: .github/scripts/check-glibc-floor.sh "$(ls target/*-runner)"+- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:name: native-amd64@@ -65,7 +77,8 @@ jobs:target/*.propertiestarget/*.soif-no-files-found: warn- retention-days: 1+ # Long enough to re-run publish-binaries on its own after a failure.+ retention-days: 7# ── Build native artifact — arm64 ────────────────────────────────────────build-native-arm64:@@ -91,6 +104,14 @@ jobs:# The flag only exists on Mandrel, so it is passed here rather than in application.yml.run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-H:-AOTSingleCallsiteInline"+ - name: Smoke-test the standalone binary+ # The same binary is published as a release asset (publish-binaries), so it is checked+ # the way a user runs it: on the host, no Docker image around it.+ run: .github/scripts/smoke-binary.sh "$(ls target/*-runner)" "$GITHUB_REF_NAME"++ - name: Check the glibc floor of the standalone binary+ run: .github/scripts/check-glibc-floor.sh "$(ls target/*-runner)"+- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:name: native-arm64@@ -99,7 +120,8 @@ jobs:target/*.propertiestarget/*.soif-no-files-found: warn- retention-days: 1+ # Long enough to re-run publish-binaries on its own after a failure.+ retention-days: 7# ── Build baseline native artifact — arm64 only ─────────────────────────build-native-arm64-baseline:@@ -123,6 +145,14 @@ jobs:# inherit optional AArch64 features (notably LSE) from the GitHub-hosted build runner.run: mvn clean package -Dnative -DskipTests -B -Dquarkus.native.additional-build-args-append="-march=armv8-a,-H:-AOTSingleCallsiteInline"+ - name: Smoke-test the standalone binary+ # The same binary is published as a release asset (publish-binaries), so it is checked+ # the way a user runs it: on the host, no Docker image around it.+ run: .github/scripts/smoke-binary.sh "$(ls target/*-runner)" "$GITHUB_REF_NAME"++ - name: Check the glibc floor of the standalone binary+ run: .github/scripts/check-glibc-floor.sh "$(ls target/*-runner)"+- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:name: native-arm64-baseline@@ -131,7 +161,199 @@ jobs:target/*.propertiestarget/*.soif-no-files-found: warn- retention-days: 1+ # Long enough to re-run publish-binaries on its own after a failure.+ retention-days: 7++ # ── Build standalone binaries — macOS and Windows ───────────────────────+ # The Linux release binaries are the native-amd64, native-arm64 and native-arm64-baseline+ # artifacts above, which also go into the images. macOS and Windows are built only for the+ # release assets. Mandrel has no macOS distribution, so both use GraalVM Community, which has+ # no -H:-AOTSingleCallsiteInline option to pass.+ build-binary-darwin-arm64:+ name: Build standalone binary (darwin-arm64)+ runs-on: macos-latest+ timeout-minutes: 60++ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1++ - uses: graalvm/setup-graalvm@27b360dbb857524eaf0b4c4cef364d38e5b4f173 # v1+ with:+ java-version: '25'+ distribution: 'graalvm-community'+ cache: maven+ github-token: ${{ secrets.GITHUB_TOKEN }}++ - name: Build native executable+ run: mvn clean package -Dnative -DskipTests -B++ - name: Smoke-test the standalone binary+ run: .github/scripts/smoke-binary.sh "$(ls target/*-runner)" "$GITHUB_REF_NAME"++ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: binary-darwin-arm64+ path: target/*-runner+ if-no-files-found: error+ retention-days: 7++ build-binary-darwin-amd64:+ name: Build standalone binary (darwin-amd64, Rosetta)+ # native-image cannot cross-compile, and Intel macOS runners queue for hours, so an x86_64+ # GraalVM runs under Rosetta 2 on the Apple Silicon runner (floci-cli's recipe).+ # setup-graalvm has no architecture override, so the x86_64 JDK is installed by hand: GraalVM+ # Community, like the other binaries, pinned to 25.0.1 (the last release with a macOS x64 build)+ # and checked against its published SHA-256 before anything built with it is signed.+ runs-on: macos-latest+ timeout-minutes: 90++ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1++ - name: Install Rosetta 2+ run: sudo softwareupdate --install-rosetta --agree-to-license++ - name: Install x86_64 GraalVM+ env:+ GRAALVM_X64_URL: https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-25.0.1/graalvm-community-jdk-25.0.1_macos-x64_bin.tar.gz+ GRAALVM_X64_SHA256: a3d895b4cd1c783badbd277ec70409806bd4102fca0d2a60dbaeb0bab41aec30+ run: |+ curl -fsSL -o "$RUNNER_TEMP/graalvm-x64.tar.gz" "$GRAALVM_X64_URL"+ echo "$GRAALVM_X64_SHA256 $RUNNER_TEMP/graalvm-x64.tar.gz" | shasum -a 256 -c -+ 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 "GRAALVM_HOME=$RUNNER_TEMP/graalvm-x64/Contents/Home" >> "$GITHUB_ENV"+ echo "$RUNNER_TEMP/graalvm-x64/Contents/Home/bin" >> "$GITHUB_PATH"++ - name: Build native executable (x86_64 under Rosetta)+ run: arch -x86_64 mvn clean package -Dnative -DskipTests -B++ - name: Verify the binary is x86_64+ run: file target/*-runner | grep -q x86_64++ - name: Smoke-test the standalone binary+ run: arch -x86_64 .github/scripts/smoke-binary.sh "$(ls target/*-runner)" "$GITHUB_REF_NAME"++ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: binary-darwin-amd64+ path: target/*-runner+ if-no-files-found: error+ retention-days: 7++ build-binary-windows-amd64:+ name: Build standalone binary (windows-amd64)+ runs-on: windows-latest+ timeout-minutes: 90++ steps:+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1++ - uses: graalvm/setup-graalvm@27b360dbb857524eaf0b4c4cef364d38e5b4f173 # v1+ with:+ java-version: '25'+ distribution: 'graalvm-community'+ cache: maven+ github-token: ${{ secrets.GITHUB_TOKEN }}++ - name: Build native executable+ # Keeps the Windows snappy-java and JNA dispatch libraries every other build excludes+ # (see quarkus.native.resources in application.yml).+ shell: bash+ run: >-+ mvn clean package -Dnative -DskipTests -B+ "-Dfloci.native.windows-jni-include=*"+ -Dfloci.native.windows-jni-exclude=none++ - name: Smoke-test the standalone binary+ shell: bash+ run: .github/scripts/smoke-binary.sh "$(ls target/*-runner.exe)" "$GITHUB_REF_NAME"++ - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: binary-windows-amd64+ path: target/*-runner.exe+ if-no-files-found: error+ retention-days: 7++ # ── Publish standalone binaries to the GitHub Release ────────────────────+ # semantic-release pushes this tag and then creates the release (notes only); the upload step+ # waits for the release to exist. This job adds+ # one raw executable per platform, sha256sums.txt, a keyless cosign bundle per file, and a+ # GitHub build-provenance attestation. It is the only job that writes to the release.+ # Verify a download with:+ # sha256sum --ignore-missing -c sha256sums.txt+ # cosign verify-blob floci-aws-linux-amd64 --bundle floci-aws-linux-amd64.sigstore.json \+ # --certificate-identity-regexp '^https://github.com/floci-io/floci/.github/workflows/release.yml@' \+ # --certificate-oidc-issuer https://token.actions.githubusercontent.com+ # gh attestation verify floci-aws-linux-amd64 --repo floci-io/floci+ publish-binaries:+ name: Publish standalone binaries+ needs:+ - build-native-amd64+ - build-native-arm64+ - build-native-arm64-baseline+ - build-binary-darwin-arm64+ - build-binary-darwin-amd64+ - build-binary-windows-amd64+ runs-on: ubuntu-latest+ timeout-minutes: 20++ permissions:+ contents: write+ id-token: write+ attestations: write++ steps:+ - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2+ with:+ path: artifacts++ - name: Stage the release assets+ run: |+ set -euo pipefail+ mkdir dist+ stage() { local src=("artifacts/$1"/*-runner*); install -m 755 "${src[0]}" "dist/$2"; }+ stage native-amd64 floci-aws-linux-amd64+ stage native-arm64 floci-aws-linux-arm64+ stage native-arm64-baseline floci-aws-linux-arm64-baseline+ stage binary-darwin-arm64 floci-aws-darwin-arm64+ stage binary-darwin-amd64 floci-aws-darwin-amd64+ stage binary-windows-amd64 floci-aws-windows-amd64.exe+ (cd dist && sha256sum floci-aws-* > sha256sums.txt)+ ls -l dist++ - name: Install Cosign+ uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2+ with:+ cosign-release: 'v3.1.3'++ - name: Sign the release assets+ working-directory: dist+ run: |+ for f in floci-aws-* sha256sums.txt; do+ cosign sign-blob --yes --bundle "$f.sigstore.json" "$f"+ done++ - name: Attest build provenance+ uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2+ with:+ subject-path: dist/floci-aws-*++ - name: Upload to the GitHub Release+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ GH_REPO: ${{ github.repository }}+ # The tag starts this workflow before semantic-release creates the GitHub Release, so wait+ # for it (up to 10 minutes) instead of failing the upload. --clobber makes a re-run idempotent.+ run: |+ for _ in $(seq 1 30); do+ gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1 && break+ echo "waiting for the $GITHUB_REF_NAME release to exist"; sleep 20+ done+ gh release view "$GITHUB_REF_NAME" > /dev/null || { echo "::error::release $GITHUB_REF_NAME not found after 10 minutes"; exit 1; }+ gh release upload "$GITHUB_REF_NAME" dist/* --clobber# ── Push native + compat Docker images ───────────────────────────────────push-native:diff --git a/Makefile b/Makefileindex 6e47d28be1..d4082aed84 100644--- a/Makefile+++ b/Makefile@@ -92,11 +92,11 @@ run-native: ## Run the host binary from native-host on port 4566, state under ./@file "$(NATIVE_BIN)" | grep -q ELF && [ "$$(uname -s)" != Linux ] && { echo "$(NATIVE_BIN) is a Linux binary from 'make native'; run 'make native-host' for this machine"; exit 1; } || true$(NATIVE_BIN)-native-install: ## Copy the host binary to $(PREFIX)/bin/floci (PREFIX defaults to ~/.local)+native-install: ## Copy the host binary to $(PREFIX)/bin/floci-aws (PREFIX defaults to ~/.local); `floci` is the CLI@test -n "$(NATIVE_BIN)" || { echo "no target/*-runner: run 'make native-host' first"; exit 1; }mkdir -p $(PREFIX)/bin- cp "$(NATIVE_BIN)" $(PREFIX)/bin/floci- @echo "installed $(PREFIX)/bin/floci"+ cp "$(NATIVE_BIN)" $(PREFIX)/bin/floci-aws+ @echo "installed $(PREFIX)/bin/floci-aws"native-image: ## Package native/$(ARCH)/ as $(NATIVE_IMAGE) with docker/Dockerfile.native-package@test -f native/$(ARCH)/application || { echo "native/$(ARCH)/application is missing: run 'make native' first"; exit 1; }diff --git a/docs/getting-started/installation.md b/docs/getting-started/installation.mdindex 2c02cfda49..6d126f0735 100644--- a/docs/getting-started/installation.md+++ b/docs/getting-started/installation.md@@ -92,7 +92,7 @@ To run Floci as a plain binary on your machine, install GraalVM or Mandrel with```bashmake native-host # target/floci-<version>-runner for this machine, no Dockermake run-native # start it on port 4566, state under ./data-make native-install # copy it to ~/.local/bin/floci (PREFIX=/usr/local to change)+make native-install # copy it to ~/.local/bin/floci-aws (PREFIX=/usr/local to change)```On Mandrel 25.0.4 and later the build needs `-H:-AOTSingleCallsiteInline`: Quarkus 3.39 turns