ci: package and push the Helm chart to the OCI registry
Add a chart-push job that runs after the chart lint on every push and publishes the packaged chart to oci://gitea.tap-tap.win/taptap/charts. Main builds use <chart version>-sha.<commit> so parallel commits do not overwrite each other; v* tags use the tag version. The shared scripts/push-chart.sh also supports explicit VERSION and local use.
This commit is contained in:
1 parent
441fa056ba
commit
76bccaefea
4 files changed
+139
-2
No files matched your search
@@ -12,6 +12,7 @@ on:
|
||||
env:
|
||||
REGISTRY: gitea.tap-tap.win
|
||||
IMAGE_NAME: taptap/audiomanager
|
||||
CHART_REPO: taptap/charts
|
||||
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
||||
# ci/Dockerfile changes.
|
||||
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||
@@ -39,6 +40,27 @@ jobs:
|
||||
helm lint charts/musicmanager
|
||||
helm template musicmanager charts/musicmanager --set users.existingSecret=test > /dev/null
|
||||
|
||||
chart-push:
|
||||
needs:
|
||||
- chart
|
||||
if: github.event_name == 'push'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Log in to the registry
|
||||
run: |
|
||||
echo "${{ secrets.AUDIOMANAGER_REGISTRY_TOKEN }}" \
|
||||
| helm registry login "$REGISTRY" \
|
||||
--username "${{ gitea.actor }}" \
|
||||
--password-stdin
|
||||
- name: Package and push the chart
|
||||
run: scripts/push-chart.sh
|
||||
|
||||
image:
|
||||
needs:
|
||||
- test
|
||||
|
||||
@@ -20,3 +20,6 @@ config/users.yaml
|
||||
|
||||
# Test fixtures (generated locally, never committed)
|
||||
test-media/
|
||||
|
||||
# Packaged Helm charts
|
||||
dist/
|
||||
@@ -179,7 +179,7 @@ Build a lightweight, self-hosted **OpenSubsonic-compatible music server** in **K
|
||||
- **Transcoding:** `ffmpeg` binary in the runtime image (libmp3lame), invoked as a subprocess
|
||||
- **Logging:** `logback-classic` + `kotlin-logging-jvm`
|
||||
- **Config:** YAML (`library.yaml`, `users.yaml`) with env-var overrides for paths and secrets
|
||||
- **Deployment:** multi-stage Dockerfile, Helm chart for k3s, Gitea Actions for tests, local release script for image pushes
|
||||
- **Deployment:** multi-stage Dockerfile, Helm chart for k3s, Gitea Actions for tests and artifact publishing, local release script for image pushes
|
||||
|
||||
---
|
||||
|
||||
@@ -704,7 +704,48 @@ UID 10001 (the chart sets `fsGroup: 10001`).
|
||||
The server exits at startup if a configured root path is missing or unreadable, so
|
||||
the pod will not pass its readiness probe in that case.
|
||||
|
||||
### 9.3 Operations
|
||||
### 9.3 Chart registry
|
||||
|
||||
CI packages the chart and pushes it to the Gitea OCI registry after the `chart`
|
||||
job passes. The package is available at:
|
||||
|
||||
```text
|
||||
oci://gitea.tap-tap.win/taptap/charts/musicmanager
|
||||
```
|
||||
|
||||
Versions published by CI:
|
||||
|
||||
- `main`: `<chart version>-sha.<commit>`, for example `0.1.1-sha.441fa05`
|
||||
- `v*` tag: the tag without the leading `v`, for example `v0.2.0` -> `0.2.0`
|
||||
|
||||
The registry is private, and Helm keeps its own credentials (a Docker login is
|
||||
not enough):
|
||||
|
||||
```bash
|
||||
helm registry login gitea.tap-tap.win -u TapTap
|
||||
```
|
||||
|
||||
Install a published chart:
|
||||
|
||||
```bash
|
||||
helm upgrade --install musicmanager \
|
||||
oci://gitea.tap-tap.win/taptap/charts/musicmanager \
|
||||
--version 0.1.1-sha.441fa05 \
|
||||
--namespace musicmanager \
|
||||
--set users.existingSecret=musicmanager-users \
|
||||
--set imagePullSecrets[0].name=musicmanager-registry
|
||||
```
|
||||
|
||||
To package and push from a workstation, run `helm registry login` first and then:
|
||||
|
||||
```bash
|
||||
scripts/push-chart.sh # version from CI env, git, or Chart.yaml
|
||||
VERSION=0.2.0 scripts/push-chart.sh # explicit version
|
||||
```
|
||||
|
||||
The script writes the `.tgz` to `dist/`, which is ignored by git.
|
||||
|
||||
### 9.4 Operations
|
||||
|
||||
- Backups: documented manual copy of `DATA_DIR` (SQLite DB + covers) while the server is stopped, or via `sqlite3 .backup`.
|
||||
- Logs to stdout (JSON optional), picked up by the cluster.
|
||||
|
||||
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Package the Helm chart and push it to the OCI registry.
|
||||
#
|
||||
# Run `helm registry login <registry>` first (CI does this with the package
|
||||
# token). The version is:
|
||||
# - VERSION if set,
|
||||
# - the pushed tag for a v* tag build,
|
||||
# - <chart version>-sha.<commit> for a main branch build,
|
||||
# - the chart version for a local build outside CI.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
REGISTRY="${REGISTRY:-gitea.tap-tap.win}"
|
||||
CHART_REPO="${CHART_REPO:-taptap/charts}"
|
||||
CHART_DIR="${CHART_DIR:-$ROOT/charts/musicmanager}"
|
||||
OUTPUT_DIR="${OUTPUT_DIR:-$ROOT/dist}"
|
||||
VERSION="${VERSION:-}"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: scripts/push-chart.sh [options]
|
||||
|
||||
Push the chart to oci://<registry>/<chart-repo>/musicmanager.
|
||||
|
||||
Options:
|
||||
-h, --help Show this help
|
||||
|
||||
Environment:
|
||||
REGISTRY OCI registry (default: gitea.tap-tap.win)
|
||||
CHART_REPO Repository path below the registry (default: taptap/charts)
|
||||
CHART_DIR Chart directory (default: charts/musicmanager)
|
||||
OUTPUT_DIR Directory for the packaged chart (default: dist)
|
||||
VERSION Chart version to package (overrides auto-detection)
|
||||
|
||||
Run `helm registry login <registry>` before this script if the registry is
|
||||
private.
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
chart_version="$(awk '/^version:/ { print $2; exit }' "$CHART_DIR/Chart.yaml")"
|
||||
if [[ -z "$chart_version" ]]; then
|
||||
echo "Could not read the chart version from $CHART_DIR/Chart.yaml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
elif [[ -n "${GITHUB_SHA:-}" ]]; then
|
||||
VERSION="${chart_version}-sha.${GITHUB_SHA::7}"
|
||||
elif git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1; then
|
||||
VERSION="${chart_version}-sha.$(git -C "$ROOT" rev-parse --short=7 HEAD)"
|
||||
else
|
||||
VERSION="$chart_version"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
package="$OUTPUT_DIR/$(basename "$CHART_DIR")-${VERSION}.tgz"
|
||||
|
||||
helm package "$CHART_DIR" --version "$VERSION" --destination "$OUTPUT_DIR"
|
||||
helm push "$package" "oci://${REGISTRY}/${CHART_REPO}"
|
||||
|
||||
echo "Pushed chart to oci://${REGISTRY}/${CHART_REPO}/$(basename "$CHART_DIR") --version ${VERSION}"
|
||||
Reference in new issue
Block a user