diff --git a/.github/workflows/_publish-registry.yml b/.github/workflows/_publish-registry.yml index 7f685c7ed..071e0ebf5 100644 --- a/.github/workflows/_publish-registry.yml +++ b/.github/workflows/_publish-registry.yml @@ -97,6 +97,9 @@ jobs: env: WORKER: ${{ inputs.worker }} BIN: ${{ inputs.bin }} + DEPLOY: ${{ inputs.deploy }} + TAG: ${{ inputs.tag }} + REPO_URL: ${{ format('https://github.com/{0}', github.repository) }} run: | set -euo pipefail mode=$(python3 - <<'PY' @@ -104,6 +107,7 @@ jobs: import yaml worker = os.environ["WORKER"] + deploy = os.environ.get("DEPLOY", "") manifest_path = f"{worker}/iii.worker.yaml" manifest = yaml.safe_load(open(manifest_path, encoding="utf-8").read()) or {} scripts = manifest.get("scripts") or {} @@ -112,7 +116,9 @@ jobs: has_runtime = bool(runtime.get("kind") or runtime.get("language")) language = str(manifest.get("language") or "").strip().lower() - if has_scripts_start or has_runtime: + if deploy == "binary": + print("release-binary") + elif has_scripts_start or has_runtime: print("iii-add") elif language == "rust": print("cargo-run") @@ -125,6 +131,29 @@ jobs: iii-add) iii worker add "./$WORKER" --force --reset-config --wait ;; + release-binary) + bin_name="${BIN:-$WORKER}" + asset_url="$REPO_URL/releases/download/$TAG/${bin_name}-x86_64-unknown-linux-gnu.tar.gz" + echo "Fetching prebuilt worker: $asset_url" + curl -fsSL "$asset_url" -o /tmp/worker-bin.tar.gz + tar -xzf /tmp/worker-bin.tar.gz -C /tmp/ + bin_path="/tmp/${bin_name}" + chmod +x "$bin_path" + + worker_log="worker-$WORKER.log" + pushd "$WORKER" >/dev/null + echo "Starting local worker with: (cd $WORKER && $bin_path)" + "$bin_path" > "../$worker_log" 2>&1 & + echo "$!" > ../worker.pid + popd >/dev/null + + sleep 2 + if ! kill -0 "$(cat worker.pid)" 2>/dev/null; then + echo "::error::$WORKER exited before interface collection" + cat "$worker_log" || true + exit 1 + fi + ;; cargo-run) if [[ ! -f "$WORKER/Cargo.toml" ]]; then echo "::error::$WORKER is a Rust worker but $WORKER/Cargo.toml was not found"