From b5eb1b75dcd77c0dbedc9b42ae695993883fadc1 Mon Sep 17 00:00:00 2001 From: Ashish Jaiswal Date: Tue, 3 Nov 2026 14:50:00 +0530 Subject: [PATCH] chore(release): cut releases with cog Releases were tagged by hand and pushed to GitHub and to the Gitea mirror, which builds the Harbor image, in separate steps. Now `cog bump --auto` derives the version from the commits since the last tag, tags the merged commit with no bump commit or changelog since changes land through GitHub PRs, and pushes master and the tag to both remotes. It refuses to run unless the local master is exactly GitHub's, so a stale checkout cannot publish a release. The README and AGENTS.md release sections describe the flow. Signed-off-by: Ashish Jaiswal Entire-Checkpoint: 60fd497792ed --- AGENTS.md | 7 +++++++ README.md | 19 +++++++++++++++++++ cog.toml | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 cog.toml diff --git a/AGENTS.md b/AGENTS.md index 4473700..1cc5f40 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -50,6 +50,7 @@ config.example.yaml # Annotated example configuration testdata/config.yaml # Test fixture .goreleaser-github.yaml # Release config used by the GitHub release workflow .goreleaser-gitea.yaml # Release config used by the Gitea release workflow (release disabled, Harbor images only) +cog.toml # cocogitto release config: `cog bump` tags the merged master commit and pushes it to GitHub and Gitea Dockerfile # Multi-stage build (Go builder + Alpine runtime) .github/workflows/ test.yml # CI: tests, lint, fmt on push/PR @@ -123,6 +124,12 @@ For AI coding agents: after making code changes, run `go fix ./...` before tests - **Tests**: standard `testing` package, table-driven tests, `t.TempDir()` for temp dirs. Sync tests use in-process bare git repos created via `initBareAndClone()` helper. No external test dependencies or test frameworks. - **No Makefile**: build and test with standard `go` commands. +## Release + +- Cut with `cog bump --auto` (`cog.toml`) on a `master` that matches GitHub's; a pre-bump hook refuses otherwise. It tags the merged commit, with no bump commit or changelog since changes land through GitHub PRs, and pushes `master` and the tag to `origin` (GitHub) and `gitea` (the mirror, kept up to date only by this push). +- On GitHub the tag runs `.github/workflows/release.yml` (GoReleaser binaries, GitHub release, GHCR image); on Gitea it runs `.gitea/workflows/release.yml` (Harbor image only). +- `--auto` derives the version from the commit types since the last tag (`feat` minor, `fix` patch, `!` major), so commit subjects must follow the style below. + ## Git commit style - **Mandatory User Approval**: NEVER commit changes unless the user explicitly asks you to. diff --git a/README.md b/README.md index 9881c35..9e65583 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,25 @@ gfetch dev (commit: none, built: unknown) Version, commit, and build date are injected at build time via ldflags when using GoReleaser or a manual build with `-ldflags`. +## Release + +Releases are cut with [cocogitto](https://docs.cocogitto.io/) on a `master` +that matches GitHub's; `cog bump` refuses to run otherwise (cog 7.0.0 reports +that refusal as a `StashError` panic): + +```sh +cog bump --auto --dry-run # print the version it would cut +cog bump --auto +``` + +`--auto` picks the version from the commit types since the last tag; pass +`--patch`, `--minor` or `--major` instead to choose it. cog tags the merged +commit, with no bump commit since changes land through GitHub PRs, and pushes +`master` and the tag to `origin` (GitHub) and `gitea`. On GitHub the tag runs +[GoReleaser](https://goreleaser.com/), which publishes the release binaries and +the `ghcr.io/obmondo/gfetch` image; on Gitea it builds the +`harbor.obmondo.com/obmondo/gfetch` image. + ## Documentation [Configuration Reference](docs/configuration.md) diff --git a/cog.toml b/cog.toml new file mode 100644 index 0000000..843ff22 --- /dev/null +++ b/cog.toml @@ -0,0 +1,28 @@ +tag_prefix = "v" +branch_whitelist = ["master"] +ignore_merge_commits = true +disable_changelog = true +# Changes land through GitHub PRs, so tag the merged commit instead of adding one. +disable_bump_commit = true +# Older commits do not all follow Conventional Commits, so `cog check` starts +# at the latest tag. +from_latest_tag = true + +pre_bump_hooks = [ + # Tag exactly GitHub's master: not behind it, nothing unmerged on top. + # When one of these fails, cog 7.0.0 panics with a StashError instead of + # naming the hook; no tag is created and nothing is pushed. + "git fetch origin master", + "git merge-base --is-ancestor origin/master HEAD", + "git merge-base --is-ancestor HEAD origin/master", +] + +post_bump_hooks = [ + # origin is GitHub, where the tag builds the release and the GHCR image. + # gitea is a mirror that only these pushes keep up to date, and the tag there + # builds the Harbor image, so master and the tag go to both. cog stops at the + # first hook that fails and keeps the tag, so a failed gitea push is retried + # by hand: git push --no-follow-tags gitea master + "git push --no-follow-tags origin master {{version_tag}}", + "git push --no-follow-tags gitea master {{version_tag}}", +]