Fix/umbrella chart support #31

Merged
niko merged 2 commits from fix/umbrella-chart-support into main 2026-06-19 13:13:07 +03:00
4 changed files with 48 additions and 7 deletions
Showing only changes of commit 45f939a611 - Show all commits
+9
View File
@@ -32,6 +32,15 @@ jobs:
repository: niko/gitea-ci-library repository: niko/gitea-ci-library
path: .ci path: .ci
- name: Install yq
# COMPROMISE: Requires internet access.
# Does NOT work in air-gapped environments. The script falls back
# to BOM-stripping sed if yq is not available.
run: |
if ! command -v yq &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y -qq yq
fi
- name: Check existing artifact and calculate version - name: Check existing artifact and calculate version
env: env:
SERVER_URL: ${{ gitea.server_url }} SERVER_URL: ${{ gitea.server_url }}
+9 -4
View File
@@ -4,14 +4,16 @@ set -e
RAW_VERSION="" RAW_VERSION=""
if [ -n "${VERSION_FILE-}" ] && [ -f "${VERSION_FILE-}" ]; then if [ -n "${VERSION_FILE-}" ] && [ -f "${VERSION_FILE-}" ]; then
RAW_VERSION=$(sed -n 's/^version:[[:space:]]*\([^[:space:]]*\).*/\1/p' "${VERSION_FILE}") if echo "${VERSION_FILE}" | grep -q -E '\.[Yy][Aa][Mm][Ll]$'; then
RAW_VERSION=$(yq '.version' "${VERSION_FILE}" 2>/dev/null | grep -v '^null$' || true)
if [ -z "${RAW_VERSION}" ]; then if [ -z "${RAW_VERSION}" ]; then
if echo "${VERSION_FILE}" | grep -q -E '\.json$'; then RAW_VERSION=$(sed 's/'$'\xef\xbb\xbf''//g' "${VERSION_FILE}" | sed -n 's/^version:[[:space:]]*\([^[:space:]]*\).*/\1/p')
fi
elif echo "${VERSION_FILE}" | grep -q -E '\.json$'; then
RAW_VERSION=$(jq -r '.version' "${VERSION_FILE}") RAW_VERSION=$(jq -r '.version' "${VERSION_FILE}")
else else
RAW_VERSION=$(cat "${VERSION_FILE}" | tr -d '[:space:]') RAW_VERSION=$(cat "${VERSION_FILE}" | tr -d '[:space:]')
fi fi
fi
fi fi
if [ -z "${RAW_VERSION}" ]; then if [ -z "${RAW_VERSION}" ]; then
@@ -22,7 +24,10 @@ if [ -z "${RAW_VERSION}" ]; then
elif [ -f pom.xml ]; then elif [ -f pom.xml ]; then
RAW_VERSION=$(grep -oP '<version>\K[^<]+' pom.xml | head -1) RAW_VERSION=$(grep -oP '<version>\K[^<]+' pom.xml | head -1)
elif [ -f Chart.yaml ]; then elif [ -f Chart.yaml ]; then
RAW_VERSION=$(sed -n 's/^version:[[:space:]]*\([^[:space:]]*\).*/\1/p' Chart.yaml) RAW_VERSION=$(yq '.version' Chart.yaml 2>/dev/null | grep -v '^null$' || true)
if [ -z "${RAW_VERSION}" ]; then
RAW_VERSION=$(sed 's/'$'\xef\xbb\xbf''//g' Chart.yaml | sed -n 's/^version:[[:space:]]*\([^[:space:]]*\).*/\1/p')
fi
else else
echo "ERROR: No version source found (VERSION_FILE, VERSION, package.json, pom.xml, Chart.yaml)" >&2 echo "ERROR: No version source found (VERSION_FILE, VERSION, package.json, pom.xml, Chart.yaml)" >&2
exit 1 exit 1
+15
View File
@@ -153,6 +153,21 @@ teardown() {
[ "$NEXT_VERSION" = "0.3.2" ] [ "$NEXT_VERSION" = "0.3.2" ]
} }
@test "VERSION_FILE=Chart-umbrella.yaml extracts only top-level version" {
mock_set_sequence '[{"code": 200, "body": []}]'
mock_start
export VERSION_FILE="$BATS_TEST_DIRNAME/fixtures/check-version/Chart-umbrella.yaml"
run bash scripts/check-version.sh
echo "STATUS=$status"
echo "OUTPUT=$output"
[ "$status" -eq 0 ]
source /tmp/build-ctx/build.env
echo "NEXT_VERSION=$NEXT_VERSION"
[ "$NEXT_VERSION" = "0.1.0" ]
}
@test "no version source exits with error" { @test "no version source exits with error" {
mock_set_sequence '[{"code": 200, "body": []}]' mock_set_sequence '[{"code": 200, "body": []}]'
mock_start mock_start
+12
View File
@@ -0,0 +1,12 @@
apiVersion: v2
name: agent-platform
description: Agent Platform umbrella chart
type: application
version: 0.1.0
dependencies:
- name: vikunja
version: "0.1.0"
repository: oci://registry.example.com
- name: langfuse
version: "0.2.0"
repository: oci://registry.example.com