2020-12-11 01:23:39 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
# Ensure the directory exists
|
|
|
|
mkdir -p release/$TAG/wasm/
|
|
|
|
|
|
|
|
# Copy wasm javascript to match the go version
|
|
|
|
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" release/$TAG/wasm/
|
|
|
|
|
2020-12-15 19:10:56 +00:00
|
|
|
# Compress wasm javascript using brotli
|
|
|
|
brotli -k release/$TAG/wasm/wasm_exec.js
|
|
|
|
|
2020-12-11 01:23:39 +00:00
|
|
|
# Build wasm code
|
2022-03-23 13:29:47 +00:00
|
|
|
GOOS=js GOARCH=wasm go build -o release/$TAG/wasm/access.wasm storj.io/storj/satellite/console/wasm
|
2020-12-15 19:10:56 +00:00
|
|
|
|
2023-10-18 18:54:28 +01:00
|
|
|
# Take a hash of generated wasm code
|
|
|
|
hash=$(sha256sum release/$TAG/wasm/access.wasm | awk '{print $1}')
|
|
|
|
|
|
|
|
# Define new file name
|
|
|
|
filename="access.${hash:0:8}.wasm"
|
|
|
|
|
|
|
|
# Rename the file to include the hash
|
|
|
|
mv release/$TAG/wasm/access.wasm release/$TAG/wasm/$filename
|
|
|
|
|
2020-12-15 19:10:56 +00:00
|
|
|
# Compress wasm code using brotli
|
2023-10-18 18:54:28 +01:00
|
|
|
brotli -k release/$TAG/wasm/$filename
|
|
|
|
|
|
|
|
# Generate the manifest which would contain our new file name
|
|
|
|
echo "{\"fileName\": \"$filename\"}" > release/$TAG/wasm/wasm-manifest.json
|