Support wasm-pack on Windows

This commit is contained in:
Taiki Endo
2022-08-01 21:12:54 +09:00
parent de0e9b667c
commit f317c8aedc
4 changed files with 49 additions and 38 deletions

View File

@@ -25,10 +25,10 @@ jobs:
os: os:
- ubuntu-20.04 - ubuntu-20.04
tool: tool:
# Note: Specifying the version of valgrind and wasm-pack is not supported. # Note: Specifying the version of valgrind is not supported.
# cargo-watch is supported by cargo-binstall (through quickinstall) # cargo-watch is supported by cargo-binstall (through quickinstall)
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch - cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- cargo-hack@0.5.16,cargo-llvm-cov@0.4.13,cargo-minimal-versions@0.1.5,parse-changelog@0.5.0,cross@0.2.4,nextest@0.9.11,protoc@3.21.4,shellcheck@0.8.0,shfmt@3.5.1,wasmtime@0.39.1,mdbook@0.4.21,mdbook-linkcheck@0.7.6,cargo-watch@8.1.1 - cargo-hack@0.5.16,cargo-llvm-cov@0.4.13,cargo-minimal-versions@0.1.5,parse-changelog@0.5.0,cross@0.2.4,nextest@0.9.11,protoc@3.21.4,shellcheck@0.8.0,shfmt@3.5.1,wasm-pack@0.10.3,wasmtime@0.39.1,mdbook@0.4.21,mdbook-linkcheck@0.7.6,cargo-watch@8.1.1
# Nextest supports basic version ranges as well # Nextest supports basic version ranges as well
- nextest@0.9 - nextest@0.9
include: include:
@@ -39,7 +39,7 @@ jobs:
- os: macos-11 - os: macos-11
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- os: windows-2019 - os: windows-2019
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,wasmtime,mdbook,mdbook-linkcheck,cargo-watch tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3

View File

@@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased] ## [Unreleased]
- Support `wasm-pack` on Windows.
- Support specifying the version of `wasm-pack`.
## [1.10.2] - 2022-08-01 ## [1.10.2] - 2022-08-01
- Support `protoc` on Windows. - Support `protoc` on Windows.

View File

