From f9316a428d8ec2c1872820e76f0c11d46d2d5110 Mon Sep 17 00:00:00 2001 From: Ryan Draga Date: Thu, 5 Nov 2026 00:15:11 -0500 Subject: [PATCH] Fix Versioning issue --- .gitignore | 1 + Makefile | 27 ++++++++++++++++--- README.md | 4 +-- .../helm/squirrelbot/templates/_helpers.tpl | 2 +- deploy/helm/squirrelbot/values.yaml | 2 +- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 132a67b..098a8db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin/ +build/ tmp/ .env web/node_modules/ diff --git a/Makefile b/Makefile index 9a47664..19779a8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -IMAGE ?= squirrelbot:0.1.0 +IMAGE_NAME ?= squirrelbot CONTAINER ?= $(shell command -v docker >/dev/null 2>&1 && echo docker || echo podman) COMPOSE = $(CONTAINER) compose @@ -15,7 +15,7 @@ help: 'up Bot and Postgres via $(CONTAINER)' \ 'down Stop $(CONTAINER) compose services' \ 'build Local bot binary and dashboard' \ - 'image Container image ($(IMAGE))' \ + 'image $(IMAGE_NAME):latest and the next patch version' \ 'test Go unit tests' \ 'test-e2e API and dashboard end-to-end tests' @@ -51,7 +51,28 @@ build-web: web/node_modules npm --prefix web run build image: - $(CONTAINER) build -t $(IMAGE) . + @mkdir -p build + @version_file=build/image-version; \ + if [ -f "$$version_file" ]; then \ + version=$$(tr -d '[:space:]' < "$$version_file"); \ + else \ + version=$$(awk '/^appVersion:/{gsub(/"/,"",$$2); print $$2; exit}' deploy/helm/squirrelbot/Chart.yaml); \ + fi; \ + case "$$version" in \ + *.*.*) ;; \ + *) echo "image version must be major.minor.patch, got $$version" >&2; exit 1 ;; \ + esac; \ + major=$${version%%.*}; \ + rest=$${version#*.}; \ + minor=$${rest%%.*}; \ + patch=$${rest#*.}; \ + case "$$patch" in \ + *[!0-9]*) echo "image patch must be a number, got $$patch" >&2; exit 1 ;; \ + esac; \ + next="$$major.$$minor.$$((10#$$patch + 1))"; \ + echo "Building $(IMAGE_NAME):$$next and $(IMAGE_NAME):latest"; \ + $(CONTAINER) build -t "$(IMAGE_NAME):$$next" -t "$(IMAGE_NAME):latest" . \ + && printf '%s\n' "$$next" > "$$version_file" test: go test ./... diff --git a/README.md b/README.md index 29efd7c..9eefe66 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Copy `.env.example` to `.env` and fill in the Discord token, OAuth client id, OA `make dev` starts Postgres, Air, and the dashboard at `http://localhost:5173`. Air rebuilds the bot when Go files, SQL migrations, or `.env` change. `make bot` and `make web` start those processes on their own, after `make db`. -`make build` writes `bin/squirrelbot` and `web/build`. `make image` builds the container `squirrelbot:0.1.0`. `make test` runs the Go unit tests. `make test-e2e` runs the API suite against Postgres and a Discord stand-in, then the browser suite against the dashboard. It starts the Compose Postgres if nothing is listening on port 5432. +`make build` writes `bin/squirrelbot` and `web/build`. `make image` builds `squirrelbot:latest` and the next patch version. `make test` runs the Go unit tests. `make test-e2e` runs the API suite against Postgres and a Discord stand-in, then the browser suite against the dashboard. It starts the Compose Postgres if nothing is listening on port 5432. `make up` runs the bot and Postgres in Docker. In that mode the dashboard is served by the bot on port 8080, so set `PUBLIC_URL` to `http://localhost:8080`. `make down` stops those containers. @@ -76,7 +76,7 @@ helm upgrade --install squirrelbot deploy/helm/squirrelbot \ Set `postgres.bundled=true` and `postgres.auth.password` to start a bundled Postgres StatefulSet. That database is for a single cluster and a small server. Use an external Postgres for anything you need to restore. `postgres.sslMode` sets the libpq mode on `DATABASE_URL` when the chart writes that URL. The default is `disable`. An `sslmode` already present in `secrets.databaseUrl` is left as written. -`make image` builds `squirrelbot:0.1.0` from the repository root. Override the tag with `make image IMAGE=squirrelbot:dev`. Set `imagePullSecrets` when the registry is private. +`make image` builds `squirrelbot:latest` and the next patch version from the repository root. The first build is one patch above the chart app version. Later builds increment the patch again. The last version is stored in `build/image-version`. Set `imagePullSecrets` when the registry is private. ## Releases diff --git a/deploy/helm/squirrelbot/templates/_helpers.tpl b/deploy/helm/squirrelbot/templates/_helpers.tpl index d5449fc..c2fec63 100644 --- a/deploy/helm/squirrelbot/templates/_helpers.tpl +++ b/deploy/helm/squirrelbot/templates/_helpers.tpl @@ -29,7 +29,7 @@ {{- end }} {{- define "squirrelbot.image" -}} -{{- $tag := .Values.image.tag | default .Chart.AppVersion }} +{{- $tag := .Values.image.tag | default "latest" }} {{- printf "%s:%s" .Values.image.repository $tag }} {{- end }} diff --git a/deploy/helm/squirrelbot/values.yaml b/deploy/helm/squirrelbot/values.yaml index 279de53..24be6f2 100644 --- a/deploy/helm/squirrelbot/values.yaml +++ b/deploy/helm/squirrelbot/values.yaml @@ -3,7 +3,7 @@ fullnameOverride: "" image: repository: squirrelbot - tag: "" + tag: latest pullPolicy: IfNotPresent imagePullSecrets: []