refactor: move version to Go source, extract in flake.nix

Define version once in cmd/oubliette/main.go and use builtins.match
in flake.nix to extract it. Add versioning guidelines to CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 16:56:54 +01:00
parent fc872b9c1b
commit 8e8f5366be
3 changed files with 15 additions and 1 deletions

View File

@@ -14,6 +14,16 @@ SSH honeypot written in Go. See `PLAN.md` for full project plan and architecture
- Keep code simple and focused. Refer to `PLAN.md` for design decisions. - Keep code simple and focused. Refer to `PLAN.md` for design decisions.
- When adding new config options, always add them to `oubliette.toml.example` as well. - When adding new config options, always add them to `oubliette.toml.example` as well.
## Versioning
We use **semver** (`MAJOR.MINOR.PATCH`). The version is defined in `cmd/oubliette/main.go` (`const Version`) and extracted automatically by `flake.nix`.
- **Patch** (`0.1.0``0.1.1`): Bug fixes, minor tweaks, documentation changes.
- **Minor** (`0.1.0``0.2.0`): New features, new config options, new shell types.
- **Major** (`0.x.y``1.0.0`): Breaking changes to config format or public interfaces.
Bump the version when merging a feature branch to master, not on every commit. While pre-1.0, breaking changes only require a minor bump.
## Git workflow ## Git workflow
- Use **conventional commits** (e.g. `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`). - Use **conventional commits** (e.g. `feat:`, `fix:`, `refactor:`, `docs:`, `test:`, `chore:`).

View File

@@ -12,6 +12,8 @@ import (
"git.t-juice.club/torjus/oubliette/internal/server" "git.t-juice.club/torjus/oubliette/internal/server"
) )
const Version = "0.1.0"
func main() { func main() {
configPath := flag.String("config", "oubliette.toml", "path to config file") configPath := flag.String("config", "oubliette.toml", "path to config file")
flag.Parse() flag.Parse()

View File

@@ -14,11 +14,13 @@
packages = forAllSystems (system: packages = forAllSystems (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
mainGo = builtins.readFile ./cmd/oubliette/main.go;
version = builtins.head (builtins.match ''.*const Version = "([^"]+)".*'' mainGo);
in in
{ {
default = pkgs.buildGoModule { default = pkgs.buildGoModule {
pname = "oubliette"; pname = "oubliette";
version = "0.1.0"; inherit version;
src = ./.; src = ./.;
vendorHash = "sha256-z/E1ZDfedOxI8CSUfcpFGYX0SrdcnAYuu2p0ATozDaA="; vendorHash = "sha256-z/E1ZDfedOxI8CSUfcpFGYX0SrdcnAYuu2p0ATozDaA=";
subPackages = [ "cmd/oubliette" ]; subPackages = [ "cmd/oubliette" ];