Files
scoutfs-build/ci/clone-source.sh
William Gill 7051201d3e Add ScoutFS CI build pipeline for Gitea Act Runner
Automated pipeline to build, sign, and publish ScoutFS kernel module
packages across AlmaLinux 8/9, Rocky Linux 8/9, and Alpine 3.18-3.21
using Gitea's built-in package registry.
2026-04-06 11:18:41 -05:00

42 lines
1.5 KiB
Bash

#!/bin/bash
# Clone the latest release tag of ScoutFS source
set -euo pipefail
SCOUTFS_REPO_URL="${SCOUTFS_REPO_URL:-https://github.com/versity/scoutfs.git}"
SCOUTFS_SRC_DIR="${SCOUTFS_SRC_DIR:-scoutfs-src}"
# If triggered by a tag push, use that tag directly
if [[ -n "${GITHUB_REF_NAME:-}" && "${GITHUB_REF_TYPE:-}" == "tag" ]]; then
TAG="${GITHUB_REF_NAME}"
echo ">>> Using tag from push event: ${TAG}"
else
# Detect latest release tag (vX.Y format, sorted by version)
echo ">>> Discovering latest release tag from ${SCOUTFS_REPO_URL}..."
TAG=$(git ls-remote --tags --sort=-v:refname "${SCOUTFS_REPO_URL}" 'refs/tags/v*' \
| head -1 \
| sed 's|.*refs/tags/||')
if [[ -z "$TAG" ]]; then
echo "ERROR: No release tags found in ${SCOUTFS_REPO_URL}"
exit 1
fi
echo ">>> Latest release tag: ${TAG}"
fi
# Clone at the specific tag with minimal depth
echo ">>> Cloning ${SCOUTFS_REPO_URL} at ${TAG}..."
git clone --depth 1 --branch "${TAG}" "${SCOUTFS_REPO_URL}" "${SCOUTFS_SRC_DIR}"
# Extract version from tag (strip leading 'v')
SCOUTFS_VERSION="${TAG#v}"
echo ">>> ScoutFS version: ${SCOUTFS_VERSION}"
echo ">>> Source directory: ${SCOUTFS_SRC_DIR}"
# Export for downstream steps (Gitea Act Runner uses GITHUB_ENV)
if [[ -n "${GITHUB_ENV:-}" ]]; then
echo "SCOUTFS_VERSION=${SCOUTFS_VERSION}" >> "${GITHUB_ENV}"
echo "SCOUTFS_TAG=${TAG}" >> "${GITHUB_ENV}"
echo "SCOUTFS_SRC_DIR=${SCOUTFS_SRC_DIR}" >> "${GITHUB_ENV}"
fi