-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
72 lines (64 loc) · 2.39 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: phi.ag - Setup Binaryen
description: Minimal shell script action to setup Binaryen
author: phi.ag
inputs:
version:
description: Binaryen version
required: false
token:
description: GitHub token used to fetch Binaryen release
default: ${{ github.token }}
branding:
icon: download
color: orange
runs:
using: composite
steps:
- name: Setup Binaryen
shell: bash
env:
BINARYEN_VERSION: version_121
run: |
VERSION=$([ "${{ inputs.version }}" ] && echo version_${{ inputs.version }} || echo ${BINARYEN_VERSION})
TOOL_PATH="${RUNNER_TOOL_CACHE:?}/binaryen/${VERSION:?}/${RUNNER_ARCH:?}"
TOOL_PATH_COMPLETE="${TOOL_PATH}.complete"
echo "${TOOL_PATH}/bin" >> ${GITHUB_PATH}
[ -f "${TOOL_PATH_COMPLETE}" ] && exit 0
if [ "${RUNNER_OS}" = "Linux" ]; then
if [ "${RUNNER_ARCH}" = "X64" ]; then
TARGET="x86_64-linux"
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
TARGET="aarch64-linux"
else
echo >&2 "Unsupported Linux architecture: ${RUNNER_ARCH}"
exit 1
fi
elif [ "${RUNNER_OS}" = "Windows" ]; then
if [ "${RUNNER_ARCH}" = "X64" ]; then
TARGET="x86_64-windows"
else
echo >&2 "Unsupported Windows architecture: ${RUNNER_ARCH}"
exit 1
fi
elif [ "${RUNNER_OS}" = "macOS" ]; then
if [ "${RUNNER_ARCH}" = "X64" ]; then
TARGET="x86_64-macos"
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
TARGET="arm64-macos"
else
echo >&2 "Unsupported macOS architecture: ${RUNNER_ARCH}"
exit 1
fi
else
echo >&2 "Unsupported runner os: ${RUNNER_OS}"
exit 1
fi
echo "Target ${TARGET}"
command -v curl >/dev/null 2>&1 || { echo >&2 "curl not installed"; exit 1; }
command -v tar >/dev/null 2>&1 || { echo >&2 "tar not installed"; exit 1; }
mkdir -p "${TOOL_PATH}"
curl -L --no-progress-meter --fail-with-body \
--header "Authorization: Bearer ${{ inputs.token }}" \
https://github.com/WebAssembly/binaryen/releases/download/${VERSION}/binaryen-${VERSION}-${TARGET:?}.tar.gz \
| tar zxv -C "${TOOL_PATH}" --strip-components 1 binaryen-${VERSION}/bin/ binaryen-${VERSION}/lib/
touch "${TOOL_PATH_COMPLETE}"