Files
harmony/.gitea/scripts/resolve-release-version.sh
Jean-Gabriel Gill-Couture 80b3cf1c31
All checks were successful
Run Check Script / check (pull_request) Successful in 2m22s
ci(fleet-operator): extract version resolution to a shared bash script
Workflow yaml had a 12-line inline bash block computing the release
version from `GITHUB_REF_NAME` or `inputs.version`. Moves the
logic into `.gitea/scripts/resolve-release-version.sh` so the
workflow yaml is back to one-line invocations and the resolver is
reusable by sibling component workflows (agent, callout).

This is the interim form. The real fix is a harmony Rust binary
that understands git refs directly — see PR thread on framework-
level build/package/release ownership.
2026-05-27 21:38:05 -04:00

39 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Resolve the release version for a per-crate release workflow.
#
# Usage:
# resolve-release-version.sh <tag-prefix> <ref-name> [manual-version]
#
# Inputs are positional so callers can plug it from any CI without
# environment-variable contracts:
# - tag-prefix: e.g. "harmony-fleet-operator-" (NO trailing v)
# - ref-name: e.g. "harmony-fleet-operator-v0.1.0" (push-tag case)
# - manual-version: optional; takes precedence over ref parsing
# (workflow_dispatch case)
#
# Prints the resolved version (e.g. "v0.1.0") to stdout; exits non-zero
# with a message to stderr if neither input yields one.
#
# Interim: this should eventually live in a harmony Rust binary that
# understands git refs natively. See PR discussion on
# .gitea/workflows/harmony-fleet-operator.yaml.
set -euo pipefail
PREFIX="${1:?usage: resolve-release-version.sh <prefix> <ref-name> [manual-version]}"
REF="${2:?usage: resolve-release-version.sh <prefix> <ref-name> [manual-version]}"
MANUAL="${3-}"
if [ -n "$MANUAL" ]; then
VERSION="$MANUAL"
else
VERSION="${REF#${PREFIX}}"
fi
if [ -z "$VERSION" ] || [ "$VERSION" = "$REF" ]; then
echo "could not resolve version from ref '$REF' (prefix '$PREFIX', manual '$MANUAL')" >&2
exit 1
fi
echo "$VERSION"