diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 3e29fbc..b5a3ed0 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -39,7 +39,7 @@ jobs: ./scripts/run-ci-wasm.sh ls -la - name: Dist prep - run: ./dist-prep.sh + run: ./dist-prep.sh ${{ matrix.target }} - name: Artifacts uses: actions/upload-artifact@v3 with: diff --git a/dist-prep.sh b/dist-prep.sh index 4ef59f7..9d2f6a9 100755 --- a/dist-prep.sh +++ b/dist-prep.sh @@ -1,6 +1,8 @@ #!/bin/bash set -e +build_target="$1" + echoerr() { echo "$@" 1>&2; } function assertFile { @@ -15,13 +17,33 @@ rm -rf dist/* ls -la libheif -cp libheif/libheif.js dist/libheif.js -cp libheif/COPYING dist/LICENSE -cp libheif/libheif.wasm dist/libheif.wasm || echo wasm not found +function copyJs() { + cp libheif/libheif.js dist/libheif.js + cp libheif/COPYING dist/LICENSE + + assertFile dist/libheif.js + assertFile dist/LICENSE + + chown $(whoami) dist/libheif.js dist/LICENSE +} + +function copyWasm() { + copyJs + + cp libheif/libheif.wasm dist/libheif.wasm + assertFile dist/libheif.wasm + chown $(whoami) dist/libheif.wasm +} -assertFile dist/libheif.js -assertFile dist/LICENSE +if [ "$build_target" = "js" ] +then + copyJs +elif [ "$build_target" = "wasm" ] +then + copyWasm +else + echo "unknown build target: $build_target" + exit 1 +fi -chown $(whoami) dist/libheif.js dist/LICENSE -chown $(whoami) dist/libheif.wasm || echo wasm not found ls -la dist