#!/usr/bin/env bash # Publish one Linux package. Installation feeds reuse this build's binaries. set -euo pipefail rid="${1:?usage: publish-linux-agent.sh }"; binaries="${2:?}" root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "$root/ci/version.sh" [[ -n "${GITEA_TOKEN:-}" ]] || { echo 'GITEA_TOKEN is required' >&2; exit 2; } if [[ -z "${CI_COMMIT_TAG:-}" ]]; then bash "$root/ci/wait-for-checks.sh" channel=dev else channel=release fi work="$root/.release/linux-agent/$rid/packages" mkdir -p "$work" chmod 700 "$work" trap 'rm -f "$work/curl.conf"' EXIT bash "$root/ci/package-linux-agent.sh" "$rid" "$binaries" "$work" printf 'header = "Authorization: token %s"\n' "$GITEA_TOKEN" > "$work/curl.conf" chmod 600 "$work/curl.conf" base="${GITEA_BASE:-http://127.0.0.1:3100}" for file in "$work"/*.tar.gz "$work"/*.sha256; do code="$(curl --silent --show-error --retry 3 --config "$work/curl.conf" --upload-file "$file" \ --output "$work/response" --write-out '%{http_code}' \ "${base%/}/api/packages/justme/generic/moshiro-node/$MOSHIRO_VERSION/$(basename "$file")")" [[ "$code" == 2* || "$code" == 409 ]] || { echo "Linux package upload failed: HTTP $code" >&2; exit 1; } done # This is an installation adapter, not a separate native build or image extraction. # Preserve the installed OpenWrt updater's signed-feed contract. if [[ "$rid" == linux-musl-* && -n "${RELEASE_SIGNING_KEY:-}" && ( "$channel" == dev || "$MOSHIRO_VERSION" != *-* ) ]]; then bash "$root/ci/publish-openwrt.sh" "$channel" "$rid" "$binaries" fi