diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f78855290..6df4975b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -508,9 +508,9 @@ jobs: - name: Install zig shell: pwsh run: | - # Get the zig version from build.zig so that it only needs to be updated - $fileContent = Get-Content -Path "build.zig" -Raw - $pattern = 'buildpkg\.requireZig\("(.*?)"\);' + # Get the zig version from build.zig.zon so that it only needs to be updated + $fileContent = Get-Content -Path "build.zig.zon" -Raw + $pattern = 'minimum_zig_version\s*=\s*"([^"]+)"' $zigVersion = [regex]::Match($fileContent, $pattern).Groups[1].Value $version = "zig-x86_64-windows-$zigVersion" Write-Output $version @@ -575,7 +575,7 @@ jobs: - name: Get required Zig version id: zig run: | - echo "version=$(sed -n -e 's/^.*requireZig("\(.*\)").*$/\1/p' build.zig)" >> $GITHUB_OUTPUT + echo "version=$(sed -n -E 's/^\s*\.?minimum_zig_version\s*=\s*"([^"]+)".*/\1/p' build.zig.zon)" >> $GITHUB_OUTPUT - name: Setup Cache uses: namespacelabs/nscloud-cache-action@7baedde84bbf5063413d621f282834bc2654d0c1 # v1.2.18 diff --git a/build.zig b/build.zig index 7b66af81a..205896390 100644 --- a/build.zig +++ b/build.zig @@ -2,9 +2,11 @@ const std = @import("std"); const assert = std.debug.assert; const builtin = @import("builtin"); const buildpkg = @import("src/build/main.zig"); +const appVersion = @import("build.zig.zon").version; +const minimumZigVersion = @import("build.zig.zon").minimum_zig_version; comptime { - buildpkg.requireZig("0.15.1"); + buildpkg.requireZig(minimumZigVersion); } pub fn build(b: *std.Build) !void { @@ -15,7 +17,8 @@ pub fn build(b: *std.Build) !void { // This defines all the available build options (e.g. `-D`). If you // want to know what options are available, you can run `--help` or // you can read `src/build/Config.zig`. - const config = try buildpkg.Config.init(b); + + const config = try buildpkg.Config.init(b, appVersion); const test_filters = b.option( [][]const u8, "test-filter", diff --git a/src/build/Config.zig b/src/build/Config.zig index 643dfe928..745fc926f 100644 --- a/src/build/Config.zig +++ b/src/build/Config.zig @@ -16,13 +16,6 @@ const expandPath = @import("../os/path.zig").expand; const gtk = @import("gtk.zig"); const GitVersion = @import("GitVersion.zig"); -/// The version of the next release. -/// -/// TODO: When Zig 0.14 is released, derive this from build.zig.zon directly. -/// Until then this MUST match build.zig.zon and should always be the -/// _next_ version to release. -const app_version: std.SemanticVersion = .{ .major = 1, .minor = 2, .patch = 1 }; - /// Standard build configuration options. optimize: std.builtin.OptimizeMode, target: std.Build.ResolvedTarget, @@ -69,7 +62,7 @@ emit_unicode_table_gen: bool = false, /// Environmental properties env: std.process.EnvMap, -pub fn init(b: *std.Build) !Config { +pub fn init(b: *std.Build, appVersion: []const u8) !Config { // Setup our standard Zig target and optimize options, i.e. // `-Doptimize` and `-Dtarget`. const optimize = b.standardOptimizeOption(.{}); @@ -217,6 +210,7 @@ pub fn init(b: *std.Build) !Config { // If an explicit version is given, we always use it. try std.SemanticVersion.parse(v) else version: { + const app_version = try std.SemanticVersion.parse(appVersion); // If no explicit version is given, we try to detect it from git. const vsn = GitVersion.detect(b) catch |err| switch (err) { // If Git isn't available we just make an unknown dev version. diff --git a/src/build/docker/debian/Dockerfile b/src/build/docker/debian/Dockerfile index 815d395cd..ffeef3d6a 100644 --- a/src/build/docker/debian/Dockerfile +++ b/src/build/docker/debian/Dockerfile @@ -24,12 +24,12 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get -qq update && \ WORKDIR /src -COPY ./build.zig /src +COPY ./build.zig ./build.zig.zon /src/ # Install zig # https://ziglang.org/download/ -RUN export ZIG_VERSION=$(sed -n -e 's/^.*requireZig("\(.*\)").*$/\1/p' build.zig) && curl -L -o /tmp/zig.tar.xz "https://ziglang.org/download/$ZIG_VERSION/zig-$(uname -m)-linux-$ZIG_VERSION.tar.xz" && \ +RUN export ZIG_VERSION=$(sed -n -E 's/^\s*\.?minimum_zig_version\s*=\s*"([^"]+)".*/\1/p' build.zig.zon) && curl -L -o /tmp/zig.tar.xz "https://ziglang.org/download/$ZIG_VERSION/zig-$(uname -m)-linux-$ZIG_VERSION.tar.xz" && \ tar -xf /tmp/zig.tar.xz -C /opt && \ rm /tmp/zig.tar.xz && \ ln -s "/opt/zig-$(uname -m)-linux-$ZIG_VERSION/zig" /usr/local/bin/zig @@ -41,4 +41,3 @@ RUN zig build \ -Dcpu=baseline RUN ./zig-out/bin/ghostty +version -