From df5c48790a8c020f78732dd11daf9b96089b40b9 Mon Sep 17 00:00:00 2001 From: Brianna Becker Date: Mon, 16 Sep 2024 12:59:26 +0200 Subject: [PATCH] Update build and release to include wasm on release --- .github/workflows/build.yml | 4 +++- .github/workflows/release.yml | 4 +++- packages/node-hcl/package.json | 6 +----- packages/node-hcl/scripts/get-wasm.sh | 8 ++++++++ packages/node-hcl/scripts/go-build.sh | 9 +++------ 5 files changed, 18 insertions(+), 13 deletions(-) create mode 100755 packages/node-hcl/scripts/get-wasm.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ae26fe..2d38d3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,9 +110,11 @@ jobs: cache-dependency-path: | packages/node-hcl/go.sum - run: yarn install - - run: yarn run lerna run build:go --stream - run: yarn tsc - run: yarn backstage-cli repo build + - run: yarn run lerna run build:go --stream + env: + WASM_OUTPUT_DIR: dist/wasm - run: yarn multi-semantic-release --ignore-private-packages --dry-run env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e186689..2e297ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,9 +27,11 @@ jobs: cache-dependency-path: | packages/node-hcl/go.sum - run: yarn install - - run: yarn run lerna run build:go --stream - run: yarn tsc - run: yarn backstage-cli repo build + - run: yarn run lerna run build:go --stream + env: + WASM_OUTPUT_DIR: dist/wasm - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/packages/node-hcl/package.json b/packages/node-hcl/package.json index d253936..d203b23 100644 --- a/packages/node-hcl/package.json +++ b/packages/node-hcl/package.json @@ -18,11 +18,7 @@ "test:go": "scripts/go-test.sh", "test": "backstage-cli package test", "tsc": "tsc", - "tsc:full": "tsc --skipLibCheck false --incremental false", - "lint": "backstage-cli package lint", - "clean": "backstage-cli package clean", - "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" + "tsc:full": "tsc --skipLibCheck false --incremental false" }, "devDependencies": { "@types/fs-extra": "11.0.4", diff --git a/packages/node-hcl/scripts/get-wasm.sh b/packages/node-hcl/scripts/get-wasm.sh new file mode 100755 index 0000000..831baaf --- /dev/null +++ b/packages/node-hcl/scripts/get-wasm.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# +# Copyright SeatGeek +# Licensed under the terms of the Apache-2.0 license. See LICENSE file in project root for terms. +# +wasm_dir=${WASM_OUTPUT_DIR:-"src/wasm"} +echo "Copying wasm_exec.js from GOROOT" +cp -rf "$(go env GOROOT)/misc/wasm/wasm_exec.js" $wasm_dir diff --git a/packages/node-hcl/scripts/go-build.sh b/packages/node-hcl/scripts/go-build.sh index 8bb3bf6..87fba93 100755 --- a/packages/node-hcl/scripts/go-build.sh +++ b/packages/node-hcl/scripts/go-build.sh @@ -3,15 +3,12 @@ # Copyright SeatGeek # Licensed under the terms of the Apache-2.0 license. See LICENSE file in project root for terms. # -wasm_dir="src/wasm" -echo "Copying wasm_exec.js from GOROOT" -cp -rf "$(go env GOROOT)/misc/wasm/wasm_exec.js" $wasm_dir - -echo "Building WASM" - +wasm_dir=${WASM_OUTPUT_DIR:-"src/wasm"} +echo "Packaging WASM" wasm_path="$wasm_dir/main.wasm" GOOS=js GOARCH=wasm go get . GOOS=js GOARCH=wasm go build -o $wasm_path gzip -9 -v -c $wasm_path > $wasm_path.gz +rm $wasm_path echo "WASM exported to $wasm_path.gz"