From 0e4d38eefcab1343ea4090f3c93b97ad643ba7b4 Mon Sep 17 00:00:00 2001 From: xavix-yo Date: Sun, 19 Jul 2026 23:54:22 +0100 Subject: [PATCH] =?UTF-8?q?Move=20CI=20scripts=20scripts/=20->=20ci/=20(sc?= =?UTF-8?q?ripts/=20=C3=A8=20in=20gitignore)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/nightly.yml | 4 +- .gitea/workflows/release.yml | 8 ++-- .gitignore | 2 - ci/package.sh | 92 ++++++++++++++++++++++++++++++++++++ ci/verify-version.sh | 56 ++++++++++++++++++++++ 5 files changed, 154 insertions(+), 8 deletions(-) create mode 100755 ci/package.sh create mode 100755 ci/verify-version.sh diff --git a/.gitea/workflows/nightly.yml b/.gitea/workflows/nightly.yml index c38ce0a..355a0c0 100644 --- a/.gitea/workflows/nightly.yml +++ b/.gitea/workflows/nightly.yml @@ -32,7 +32,7 @@ jobs: - name: Package amd64 run: | cd "${GITHUB_WORKSPACE:-.}" - ./scripts/package.sh \ + ./ci/package.sh \ --version nightly \ --arch amd64 \ --target-dir /home/dguiducci/.cache/skald-ci/target/release \ @@ -41,7 +41,7 @@ jobs: - name: Package arm64 run: | cd "${GITHUB_WORKSPACE:-.}" - ./scripts/package.sh \ + ./ci/package.sh \ --version nightly \ --arch arm64 \ --target-dir /home/dguiducci/.cache/skald-ci/target/aarch64-unknown-linux-gnu/release \ diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 4add902..1a48f96 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Verify version is new - run: ./scripts/verify-version.sh --builds-dir /var/www/builds.skaldagent.net + run: ./ci/verify-version.sh --builds-dir /var/www/builds.skaldagent.net # ── Push/merge: build, package, and deploy the release ────────────────────── release: @@ -43,7 +43,7 @@ jobs: # Also run verify-version on push to catch any race (belt-and-suspenders) - name: Verify version is new - run: ./scripts/verify-version.sh --builds-dir /var/www/builds.skaldagent.net + run: ./ci/verify-version.sh --builds-dir /var/www/builds.skaldagent.net - name: Build native (linux/amd64) run: | @@ -62,7 +62,7 @@ jobs: - name: Package amd64 run: | cd "${GITHUB_WORKSPACE:-.}" - ./scripts/package.sh \ + ./ci/package.sh \ --version "${{ steps.extract-version.outputs.version }}" \ --arch amd64 \ --target-dir /home/dguiducci/.cache/skald-ci/target/release \ @@ -71,7 +71,7 @@ jobs: - name: Package arm64 run: | cd "${GITHUB_WORKSPACE:-.}" - ./scripts/package.sh \ + ./ci/package.sh \ --version "${{ steps.extract-version.outputs.version }}" \ --arch arm64 \ --target-dir /home/dguiducci/.cache/skald-ci/target/aarch64-unknown-linux-gnu/release \ diff --git a/.gitignore b/.gitignore index 2679507..fd252fa 100644 --- a/.gitignore +++ b/.gitignore @@ -17,8 +17,6 @@ blueprint/ /logs/ /tmp/ /scripts/ -!scripts/package.sh -!scripts/verify-version.sh # Connector folders installed from the marketplace — instance data, like homes/ # and database/, not source. See crates/skald-core/src/mcp/install.rs /connectors/ diff --git a/ci/package.sh b/ci/package.sh new file mode 100755 index 0000000..7a3fd13 --- /dev/null +++ b/ci/package.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env sh +# Package a Skald Circle build into a distributable tarball. +# +# Usage: +# ./scripts/package.sh \ +# --version v0.1.0 \ +# --arch amd64 \ +# --target-dir target/release \ +# --output /tmp/dist +# +# --version Version string, e.g. "v0.1.0" or "nightly" +# --arch Architecture: "amd64" or "arm64" +# --target-dir Path to cargo release output (target/release or +# target/aarch64-unknown-linux-gnu/release) +# --output Directory where the .tar.gz will be written +# +# The tarball contains everything needed to run Skald Circle: +# bin/skald, bin/skald-setup, web/, agents/, skills/, +# default.config.yaml, requirements.txt, run.sh + +set -eu + +cd "$(dirname "$0")/.." + +# ── Parse args ──────────────────────────────────────────────────────────────── +VERSION="" +ARCH="" +TARGET_DIR="" +OUTPUT="" + +while [ $# -gt 0 ]; do + case "$1" in + --version) VERSION="$2"; shift 2 ;; + --arch) ARCH="$2"; shift 2 ;; + --target-dir) TARGET_DIR="$2"; shift 2 ;; + --output) OUTPUT="$2"; shift 2 ;; + *) echo "[package.sh] Unknown option: $1" >&2; exit 1 ;; + esac +done + +if [ -z "$VERSION" ] || [ -z "$ARCH" ] || [ -z "$TARGET_DIR" ] || [ -z "$OUTPUT" ]; then + echo "[package.sh] Missing required argument. See usage." >&2 + exit 1 +fi + +PACKAGE_NAME="skald-circle-${VERSION}-linux-${ARCH}" +STAGING="$(mktemp -d)/${PACKAGE_NAME}" +mkdir -p "$STAGING/bin" + +echo "[package.sh] Packaging $PACKAGE_NAME" +echo "[package.sh] target-dir: $TARGET_DIR" +echo "[package.sh] output: $OUTPUT" + +# ── Verify binaries exist ───────────────────────────────────────────────────── +if [ ! -f "$TARGET_DIR/skald" ]; then + echo "[package.sh] ERROR: skald binary not found at $TARGET_DIR/skald" >&2 + exit 1 +fi +if [ ! -f "$TARGET_DIR/skald-setup" ]; then + echo "[package.sh] ERROR: skald-setup binary not found at $TARGET_DIR/skald-setup" >&2 + exit 1 +fi + +# ── Copy binaries (stripped) ────────────────────────────────────────────────── +cp "$TARGET_DIR/skald" "$STAGING/bin/skald" +cp "$TARGET_DIR/skald-setup" "$STAGING/bin/skald-setup" +strip "$STAGING/bin/skald" "$STAGING/bin/skald-setup" +chmod 755 "$STAGING/bin/skald" "$STAGING/bin/skald-setup" + +# ── Copy runtime assets ─────────────────────────────────────────────────────── +cp -r web "$STAGING/web" +cp -r agents "$STAGING/agents" +cp -r skills "$STAGING/skills" +cp default.config.yaml "$STAGING/default.config.yaml" +cp requirements.txt "$STAGING/requirements.txt" +cp run.sh "$STAGING/run.sh" +chmod 755 "$STAGING/run.sh" + +# ── Create tarball ──────────────────────────────────────────────────────────── +mkdir -p "$OUTPUT" +TARBALL="${OUTPUT}/${PACKAGE_NAME}.tar.gz" + +cd "$(dirname "$STAGING")" +tar czf "$TARBALL" "$PACKAGE_NAME" +cd - > /dev/null + +rm -rf "$(dirname "$STAGING")" + +SHA256="$(sha256sum "$TARBALL" | cut -d' ' -f1)" +echo "[package.sh] ✅ Created $TARBALL" +echo "[package.sh] sha256: $SHA256" +echo "[package.sh] size: $(du -h "$TARBALL" | cut -f1)" diff --git a/ci/verify-version.sh b/ci/verify-version.sh new file mode 100755 index 0000000..e099e8e --- /dev/null +++ b/ci/verify-version.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env sh +# Verify that a Skald Circle release version has not been built yet. +# +# Intended as a required Gitea Actions status check on PRs to the `release` +# branch. Runs in the repo root after checkout. +# +# Usage: +# ./scripts/verify-version.sh \ +# --builds-dir /var/www/builds.skaldagent.net +# +# Exit codes: +# 0 → version is new (or builds-dir doesn't exist yet) → PR may proceed +# 1 → version already built → PR should fail +# +# Reads the version from Cargo.toml in the current directory. + +set -eu + +# ── Parse args ──────────────────────────────────────────────────────────────── +BUILDS_DIR="" + +while [ $# -gt 0 ]; do + case "$1" in + --builds-dir) BUILDS_DIR="$2"; shift 2 ;; + *) echo "[verify-version] Unknown option: $1" >&2; exit 1 ;; + esac +done + +if [ -z "$BUILDS_DIR" ]; then + echo "[verify-version] Missing --builds-dir" >&2 + exit 1 +fi + +# ── Read version from Cargo.toml ────────────────────────────────────────────── +# This is the workspace root's Cargo.toml. +VERSION="$(grep '^version ' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')" + +if [ -z "$VERSION" ]; then + echo "[verify-version] ERROR: Could not read version from Cargo.toml" >&2 + exit 1 +fi + +echo "[verify-version] Version in Cargo.toml: v${VERSION}" + +# ── Check if already built ──────────────────────────────────────────────────── +RELEASE_DIR="${BUILDS_DIR}/releases/v${VERSION}" + +if [ -d "$RELEASE_DIR" ]; then + echo "[verify-version] ❌ Release v${VERSION} already exists at:" + echo "[verify-version] ${RELEASE_DIR}" + echo "[verify-version] Bump the version in Cargo.toml before merging." + exit 1 +fi + +echo "[verify-version] ✅ Release v${VERSION} is new — no conflict." +exit 0