|
| 1 | +name: 'Setup TinyGo environment' |
| 2 | +description: 'Setup a TinyGo environment and add it to the PATH' |
| 3 | +inputs: |
| 4 | + version: |
| 5 | + description: 'The Go version to download and use. Must be a valid commitish, e.g. "dev" or "v1.0.0"' |
| 6 | + required: true |
| 7 | +runs: |
| 8 | + using: "composite" |
| 9 | + steps: |
| 10 | + - name: Install LLVM 13 |
| 11 | + run: | |
| 12 | + source /etc/os-release |
| 13 | + echo "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-13 main" | sudo tee /etc/apt/sources.list.d/llvm.list |
| 14 | + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - |
| 15 | + sudo apt-get -qq update |
| 16 | + sudo apt-get -yqq install clang-13 llvm-13-dev lld-13 libclang-13-dev |
| 17 | + shell: bash |
| 18 | + |
| 19 | + - uses: actions/setup-go@v3 |
| 20 | + with: |
| 21 | + go-version: 1.17 |
| 22 | + |
| 23 | + - name: Install Binaryen |
| 24 | + run: | |
| 25 | + pushd /dev/shm |
| 26 | + VERSION="$(curl -fsSLI -o /dev/null -w "%{url_effective}" https://github.com/WebAssembly/binaryen/releases/latest)" |
| 27 | + VERSION="${VERSION#https://github.com/WebAssembly/binaryen/releases/tag/}" |
| 28 | + curl -sfOL "https://github.com/WebAssembly/binaryen/releases/download/${VERSION}/binaryen-${VERSION}-$(uname -m)-linux.tar.gz" |
| 29 | + tar -xvf "binaryen-${VERSION}-$(uname -m)-linux.tar.gz" |
| 30 | + mkdir -p "${RUNNER_TOOL_CACHE}/binaryen" |
| 31 | + mv "binaryen-${VERSION}" "${RUNNER_TOOL_CACHE}/binaryen/${VERSION}" |
| 32 | + echo "${RUNNER_TOOL_CACHE}/binaryen/${VERSION}/bin" >> $GITHUB_PATH |
| 33 | + popd |
| 34 | + shell: bash |
| 35 | + |
| 36 | + - name: Install TinyGo |
| 37 | + run: | |
| 38 | + pushd /dev/shm |
| 39 | + mkdir tinygo |
| 40 | + cd tinygo |
| 41 | + git init |
| 42 | + git remote add origin https://github.com/tinygo-org/tinygo.git |
| 43 | + git fetch --prune --progress --no-tags --depth=1 origin "${{ inputs.version }}" |
| 44 | + git checkout --progress --force -B "${{ inputs.version }}" FETCH_HEAD |
| 45 | + git submodule update --init --recursive --depth 1 |
| 46 | + make wasi-libc |
| 47 | + mkdir -p "${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" |
| 48 | + GOBIN="${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" go install |
| 49 | + echo "${RUNNER_TOOL_CACHE}/tinygo/${{ inputs.version }}" >> $GITHUB_PATH |
| 50 | + popd |
| 51 | + shell: bash |
0 commit comments