Files
s3-gateway/ci/clone-source.sh
William Gill 8814a6e239
build / build (push) Has been cancelled
ci: any Linux runner; build per tag or dispatch, drop cron and matrix
runs-on is now ubuntu-latest (any Linux runner with Docker; toolchain comes from the golang container). The workflow builds one version per run, triggered by a v* tag push or manual workflow_dispatch with a tag input - no scheduled builds. Removes the static matrix (and ci/matrix.sh) and hardens clone-source.sh tag detection to use GITHUB_REF. Docs/README updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 13:29:20 -05:00

64 lines
2.3 KiB
Bash

#!/bin/bash
# Clone a versitygw release tag into a local source tree, ready for
# patch application. Mirrors the scoutfs-build clone-source.sh tag
# selection logic.
#
# Environment:
# VGW_REPO_URL upstream git URL (default github.com/versity/versitygw)
# VGW_TAG explicit tag to build (set by the CI matrix from
# ci/support-matrix.yaml). Highest priority.
# VGW_SRC_DIR where to put the checkout (default: src)
#
# Tag selection priority:
# 1. VGW_TAG env (matrix / manual single-version run)
# 2. GITHUB_REF_NAME when this run was triggered by a tag push
# 3. latest remote vX.Y.Z tag
#
# Exports VGW_VERSION / VGW_TAG / VGW_SRC_DIR to GITHUB_ENV when run
# under Gitea Actions.
set -euo pipefail
VGW_REPO_URL="${VGW_REPO_URL:-https://github.com/versity/versitygw.git}"
VGW_SRC_DIR="${VGW_SRC_DIR:-src}"
if [[ -n "${VGW_TAG:-}" ]]; then
TAG="${VGW_TAG}"
echo ">>> Using VGW_TAG from env: ${TAG}"
elif [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
TAG="${GITHUB_REF_NAME:-${GITHUB_REF#refs/tags/}}"
echo ">>> Using tag from push event: ${TAG}"
else
echo ">>> Discovering latest release tag from ${VGW_REPO_URL}..."
TAG=$(git ls-remote --tags --sort=-v:refname "${VGW_REPO_URL}" 'refs/tags/v*' \
| grep -v '\^{}' \
| head -1 \
| sed 's|.*refs/tags/||')
[[ -n "$TAG" ]] || { echo "ERROR: no release tags found in ${VGW_REPO_URL}" >&2; exit 1; }
echo ">>> Latest release tag: ${TAG}"
fi
echo ">>> Cloning ${VGW_REPO_URL} at ${TAG}..."
rm -rf "${VGW_SRC_DIR}"
# autocrlf=false keeps the checkout byte-identical to upstream (LF) so
# the LF patches in patches/ apply cleanly regardless of host platform.
git -c core.autocrlf=false clone --depth 1 --branch "${TAG}" \
"${VGW_REPO_URL}" "${VGW_SRC_DIR}"
# git am needs a clean worktree, LF line endings, and a committer
# identity inside the source tree. CI runners don't set these.
git -C "${VGW_SRC_DIR}" config core.autocrlf false
git -C "${VGW_SRC_DIR}" config user.email "ci@s3-gateway.local"
git -C "${VGW_SRC_DIR}" config user.name "s3-gateway CI"
VGW_VERSION="${TAG#v}"
echo ">>> versitygw version: ${VGW_VERSION}"
echo ">>> source directory: ${VGW_SRC_DIR}"
if [[ -n "${GITHUB_ENV:-}" ]]; then
{
echo "VGW_VERSION=${VGW_VERSION}"
echo "VGW_TAG=${TAG}"
echo "VGW_SRC_DIR=${VGW_SRC_DIR}"
} >> "${GITHUB_ENV}"
fi