From 028b7d80340fe94984854a97e7505a049f9a5f48 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 27 Feb 2022 19:29:56 -0700 Subject: [PATCH] gpu-dawn: CI: upload headers.json + tarball Fixes hexops/mach#171 Helps hexops/mach#109 Signed-off-by: Stephen Gutekanst --- gpu-dawn/.github/workflows/ci.yml | 24 ++++++++---------------- gpu-dawn/.github/workflows/m1_ci.yml | 13 +++++-------- gpu-dawn/dev/bundle-release.sh | 24 ++++++++++++++++++++++++ gpu-dawn/dev/dir_to_json.py | 12 ++++++++++++ gpu-dawn/dev/upload-release.sh | 20 ++++++++++++++++++++ 5 files changed, 69 insertions(+), 24 deletions(-) create mode 100755 gpu-dawn/dev/bundle-release.sh create mode 100644 gpu-dawn/dev/dir_to_json.py create mode 100755 gpu-dawn/dev/upload-release.sh diff --git a/gpu-dawn/.github/workflows/ci.yml b/gpu-dawn/.github/workflows/ci.yml index f0acdd24..91d24314 100644 --- a/gpu-dawn/.github/workflows/ci.yml +++ b/gpu-dawn/.github/workflows/ci.yml @@ -22,11 +22,9 @@ jobs: - name: install (debug) run: zig build install -Ddawn-from-source=true -Dtarget=x86_64-linux - name: upload (debug) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_debug.a - gzip -9 zig-out/lib/libdawn_x86_64-linux-gnu_debug.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_debug.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: x86_64-linux-gnu_debug GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} x86_64-linux_release-fast: runs-on: ubuntu-latest @@ -45,11 +43,9 @@ jobs: - name: install (release-fast) run: zig build install -Ddawn-from-source=true -Drelease-fast=true -Dtarget=x86_64-linux - name: upload (release-fast) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a - gzip -9 zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-linux-gnu_release-fast.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: x86_64-linux-gnu_release-fast GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # TODO(build-system): enable windows CI here once gpu-dawn builds under Windows # x86_64-windows: @@ -90,11 +86,9 @@ jobs: env: AGREE: true - name: upload (debug) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12---12-gnu_debug.a - gzip -9 zig-out/lib/libdawn_x86_64-macos.12---12-gnu_debug.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12---12-gnu_debug.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: x86_64-macos.12---12-gnu_debug GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} x86_64-macos_release-fast: runs-on: macos-latest @@ -115,9 +109,7 @@ jobs: env: AGREE: true - name: upload (release-fast) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_x86_64-macos.12---12-gnu_release-fast.a - gzip -9 zig-out/lib/libdawn_x86_64-macos.12---12-gnu_release-fast.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_x86_64-macos.12---12-gnu_release-fast.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: x86_64-macos.12---12-gnu_release-fast GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gpu-dawn/.github/workflows/m1_ci.yml b/gpu-dawn/.github/workflows/m1_ci.yml index a3502ada..898ff658 100644 --- a/gpu-dawn/.github/workflows/m1_ci.yml +++ b/gpu-dawn/.github/workflows/m1_ci.yml @@ -28,20 +28,17 @@ jobs: env: AGREE: true - name: upload (debug) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12---12-gnu_debug.a - gzip -9 zig-out/lib/libdawn_aarch64-macos.12---12-gnu_debug.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12---12-gnu_debug.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: aarch64-macos.12---12-gnu_debug GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: install (release-fast) run: zig build install -Ddawn-from-source=true -Drelease-fast=true -Dtarget=aarch64-macos.12 env: AGREE: true - name: upload (release-fast) - run: | - mv zig-out/lib/libdawn.a zig-out/lib/libdawn_aarch64-macos.12---12-gnu_release-fast.a - gzip -9 zig-out/lib/libdawn_aarch64-macos.12---12-gnu_release-fast.a - gh release upload "release-$(git rev-parse --short HEAD)" zig-out/lib/libdawn_aarch64-macos.12---12-gnu_release-fast.a.gz + run: ./dev/upload-release.sh env: + RELEASE_NAME: aarch64-macos.12---12-gnu_release-fast + UPLOAD_HEADERS: true GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/gpu-dawn/dev/bundle-release.sh b/gpu-dawn/dev/bundle-release.sh new file mode 100755 index 00000000..bbd7776d --- /dev/null +++ b/gpu-dawn/dev/bundle-release.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -exuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")"/.. + +# Prepare the `out/` directory that we will bundle. +rm -rf out/ +mkdir out/ +cp -R libs/dawn/include out/ +cp -R libs/dawn/out/Debug/gen/include/* out/include/ +cp libs/dawn/LICENSE out/ + +# Bundle headers.json.gz +pushd out +python ../dev/dir_to_json.py > ../headers.json +popd +gzip -9 headers.json + +# Copy the binary into the out/ directory +cp zig-out/lib/libdawn.a out/ + +# Create out.tar.gz bundle +pushd out +tar -czvf ../out.tar.gz . +popd diff --git a/gpu-dawn/dev/dir_to_json.py b/gpu-dawn/dev/dir_to_json.py new file mode 100644 index 00000000..a697c08f --- /dev/null +++ b/gpu-dawn/dev/dir_to_json.py @@ -0,0 +1,12 @@ +import os +import json + +def dir_to_dict(d): + dict = {} + for dirpath,_,filenames in os.walk(d): + for f in filenames: + path = os.path.join(dirpath, f) + dict[path] = open(path, 'r').read() + return dict + +print(json.dumps(dir_to_dict('.'))) diff --git a/gpu-dawn/dev/upload-release.sh b/gpu-dawn/dev/upload-release.sh new file mode 100755 index 00000000..d49d416f --- /dev/null +++ b/gpu-dawn/dev/upload-release.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -exuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")"/.. + +# Prepare tarball, headers.json.gz, etc. +./dev/bundle-release.sh + +if [[ "${UPLOAD_HEADERS:-"false"}" == "true" ]]; then + # Upload headers.json.gz + gh release upload "release-$(git rev-parse --short HEAD)" headers.json.gz +fi + +# Upload static library individually. +cp zig-out/lib/libdawn.a "libdawn_$RELEASE_NAME.a" +gzip -9 "libdawn_$RELEASE_NAME.a" +gh release upload "release-$(git rev-parse --short HEAD)" "libdawn_$RELEASE_NAME.a" + +# Upload tarball of static library + headers. +mv out.tar.gz "$RELEASE_NAME.tar.gz" +gh release upload "release-$(git rev-parse --short HEAD)" "$RELEASE_NAME.tar.gz"