Get app_version from build.zig.zon .version (#9101)
Reads .version from build.zig.zon and passes it to Config.pull/9110/head
commit
f2c7f4ec0f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue