From c923f9446945a742c5aba108745ec6de2d8f4214 Mon Sep 17 00:00:00 2001 From: Laurynas Keturakis Date: Thu, 26 Mar 2026 16:17:46 +0100 Subject: [PATCH] fix: inject release version into drift binary --- .claude/skills/drift/SKILL.md | 8 ++++---- .github/workflows/release.yml | 2 +- README.md | 13 +++++++++++++ build.zig | 5 +++++ docs/CLI.md | 2 +- docs/DECISIONS.md | 6 +++--- docs/DESIGN.md | 10 +++++----- docs/RELEASING.md | 6 +++--- src/main.zig | 3 ++- 9 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.claude/skills/drift/SKILL.md b/.claude/skills/drift/SKILL.md index baff949..d16875d 100644 --- a/.claude/skills/drift/SKILL.md +++ b/.claude/skills/drift/SKILL.md @@ -3,10 +3,10 @@ name: drift description: Drift spec-to-code anchor conventions. Use when editing code that is bound by drift specs, updating specs, working with drift frontmatter, or when drift check reports stale anchors. drift: files: - - src/main.zig@a7ffa398 - - src/frontmatter.zig@a7ffa398 - - src/scanner.zig@a7ffa398 - - src/vcs.zig@a7ffa398 + - src/main.zig@2d3a4080 + - src/frontmatter.zig@2d3a4080 + - src/scanner.zig@2d3a4080 + - src/vcs.zig@2d3a4080 --- # Drift diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5c5a381..29cce29 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ jobs: version: 0.15.2 - name: Build - run: zig build -Doptimize=ReleaseSafe -Dtarget=${{ matrix.zig-target }} ${{ matrix.zig-cpu && format('-Dcpu={0}', matrix.zig-cpu) || '' }} + run: zig build -Doptimize=ReleaseSafe -Dversion=${{ github.ref_name }} -Dtarget=${{ matrix.zig-target }} ${{ matrix.zig-cpu && format('-Dcpu={0}', matrix.zig-cpu) || '' }} - name: Package run: | diff --git a/README.md b/README.md index ec35be0..6627f7f 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,22 @@ Any markdown file in your repo can declare anchors to code — specific files or curl -fsSL https://drift.fp.dev/install.sh | sh ``` +To install a specific version: + +```bash +curl -fsSL https://drift.fp.dev/install.sh | sh -s -- --version vX.Y.Z +``` + +Or build from source: + +```bash +zig build -Doptimize=ReleaseSafe --prefix ~/.local +``` + ### Coding agent skill (Claude Code, Codex) ```bash +curl -fsSL https://drift.fp.dev/install.sh | sh npx skills add fiberplane/drift ``` diff --git a/build.zig b/build.zig index a6b5566..0b26b0b 100644 --- a/build.zig +++ b/build.zig @@ -3,6 +3,7 @@ const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + const version = b.option([]const u8, "version", "Drift version string") orelse "0.0.0-dev"; // Dependencies const clap_dep = b.dependency("clap", .{}); @@ -10,6 +11,9 @@ pub fn build(b: *std.Build) void { // Build tree-sitter C library from vendor sources const ts_module = buildTreeSitter(b, target, optimize); + const build_options = b.addOptions(); + build_options.addOption([]const u8, "version", version); + // Root module const root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), @@ -21,6 +25,7 @@ pub fn build(b: *std.Build) void { .{ .name = "tree_sitter", .module = ts_module }, }, }); + root_module.addOptions("build_options", build_options); linkGrammars(b, root_module); // Executable diff --git a/docs/CLI.md b/docs/CLI.md index d477199..d817370 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -1,7 +1,7 @@ --- drift: files: - - src/main.zig@a7ffa398 + - src/main.zig@2d3a4080 --- # CLI Reference diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index b19d492..8fa1826 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -1,9 +1,9 @@ --- drift: files: - - src/main.zig@a7ffa398 - - src/symbols.zig@a7ffa398 - - src/vcs.zig@a7ffa398 + - src/main.zig@2d3a4080 + - src/symbols.zig@2d3a4080 + - src/vcs.zig@2d3a4080 --- # Decisions diff --git a/docs/DESIGN.md b/docs/DESIGN.md index d7cb540..49b3c90 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1,11 +1,11 @@ --- drift: files: - - src/main.zig@a7ffa398 - - src/frontmatter.zig@a7ffa398 - - src/scanner.zig@a7ffa398 - - src/symbols.zig@a7ffa398 - - src/vcs.zig@a7ffa398 + - src/main.zig@2d3a4080 + - src/frontmatter.zig@2d3a4080 + - src/scanner.zig@2d3a4080 + - src/symbols.zig@2d3a4080 + - src/vcs.zig@2d3a4080 --- # Design diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 9b5d449..ea9f471 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -1,9 +1,9 @@ --- drift: files: - - .github/workflows/release.yml@xxoutkyz - - .github/workflows/ci.yml@xxoutkyz - - cliff.toml@xxoutkyz + - .github/workflows/release.yml@2d3a4080 + - .github/workflows/ci.yml@2d3a4080 + - cliff.toml@2d3a4080 --- # Releasing diff --git a/src/main.zig b/src/main.zig index 914a92f..1772be8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,4 +1,5 @@ const std = @import("std"); +const build_options = @import("build_options"); const clap = @import("clap"); const frontmatter = @import("frontmatter.zig"); const scanner = @import("scanner.zig"); @@ -7,7 +8,7 @@ const vcs = @import("vcs.zig"); const Spec = scanner.Spec; -const version = "0.1.0"; +const version = build_options.version; const SubCommand = enum { check,