From 7a8c9317bc98e11dbcc19adb05fb5fb4c54ee6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Tue, 17 Oct 2023 15:35:44 +0200 Subject: [PATCH] ci: create install-wasm-opt reusable action (#4012) --- .github/actions/install-wasm-opt/action.yml | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/actions/install-wasm-opt/action.yml diff --git a/.github/actions/install-wasm-opt/action.yml b/.github/actions/install-wasm-opt/action.yml new file mode 100644 index 0000000000..3eb84c119f --- /dev/null +++ b/.github/actions/install-wasm-opt/action.yml @@ -0,0 +1,37 @@ +name: 'Install wasm-opt' +description: 'Installs wasm-opt from binaryen' +inputs: + version: + description: 'Version of wasm-opt to install' + default: '116' +runs: + using: 'composite' + steps: + - name: Check platform compatibility + run: | + if [[ "$(uname)" != "Linux" ]]; then + echo "Error: This action is only compatible with Linux." + exit 1 + fi + shell: bash + + - name: Download wasm-opt + run: | + set -e + SOURCE="https://github.com/WebAssembly/binaryen/releases/download/version_${{ inputs.version }}/binaryen-version_${{ inputs.version }}-x86_64-linux.tar.gz" + TEMP_ARCHIVE="$RUNNER_TEMP/binaryen-version_${{ inputs.version }}-x86_64-linux.tar.gz" + curl -L -o "$TEMP_ARCHIVE" "$SOURCE" + tar -xvzf $TEMP_ARCHIVE -C $RUNNER_TEMP + echo "$RUNNER_TEMP/binaryen-version_${{ inputs.version }}/bin" >> $GITHUB_PATH + shell: bash + id: install-binary + + - name: Verify installation + run: | + if ! command -v wasm-opt &> /dev/null; then + echo "Error: wasm-opt binary was not installed successfully." + exit 1 + fi + shell: bash + id: verify-installation +