@@ -79,7 +79,7 @@ https://spdx.org/licenses
| [**shellcheck**](https://www.shellcheck.net) | `/usr/local/bin` | [GitHub Releases](https://github.com/koalaman/shellcheck/releases) | Linux, macOS, Windows | [GPL-3.0-or-later](https://github.com/koalaman/shellcheck/blob/HEAD/LICENSE) | | [**shellcheck**](https://www.shellcheck.net) | `/usr/local/bin` | [GitHub Releases](https://github.com/koalaman/shellcheck/releases) | Linux, macOS, Windows | [GPL-3.0-or-later](https://github.com/koalaman/shellcheck/blob/HEAD/LICENSE) |
| [**shfmt**](https://github.com/mvdan/sh) | `/usr/local/bin` | [GitHub Releases](https://github.com/mvdan/sh/releases) | Linux, macOS, Windows | [BSD-3-Clause](https://github.com/mvdan/sh/blob/HEAD/LICENSE) | | [**shfmt**](https://github.com/mvdan/sh) | `/usr/local/bin` | [GitHub Releases](https://github.com/mvdan/sh/releases) | Linux, macOS, Windows | [BSD-3-Clause](https://github.com/mvdan/sh/blob/HEAD/LICENSE) |
| [**valgrind**](https://valgrind.org) | `/snap/bin` | [snap](https://snapcraft.io/install/valgrind/ubuntu) | Linux | [GPL-2.0-or-later](https://valgrind.org/docs/manual/license.gpl.html) | | [**valgrind**](https://valgrind.org) | `/snap/bin` | [snap](https://snapcraft.io/install/valgrind/ubuntu) | Linux | [GPL-2.0-or-later](https://valgrind.org/docs/manual/license.gpl.html) |
| [**wasm-pack**](https://github.com/rustwasm/wasm-pack) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rustwasm/wasm-pack/releases) | Linux, macOS | [Apache-2.0](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-MIT) | | [**wasm-pack**](https://github.com/rustwasm/wasm-pack) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rustwasm/wasm-pack/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/rustwasm/wasm-pack/blob/HEAD/LICENSE-MIT) |
| [**wasmtime**](https://github.com/bytecodealliance/wasmtime) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/bytecodealliance/wasmtime/releases) | Linux, macOS, Windows | [Apache-2.0 WITH LLVM-exception](https://github.com/bytecodealliance/wasmtime/blob/HEAD/LICENSE) | | [**wasmtime**](https://github.com/bytecodealliance/wasmtime) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/bytecodealliance/wasmtime/releases) | Linux, macOS, Windows | [Apache-2.0 WITH LLVM-exception](https://github.com/bytecodealliance/wasmtime/blob/HEAD/LICENSE) |
If `$CARGO_HOME/bin` is not available, Rust-related binaries will be installed to `$HOME/.cargo/bin`.<br> If `$CARGO_HOME/bin` is not available, Rust-related binaries will be installed to `$HOME/.cargo/bin`.<br>

75
main.sh
View File

@@ -173,22 +173,25 @@ for tool in "${tools[@]}"; do
*) exit 1 ;; *) exit 1 ;;
esac esac
repo="taiki-e/${tool}" repo="taiki-e/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="x86_64-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;; darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;; cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in
latest) version="${latest_version}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz" url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz"
download "${url}" "${cargo_bin}" "${tool}${exe}" download "${url}" "${cargo_bin}" "${tool}${exe}"
;; ;;
cross) cross)
# https://github.com/cross-rs/cross/releases # https://github.com/cross-rs/cross/releases
latest_version="0.2.4" latest_version="0.2.4"
repo="cross-rs/cross" repo="cross-rs/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="x86_64-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;; darwin*) target="x86_64-apple-darwin" ;;
@@ -196,11 +199,8 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; 0.1.* | 0.2.[0-1]) url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}-${target}.tar.gz" ;;
esac *) url="https://github.com/${repo}/releases/download/v${version}/${tool}-${target}.tar.gz" ;;
case "${version}" in
0.1.* | 0.2.[0-1]) url="https://github.com/${repo}/releases/download/v${version}/cross-v${version}-${target}.tar.gz" ;;
*) url="https://github.com/${repo}/releases/download/v${version}/cross-${target}.tar.gz" ;;
esac esac
download "${url}" "${cargo_bin}" "${tool}${exe}" download "${url}" "${cargo_bin}" "${tool}${exe}"
;; ;;
@@ -230,7 +230,7 @@ for tool in "${tools[@]}"; do
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
miner_patch_version="${latest_version#*.}" miner_patch_version="${version#*.}"
base_url="https://github.com/${repo}/releases/download/v${miner_patch_version}/protoc-${miner_patch_version}" base_url="https://github.com/${repo}/releases/download/v${miner_patch_version}/protoc-${miner_patch_version}"
bin_dir="/usr/local/bin" bin_dir="/usr/local/bin"
include_dir="/usr/local/include" include_dir="/usr/local/include"
@@ -275,12 +275,12 @@ for tool in "${tools[@]}"; do
shellcheck) shellcheck)
# https://github.com/koalaman/shellcheck/releases # https://github.com/koalaman/shellcheck/releases
latest_version="0.8.0" latest_version="0.8.0"
repo="koalaman/shellcheck" repo="koalaman/${tool}"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
base_url="https://github.com/${repo}/releases/download/v${version}/shellcheck-v${version}" base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
bin="shellcheck-v${version}/shellcheck${exe}" bin="${tool}-v${version}/${tool}${exe}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
if type -P shellcheck &>/dev/null; then if type -P shellcheck &>/dev/null; then
@@ -291,7 +291,7 @@ for tool in "${tools[@]}"; do
darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;; darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;;
cygwin* | msys*) cygwin* | msys*)
url="${base_url}.zip" url="${base_url}.zip"
bin="shellcheck${exe}" bin="${tool}${exe}"
;; ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
@@ -301,6 +301,9 @@ for tool in "${tools[@]}"; do
# https://github.com/mvdan/sh/releases # https://github.com/mvdan/sh/releases
latest_version="3.5.1" latest_version="3.5.1"
repo="mvdan/sh" repo="mvdan/sh"
case "${version}" in
latest) version="${latest_version}" ;;
esac
bin_dir="/usr/local/bin" bin_dir="/usr/local/bin"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="linux_amd64" ;; linux*) target="linux_amd64" ;;
@@ -316,26 +319,23 @@ for tool in "${tools[@]}"; do
;; ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in url="https://github.com/${repo}/releases/download/v${version}/${tool}_v${version}_${target}${exe}"
latest) version="${latest_version}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/shfmt_v${version}_${target}${exe}"
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o "${bin_dir}/shfmt${exe}" "${url}" retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o "${bin_dir}/${tool}${exe}" "${url}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux* | darwin*) chmod +x "${bin_dir}/shfmt${exe}" ;; linux* | darwin*) chmod +x "${bin_dir}/${tool}${exe}" ;;
esac esac
;; ;;
valgrind) valgrind)
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported yet by this action" ;;
esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) ;; linux*) ;;
darwin* | cygwin* | msys*) bail "${tool} for non-linux is not supported yet by this action" ;; darwin* | cygwin* | msys*) bail "${tool} for non-linux is not supported yet by this action" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in
latest) ;;
*) warn "specifying the version of ${tool} is not supported yet by this action" ;;
esac
retry sudo apt-get -o Acquire::Retries=10 -qq update retry sudo apt-get -o Acquire::Retries=10 -qq update
# libc6-dbg is needed to run Valgrind # libc6-dbg is needed to run Valgrind
retry sudo apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y libc6-dbg retry sudo apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y libc6-dbg
@@ -344,22 +344,29 @@ for tool in "${tools[@]}"; do
retry sudo snap install valgrind --classic retry sudo snap install valgrind --classic
;; ;;
wasm-pack) wasm-pack)
# https://rustwasm.github.io/wasm-pack/installer # https://github.com/rustwasm/wasm-pack/releases
latest_version="0.10.3"
repo="rustwasm/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux* | darwin*) ;; linux*) target="x86_64-unknown-linux-musl" ;;
cygwin* | msys*) bail "${tool} for windows is not supported yet by this action" ;; darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused https://rustwasm.github.io/wasm-pack/installer/init.sh | sh url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}-${target}.tar.gz"
download "${url}" "${cargo_bin}" "${tool}-v${version}-${target}/${tool}${exe}"
;; ;;
wasmtime) wasmtime)
# https://github.com/bytecodealliance/wasmtime/releases # https://github.com/bytecodealliance/wasmtime/releases
latest_version="0.39.1" latest_version="0.39.1"
repo="bytecodealliance/wasmtime" repo="bytecodealliance/${tool}"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
base_url="https://github.com/bytecodealliance/wasmtime/releases/download/v${version}/wasmtime-v${version}" base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
target="x86_64-linux" target="x86_64-linux"
@@ -396,16 +403,16 @@ for tool in "${tools[@]}"; do
mdbook-linkcheck) mdbook-linkcheck)
# https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases # https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases
latest_version="0.7.6" latest_version="0.7.6"
repo="Michael-F-Bryan/mdbook-linkcheck" repo="Michael-F-Bryan/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-gnu" ;; linux*) target="x86_64-unknown-linux-gnu" ;;
darwin*) target="x86_64-apple-darwin" ;; darwin*) target="x86_64-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;; cygwin* | msys*) target="x86_64-pc-windows-msvc" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
case "${version}" in
latest) version="${latest_version}" ;;
esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}.${target}.zip" url="https://github.com/${repo}/releases/download/v${version}/${tool}.${target}.zip"
download "${url}" "${cargo_bin}" "${tool}${exe}" download "${url}" "${cargo_bin}" "${tool}${exe}"
case "${OSTYPE}" in case "${OSTYPE}" in