Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion .github/workflows/_publish-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,17 @@ 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'
import os
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 {}
Expand All @@ -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")
Expand All @@ -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"
Expand Down
Loading