Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 86 additions & 31 deletions .github/workflows/helm-release.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,104 @@
# .github/workflows/helm-release.yml
name: Release Helm Chart

on:
# Auto trigger: plain SemVer tags, e.g. 1.2.3 or 1.2.3-extra-test.
push:
tags:
- 'filebrowser-quantum-v*' # only triggers on tags like filebrowser-quantum-v1.2.3
- '*.*.*'
# Manual trigger: run from any branch/commit for testing. The chosen
# ref becomes the chart version, so test packages never collide with
# real semver releases.
workflow_dispatch:
inputs:
dry_run:
description: 'Lint only, do not push to OCI or create a release'
type: boolean
default: false

env:
CHART_DIR: filebrowser
CHART_NAME: filebrowser-quantum

jobs:
lint:
name: Lint chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Helm
uses: azure/setup-helm@v4

- name: helm lint
run: helm lint "${CHART_DIR}"

- name: helm template (render sanity check)
run: helm template test "${CHART_DIR}" > /dev/null

release:
name: Package & publish
needs: lint
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for git-cliff changelog range
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v4

- name: Set OCI repo (lowercased)
run: |
echo "OCI_REPO=ghcr.io/$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')/helm-charts" >> "$GITHUB_ENV"

- name: Extract version from tag
- name: Determine chart version
id: version
run: |
# strips "filebrowser-quantum-v" prefix → "1.2.3"
VERSION=${GITHUB_REF_NAME#filebrowser-quantum-v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [ "${{ github.ref_type }}" = "tag" ]; then
# Tag push -> tag is already valid SemVer, use as-is.
# e.g. 1.2.3 or 1.2.3-extra-test
VERSION="${GITHUB_REF_NAME}"
else
# Manual dispatch on a branch/commit -> version derived from
# the branch name. Sanitized + short-SHA suffixed so Helm
# (which requires valid SemVer) accepts it and repeated test
# runs on the same branch don't overwrite each other's tag.
SAFE_BRANCH=$(echo "${GITHUB_REF_NAME}" \
| tr '[:upper:]' '[:lower:]' \
| sed -e 's#[/_]#-#g' -e 's#[^a-z0-9-]##g')
SHORT_SHA=$(git rev-parse --short HEAD)
VERSION="0.0.0-${SAFE_BRANCH}.${SHORT_SHA}"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "Resolved chart version: ${VERSION}"

- name: Set up Helm
uses: azure/setup-helm@v4
- name: Set Chart.yaml version
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" \
"${CHART_DIR}/Chart.yaml"

- name: Lint chart
run: helm lint filebrowser
- name: Package chart
run: helm package "${CHART_DIR}" --version "${{ steps.version.outputs.version }}" --destination .

- name: Login to GHCR
if: ${{ !inputs.dry_run }}
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \
-u "${{ github.actor }}" --password-stdin

- name: Push chart to OCI
if: ${{ !inputs.dry_run }}
run: |
helm push "${CHART_NAME}-${{ steps.version.outputs.version }}.tgz" \
"oci://${OCI_REPO}"

- name: Generate changelog
if: ${{ github.ref_type == 'tag' && !inputs.dry_run }}
id: changelog
uses: orhun/git-cliff-action@v4
with:
Expand All @@ -41,25 +107,14 @@ jobs:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- name: Update Chart.yaml version
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.version }}/" filebrowser/Chart.yaml

- name: Login to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \
-u ${{ github.actor }} --password-stdin

- name: Package and push chart
run: |
helm package filebrowser --version ${{ steps.version.outputs.version }}
helm push filebrowser-quantum-${{ steps.version.outputs.version }}.tgz \
oci://ghcr.io/${{ github.repository_owner }}/helm-charts

- name: Create GitHub Release
if: ${{ !inputs.dry_run }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: "filebrowser-quantum v${{ steps.version.outputs.version }}"
body: ${{ steps.changelog.outputs.content }}
files: filebrowser-quantum-${{ steps.version.outputs.version }}.tgz
tag_name: ${{ steps.version.outputs.version }}
target_commitish: ${{ github.sha }}
name: "${{ env.CHART_NAME }} v${{ steps.version.outputs.version }}"
draft: ${{ github.ref_type != 'tag' }}
prerelease: ${{ github.ref_type != 'tag' }}
body: ${{ github.ref_type == 'tag' && steps.changelog.outputs.content || format('Test build from `{0}` @ `{1}`. Not an official release — draft only.', github.ref_name, github.sha) }}
files: "${{ env.CHART_NAME }}-${{ steps.version.outputs.version }}.tgz"
Loading