Files
sendico/ci/scripts/common/ensure_env_version.sh
Stephan D 4dfe6f8eac
Some checks failed
ci/woodpecker/push/db Pipeline was successful
ci/woodpecker/push/billing_fees Pipeline failed
ci/woodpecker/push/fx/1 Pipeline failed
ci/woodpecker/push/nats Pipeline was successful
ci/woodpecker/push/fx/2 Pipeline failed
chain gateway build fix
2025-11-11 09:26:00 +01:00

54 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -eu
echo "[fx-pipeline] rewriting .env.version" >&2
if [ -f ./.env.version ]; then
while IFS= read -r line || [ -n "$line" ]; do
case "$line" in
''|\#*) continue ;;
esac
if printf '%s' "$line" | grep -Eq '^[[:alpha:]_][[:alnum:]_]*='; then
key="${line%%=*}"
value="${line#*=}"
export "$key=$value"
fi
done < ./.env.version
fi
if [ -n "${WOODPECKER_COMMIT:-}" ]; then
GIT_REV="$(printf '%s' "${WOODPECKER_COMMIT}" | cut -c1-7)"
elif command -v git >/dev/null 2>&1; then
GIT_REV="$(git rev-parse --short HEAD 2>/dev/null || true)"
fi
: "${GIT_REV:=dev}"
if [ -n "${WOODPECKER_BRANCH:-}" ]; then
BUILD_BRANCH="${WOODPECKER_BRANCH}"
elif command -v git >/dev/null 2>&1; then
BUILD_BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
fi
: "${BUILD_BRANCH:=local}"
if [ -f version ]; then
APP_V="$(cat version 2>/dev/null || true)"
fi
: "${APP_V:=dev}"
if [ -z "${BUILD_DATE:-}" ]; then
BUILD_DATE="$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || echo unknown)"
fi
: "${WOODPECKER_MACHINE:=woodpecker}"
if [ -z "${BUILD_USER:-}" ]; then
BUILD_USER="${WOODPECKER_MACHINE}"
fi
cat > .env.version <<EOF
GIT_REV=${GIT_REV}
BUILD_BRANCH=${BUILD_BRANCH}
APP_V=${APP_V}
BUILD_DATE=${BUILD_DATE}
BUILD_USER=${BUILD_USER}
EOF