From 85dbc406ffa14613270fad1d462add7e949f08b0 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 27 Feb 2022 13:42:56 -0700 Subject: [PATCH] gpu-dawn: abide by GitHub release filename restrictions GitHub releases impose [some weird restrictions on uploaded filenames](https://twitter.com/slimsag/status/1498025997987315713), so we now abide by those. Signed-off-by: Stephen Gutekanst --- gpu-dawn/.github/workflows/ci.yml | 12 ++++++------ gpu-dawn/.github/workflows/m1_ci.yml | 12 ++++++------ gpu-dawn/build.zig | 10 +++++++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/gpu-dawn/.github/workflows/ci.yml b/gpu-dawn/.github/workflows/ci.yml index d3c1d962..2a79ccb6 100644 --- a/gpu-dawn/.github/workflows/ci.yml +++ b/gpu-dawn/.github/workflows/ci.yml @@ -91,9 +91,9 @@ jobs: AGREE: true - name: upload (debug) run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a - gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_debug.a.gz + mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_debug.a + gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_debug.a + gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_debug.a.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} x86_64-macos_release-fast: @@ -116,8 +116,8 @@ jobs: AGREE: true - name: upload (release-fast) run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a - gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1...12.1-gnu_release-fast.a.gz + mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_release-fast.a + gzip -9 zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_release-fast.a + gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12.1---12.1-gnu_release-fast.a.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gpu-dawn/.github/workflows/m1_ci.yml b/gpu-dawn/.github/workflows/m1_ci.yml index 9db46aee..b9f3dc49 100644 --- a/gpu-dawn/.github/workflows/m1_ci.yml +++ b/gpu-dawn/.github/workflows/m1_ci.yml @@ -29,9 +29,9 @@ jobs: AGREE: true - name: upload (debug) run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a - gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_debug.a.gz + mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_debug.a + gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_debug.a + gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_debug.a.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: install (release-fast) @@ -40,8 +40,8 @@ jobs: AGREE: true - name: upload (release-fast) run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a - gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1...12.1-gnu_release-fast.a.gz + mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_release-fast.a + gzip -9 zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_release-fast.a + gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12.1---12.1-gnu_release-fast.a.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gpu-dawn/build.zig b/gpu-dawn/build.zig index 48e67681..2968964d 100644 --- a/gpu-dawn/build.zig +++ b/gpu-dawn/build.zig @@ -227,7 +227,7 @@ pub fn linkFromBinary(b: *Builder, step: *std.build.LibExeObjStep, options: Opti } } -pub fn ensureBinaryDownloaded(allocator: std.mem.Allocator, triple: []const u8, is_release: bool, version: []const u8) void { +pub fn ensureBinaryDownloaded(allocator: std.mem.Allocator, zig_triple: []const u8, is_release: bool, version: []const u8) void { // If zig-cache/mach/gpu-dawn/ does not exist: // If on a commit in the main branch => rm -r zig-cache/mach/gpu-dawn/ // else => noop @@ -253,7 +253,7 @@ pub fn ensureBinaryDownloaded(allocator: std.mem.Allocator, triple: []const u8, } const release_tag = if (is_release) "release-fast" else "debug"; - const target_cache_dir = std.fs.path.join(allocator, &.{ commit_cache_dir, triple, release_tag }) catch unreachable; + const target_cache_dir = std.fs.path.join(allocator, &.{ commit_cache_dir, zig_triple, release_tag }) catch unreachable; if (dirExists(target_cache_dir)) { return; // nothing to do, already have the binary } @@ -261,13 +261,17 @@ pub fn ensureBinaryDownloaded(allocator: std.mem.Allocator, triple: []const u8, const download_dir = std.fs.path.join(allocator, &.{ target_cache_dir, "download" }) catch unreachable; std.fs.cwd().makePath(download_dir) catch unreachable; + // Replace "..." with "---" because GitHub releases has very weird restrictions on file names. + // https://twitter.com/slimsag/status/1498025997987315713 + const github_triple = std.mem.replaceOwned(u8, allocator, zig_triple, "...", "---") catch unreachable; + // Compose the download URL, e.g.: // https://github.com/hexops/mach-gpu-dawn/releases/download/release-2e5a4eb/libdawn_x86_64-macos_debug.a.gz const download_url = std.mem.concat(allocator, u8, &.{ "https://github.com/hexops/mach-gpu-dawn/releases/download/", version, "/libdawn_", - triple, + github_triple, "_", release_tag, ".a.gz",