From fc0981b4ac1fbfb25528d1702dda4b870e2fc809 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Sun, 18 Oct 2026 17:27:23 +0200 Subject: [PATCH] Version chart releases from Git tags --- .gitea/workflows/chart.yml | 21 +++++++++++---------- scripts/chart-version.sh | 12 ++++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100755 scripts/chart-version.sh diff --git a/.gitea/workflows/chart.yml b/.gitea/workflows/chart.yml index ed96762..f0e794b 100644 --- a/.gitea/workflows/chart.yml +++ b/.gitea/workflows/chart.yml @@ -14,8 +14,10 @@ jobs: name: Validate chart runs-on: ubuntu-latest steps: - - name: Check out source + - name: Check out source and tags uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Helm uses: azure/setup-helm@v4 @@ -50,8 +52,10 @@ jobs: needs: validate runs-on: ubuntu-latest steps: - - name: Check out source + - name: Check out source and tags uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Install Helm uses: azure/setup-helm@v4 @@ -61,10 +65,7 @@ jobs: - name: Select immutable chart version run: | set -euo pipefail - run_attempt="${GITHUB_RUN_ATTEMPT:-1}" - test -n "${GITHUB_RUN_NUMBER}" - printf 'CHART_VERSION=0.%s.%s\n' \ - "${GITHUB_RUN_NUMBER}" "${run_attempt}" >> "${GITHUB_ENV}" + printf 'CHART_VERSION=%s\n' "$(./scripts/chart-version.sh)" >> "${GITHUB_ENV}" - name: Package and publish chart env: @@ -113,10 +114,10 @@ jobs: working-directory: homelab-gitops run: | set -euo pipefail - ./scripts/update-immichframe-chart.sh "${CHART_VERSION}" - git config user.name "immichframe chart CI" - git config user.email "immichframe-chart-ci@brunner.ninja" - git add apps/immichframe/Chart.yaml + ./scripts/update-chart-version.sh immichframe "${CHART_VERSION}" + git config user.name "feedc0de" + git config user.email "feedc0de@users.noreply.code.brunner.ninja" + git add bootstrap/immichframe.yaml if git diff --cached --quiet; then echo "GitOps already selects ${CHART_VERSION}" exit 0 diff --git a/scripts/chart-version.sh b/scripts/chart-version.sh new file mode 100755 index 0000000..a20feb6 --- /dev/null +++ b/scripts/chart-version.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu + +description=$(git describe --tags --long --match 'v[0-9]*' --dirty) +case "$description" in + *-dirty) echo "refusing to package a dirty tree" >&2; exit 1 ;; +esac +version=${description#v} +case "$version" in + *-0-g*) version=${version%%-0-g*} ;; +esac +printf '%s\n' "$version"