#!/bin/sh # release-image.sh — build the zddc-server runtime image locally and push it # to codeberg.org/varasys/zddc-server with cascading channel tags. # # Usage: # sh release-image.sh [alpha|beta|stable] # # alpha → : :alpha (default — for active dev) # beta → : :beta :alpha # stable → : :stable :beta :alpha # # Examples: # sh release-image.sh 0.0.4 # → :0.0.4 :alpha (default) # sh release-image.sh 0.0.4 beta # → :0.0.4 :beta :alpha # sh release-image.sh 0.0.4 stable # → :0.0.4 :stable :beta :alpha # # Why alpha is the default: `:stable` should only advance on a deliberate # promotion, not as a side-effect of every dev release. With alpha as # default, `sh release-image.sh ` always lands on the alpha # channel; the `:stable` tag stays put until you explicitly pass `stable`. # # Convention: cut a git tag first (`git tag zddc-server-v0.0.4 && git push # origin zddc-server-v0.0.4`) so version history is auditable, then run this # to publish the image. The two are coordinated by hand, deliberately — # `.woodpecker.yml` is gone; this script is the canonical path. # # Prerequisites: # - podman (or substitute docker — the commands below are identical) # - logged in to codeberg.org: `podman login codeberg.org` # (your Codeberg username + a personal token with `package:write` scope, # generated at https://codeberg.org/user/settings/applications) # # What it does: # 1. Runs `sh build.sh` so zddc/dist/web/{index.html,archive.html} reflect # current source — those get COPYd into the runtime image. # 2. Builds zddc/Containerfile's `server` stage as a single local image. # 3. Tags that image with each cascade tag and pushes them in turn. set -eu usage() { echo "usage: $0 [alpha|beta|stable]" >&2 echo " channel default: alpha (active dev)" >&2 echo " version: e.g. 0.0.4, 0.0.4-beta.1, 0.0.4-alpha.2" >&2 exit 1 } [ $# -ge 1 ] || usage VERSION="$1" CHANNEL="${2:-alpha}" case "$CHANNEL" in alpha) TAGS="$VERSION alpha" ;; beta) TAGS="$VERSION beta alpha" ;; stable) TAGS="$VERSION stable beta alpha" ;; *) echo "error: unknown channel: $CHANNEL (expected alpha|beta|stable)" >&2; exit 1 ;; esac REPO="codeberg.org/varasys/zddc-server" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) # Pick podman or docker, whichever is on PATH. if command -v podman >/dev/null 2>&1; then OCI=podman elif command -v docker >/dev/null 2>&1; then OCI=docker else echo "error: neither podman nor docker found on PATH" >&2 exit 1 fi echo "=== Building $REPO ===" echo "Version: $VERSION" echo "Channel: $CHANNEL" echo "Tags: $TAGS" echo "OCI CLI: $OCI" echo # Refresh dist/web — the Containerfile's server stage COPYs them in. sh "$SCRIPT_DIR/build.sh" # Build the runtime image as a single local tag, then re-tag for each cascade # entry so the build runs once and the pushes are cheap layer reuses. "$OCI" build --target server -t zddc-server:build "$SCRIPT_DIR/zddc/" echo echo "=== Pushing tags ===" for tag in $TAGS; do "$OCI" tag zddc-server:build "$REPO:$tag" "$OCI" push "$REPO:$tag" echo "pushed $REPO:$tag" done echo echo "=== Done ===" echo "Image is live at $REPO:$VERSION" echo "Tags published: $TAGS" echo echo "Next: bump tnd-zddc-chart (push to develop) so the chart's CI rebuilds" echo "the dev-shell image against the new :beta and helm-rolls the cluster."