ci: publish charts to TapTap/Charts
Replace the OCI chart push with a classic Helm repository in the public TapTap/Charts repository. CI packages the chart, regenerates index.yaml and pushes both to main, so `helm repo add` and Kustomize helmCharts work. The publisher authenticates with the AUDIOMANAGER_CHARTS_TOKEN secret and supports an explicit VERSION for local releases.
This commit is contained in:
1 parent
df3ed281f8
commit
0ac226b011
3 files changed
+109
-46
No files matched your search
@@ -12,7 +12,6 @@ on:
|
|||||||
env:
|
env:
|
||||||
REGISTRY: gitea.tap-tap.win
|
REGISTRY: gitea.tap-tap.win
|
||||||
IMAGE_NAME: taptap/audiomanager
|
IMAGE_NAME: taptap/audiomanager
|
||||||
CHART_REPO: taptap/charts
|
|
||||||
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
|
||||||
# ci/Dockerfile changes.
|
# ci/Dockerfile changes.
|
||||||
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
@@ -49,16 +48,11 @@ jobs:
|
|||||||
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
env:
|
||||||
|
CHARTS_TOKEN: ${{ secrets.AUDIOMANAGER_CHARTS_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Log in to the registry
|
- name: Package and publish the chart
|
||||||
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
|
run: scripts/push-chart.sh
|
||||||
|
|
||||||
image:
|
image:
|
||||||
|
|||||||
@@ -704,50 +704,76 @@ UID 10001 (the chart sets `fsGroup: 10001`).
|
|||||||
The server exits at startup if a configured root path is missing or unreadable, so
|
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.
|
the pod will not pass its readiness probe in that case.
|
||||||
|
|
||||||
### 9.3 Chart registry
|
### 9.3 Chart repository
|
||||||
|
|
||||||
CI packages the chart and pushes it to the Gitea OCI registry after the `chart`
|
The chart source lives in `charts/audiomanager` in this repository. CI packages
|
||||||
job passes. The package is available at:
|
it and publishes the `.tgz` plus `index.yaml` to the public `TapTap/Charts`
|
||||||
|
repository:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
oci://gitea.tap-tap.win/taptap/charts/audiomanager
|
https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This is a classic Helm repository, so it supports both `helm repo add` and
|
||||||
|
Kustomize's `helmCharts` generator. The chart repository is public; the image
|
||||||
|
registry remains private.
|
||||||
|
|
||||||
Versions published by CI:
|
Versions published by CI:
|
||||||
|
|
||||||
- `main`: `<chart version>-sha.<commit>`, for example `0.1.2-sha.<commit>`
|
- `main`: `<chart version>-sha.<commit>`, for example `0.1.2-sha.<commit>`
|
||||||
- `v*` tag: the tag without the leading `v`, for example `v0.2.0` -> `0.2.0`
|
- `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
|
Use it with Helm:
|
||||||
not enough):
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
helm registry login gitea.tap-tap.win -u TapTap
|
helm repo add taptap \
|
||||||
|
https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main
|
||||||
|
helm repo update
|
||||||
|
helm search repo taptap/audiomanager
|
||||||
```
|
```
|
||||||
|
|
||||||
Install a published chart:
|
Install a published chart:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
VERSION="0.1.2-sha.<commit>"
|
VERSION="0.1.2-sha.<commit>"
|
||||||
helm upgrade --install audiomanager \
|
helm upgrade --install audiomanager taptap/audiomanager \
|
||||||
oci://gitea.tap-tap.win/taptap/charts/audiomanager \
|
|
||||||
--version "$VERSION" \
|
--version "$VERSION" \
|
||||||
--namespace audiomanager \
|
--namespace audiomanager \
|
||||||
--set users.existingSecret=audiomanager-users \
|
--set users.existingSecret=audiomanager-users \
|
||||||
--set imagePullSecrets[0].name=audiomanager-registry
|
--set imagePullSecrets[0].name=audiomanager-registry
|
||||||
```
|
```
|
||||||
|
|
||||||
Replace `VERSION` with the commit build shown in Gitea Actions or the package
|
For Kustomize, use the same repository with `build --enable-helm`:
|
||||||
list.
|
|
||||||
|
|
||||||
To package and push from a workstation, run `helm registry login` first and then:
|
```yaml
|
||||||
|
helmCharts:
|
||||||
```bash
|
- name: audiomanager
|
||||||
scripts/push-chart.sh # version from CI env, git, or Chart.yaml
|
releaseName: audiomanager
|
||||||
VERSION=0.2.0 scripts/push-chart.sh # explicit version
|
namespace: audiomanager
|
||||||
|
repo: https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main
|
||||||
|
version: 0.1.2-sha.<commit>
|
||||||
|
valuesFile: values.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
The script writes the `.tgz` to `dist/`, which is ignored by git.
|
```bash
|
||||||
|
kustomize build --enable-helm deploy/overlays/prod | kubectl apply -f -
|
||||||
|
```
|
||||||
|
|
||||||
|
`kubectl apply -k` does not run the Helm inflator; render with `kustomize build
|
||||||
|
--enable-helm` (or `kubectl kustomize --enable-helm`) first. Kustomize's Helm
|
||||||
|
generator cannot authenticate, which is why `TapTap/Charts` is public.
|
||||||
|
|
||||||
|
To publish from a workstation, either configure git credentials for
|
||||||
|
`TapTap/Charts` or pass a token explicitly:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CHARTS_TOKEN=<token> scripts/push-chart.sh
|
||||||
|
VERSION=0.2.0 CHARTS_TOKEN=<token> scripts/push-chart.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
The CI job uses the `AUDIOMANAGER_CHARTS_TOKEN` repository secret. The script
|
||||||
|
clones the chart repository, adds the packaged chart, regenerates `index.yaml`
|
||||||
|
and pushes to `main`.
|
||||||
|
|
||||||
### 9.4 Operations
|
### 9.4 Operations
|
||||||
|
|
||||||
|
|||||||
+63
-20
@@ -1,9 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Package the Helm chart and push it to the OCI registry.
|
# Package the Helm chart and publish it to the classic Helm chart repository
|
||||||
|
# in TapTap/Charts.
|
||||||
#
|
#
|
||||||
# Run `helm registry login <registry>` first (CI does this with the package
|
# The repository keeps index.yaml and the packaged .tgz files on its main
|
||||||
# token). The version is:
|
# branch, so it works with `helm repo add` and Kustomize's helmCharts
|
||||||
|
# generator. The version is:
|
||||||
# - VERSION if set,
|
# - VERSION if set,
|
||||||
# - the pushed tag for a v* tag build,
|
# - the pushed tag for a v* tag build,
|
||||||
# - <chart version>-sha.<commit> for a main branch build,
|
# - <chart version>-sha.<commit> for a main branch build,
|
||||||
@@ -12,30 +14,35 @@ set -euo pipefail
|
|||||||
|
|
||||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
REGISTRY="${REGISTRY:-gitea.tap-tap.win}"
|
CHARTS_REPO_URL="${CHARTS_REPO_URL:-https://gitea.tap-tap.win/TapTap/Charts.git}"
|
||||||
CHART_REPO="${CHART_REPO:-taptap/charts}"
|
CHARTS_BRANCH="${CHARTS_BRANCH:-main}"
|
||||||
|
CHARTS_USERNAME="${CHARTS_USERNAME:-TapTap}"
|
||||||
|
CHARTS_TOKEN="${CHARTS_TOKEN:-}"
|
||||||
|
CHARTS_RAW_URL="${CHARTS_RAW_URL:-https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main}"
|
||||||
CHART_DIR="${CHART_DIR:-$ROOT/charts/audiomanager}"
|
CHART_DIR="${CHART_DIR:-$ROOT/charts/audiomanager}"
|
||||||
OUTPUT_DIR="${OUTPUT_DIR:-$ROOT/dist}"
|
|
||||||
VERSION="${VERSION:-}"
|
VERSION="${VERSION:-}"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Usage: scripts/push-chart.sh [options]
|
Usage: scripts/push-chart.sh [options]
|
||||||
|
|
||||||
Push the chart to oci://<registry>/<chart-repo>/audiomanager.
|
Package the chart and publish it to the classic Helm repository in
|
||||||
|
TapTap/Charts.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help Show this help
|
-h, --help Show this help
|
||||||
|
|
||||||
Environment:
|
Environment:
|
||||||
REGISTRY OCI registry (default: gitea.tap-tap.win)
|
CHARTS_REPO_URL Git URL of the chart repository
|
||||||
CHART_REPO Repository path below the registry (default: taptap/charts)
|
(default: https://gitea.tap-tap.win/TapTap/Charts.git)
|
||||||
CHART_DIR Chart directory (default: charts/audiomanager)
|
CHARTS_BRANCH Published branch (default: main)
|
||||||
OUTPUT_DIR Directory for the packaged chart (default: dist)
|
CHARTS_USERNAME Git username for the chart repository (default: TapTap)
|
||||||
VERSION Chart version to package (overrides auto-detection)
|
CHARTS_TOKEN Token with write access to the chart repository. When empty,
|
||||||
|
normal git credentials are used.
|
||||||
Run `helm registry login <registry>` before this script if the registry is
|
CHARTS_RAW_URL Public URL written into index.yaml
|
||||||
private.
|
(default: https://gitea.tap-tap.win/TapTap/Charts/raw/branch/main)
|
||||||
|
CHART_DIR Chart directory (default: charts/audiomanager)
|
||||||
|
VERSION Chart version to package (overrides auto-detection)
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +69,46 @@ if [[ -z "$VERSION" ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$OUTPUT_DIR"
|
workdir="$(mktemp -d "${TMPDIR:-/tmp}/charts-publish.XXXXXX")"
|
||||||
package="$OUTPUT_DIR/$(basename "$CHART_DIR")-${VERSION}.tgz"
|
trap 'rm -rf "$workdir"' EXIT
|
||||||
|
|
||||||
helm package "$CHART_DIR" --version "$VERSION" --destination "$OUTPUT_DIR"
|
if [[ -n "$CHARTS_TOKEN" ]]; then
|
||||||
helm push "$package" "oci://${REGISTRY}/${CHART_REPO}"
|
askpass="$workdir/askpass.sh"
|
||||||
|
cat > "$askpass" <<'SH'
|
||||||
|
#!/bin/sh
|
||||||
|
case "$1" in
|
||||||
|
*Username*) printf '%s\n' "${CHARTS_USERNAME:?}" ;;
|
||||||
|
*Password*) printf '%s\n' "${CHARTS_TOKEN:?}" ;;
|
||||||
|
esac
|
||||||
|
SH
|
||||||
|
chmod 700 "$askpass"
|
||||||
|
export CHARTS_USERNAME CHARTS_TOKEN
|
||||||
|
export GIT_ASKPASS="$askpass"
|
||||||
|
export GIT_TERMINAL_PROMPT=0
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Pushed chart to oci://${REGISTRY}/${CHART_REPO}/$(basename "$CHART_DIR") --version ${VERSION}"
|
git clone --quiet --depth=1 --branch "$CHARTS_BRANCH" \
|
||||||
|
"$CHARTS_REPO_URL" "$workdir/repo"
|
||||||
|
|
||||||
|
chart_name="$(awk '/^name:/ { print $2; exit }' "$CHART_DIR/Chart.yaml")"
|
||||||
|
if [[ -f "$workdir/repo/${chart_name}-${VERSION}.tgz" ]]; then
|
||||||
|
echo "Chart $chart_name $VERSION is already published."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
helm package "$CHART_DIR" --version "$VERSION" --destination "$workdir/repo"
|
||||||
|
helm repo index "$workdir/repo" --url "$CHARTS_RAW_URL"
|
||||||
|
|
||||||
|
git -C "$workdir/repo" add .
|
||||||
|
if git -C "$workdir/repo" diff --cached --quiet; then
|
||||||
|
echo "Chart $(basename "$CHART_DIR") $VERSION is already published."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git -C "$workdir/repo" \
|
||||||
|
-c user.name="${GIT_AUTHOR_NAME:-Chart Publisher}" \
|
||||||
|
-c user.email="${GIT_AUTHOR_EMAIL:-charts@tap-tap.win}" \
|
||||||
|
commit -q -m "chart: publish $(basename "$CHART_DIR") $VERSION"
|
||||||
|
git -C "$workdir/repo" push -q origin "$CHARTS_BRANCH"
|
||||||
|
|
||||||
|
echo "Published $(basename "$CHART_DIR") $VERSION to $CHARTS_RAW_URL"
|
||||||
Reference in new issue
Block a user