diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c0422d0..b9aaf13d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,19 +27,19 @@ jobs: tool: # Note: Specifying the version of valgrind and wasm-pack is not supported. # cargo-watch is supported by cargo-binstall (through quickinstall) - - cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,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,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,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 # Nextest supports basic version ranges as well - nextest@0.9 include: # Note: mdBook binary is incompatible with ubuntu 18.04, # see https://github.com/rust-lang/mdBook/issues/1779 - os: ubuntu-18.04 - tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook-linkcheck,cargo-watch + tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook-linkcheck,cargo-watch - os: macos-11 - tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,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 - tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,wasmtime,mdbook,mdbook-linkcheck,cargo-watch + tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,protoc,shellcheck,shfmt,wasmtime,mdbook,mdbook-linkcheck,cargo-watch runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index a13d6b0b..59978926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +- Support `protoc`. +- Support `shellcheck` on Windows. +- Support `shfmt` on Windows. + ## [1.8.4] - 2022-08-01 - Update `cargo-llvm-cov@latest` to 0.4.13. @@ -25,13 +29,13 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [1.8.1] - 2022-07-26 -- Fix cargo-binstall installation failure. +- Fix `cargo-binstall` installation failure. ## [1.8.0] - 2022-07-26 - Only use musl binaries for nextest if glibc isn't available. See [#13](https://github.com/taiki-e/install-action/issues/13) for more. -- Fix cargo-binstall installation failure. ([#16](https://github.com/taiki-e/install-action/pull/16), thanks @CAD97) +- Fix `cargo-binstall` installation failure. ([#16](https://github.com/taiki-e/install-action/pull/16), thanks @CAD97) - Accept `cargo-nextest` as an alias for `nextest`. ([#15](https://github.com/taiki-e/install-action/pull/15), thanks @CAD97) @@ -45,15 +49,15 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [1.6.0] - 2022-07-25 -- Support mdbook-linkcheck. -- Support mdbook on Windows. -- Support wasmtime on Windows. -- Support nextest on Linux (musl). +- Support `mdbook-linkcheck`. +- Support `mdbook` on Windows. +- Support `wasmtime` on Windows. +- Support `nextest` on Linux (musl). - Fix installation failure when `$CARGO_HOME/bin` and `$HOME/.cargo/bin` is not available. ## [1.5.11] - 2022-07-25 -- Fix cargo-binstall installation on macOS and Windows. +- Fix `cargo-binstall` installation on macOS and Windows. ## [1.5.10] - 2022-07-24 diff --git a/README.md b/README.md index b6911ac2..d11980e1 100644 --- a/README.md +++ b/README.md @@ -70,19 +70,21 @@ https://spdx.org/licenses | [**cargo-llvm-cov**](https://github.com/taiki-e/cargo-llvm-cov) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/taiki-e/cargo-llvm-cov/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/taiki-e/cargo-llvm-cov/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/taiki-e/cargo-llvm-cov/blob/HEAD/LICENSE-MIT) | | [**cargo-minimal-versions**](https://github.com/taiki-e/cargo-minimal-versions) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/taiki-e/cargo-minimal-versions/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/taiki-e/cargo-minimal-versions/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/taiki-e/cargo-minimal-versions/blob/HEAD/LICENSE-MIT) | | [**parse-changelog**](https://github.com/taiki-e/parse-changelog) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/taiki-e/parse-changelog/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/taiki-e/parse-changelog/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/taiki-e/parse-changelog/blob/HEAD/LICENSE-MIT) | +| [**cargo-binstall**][cargo-binstall] | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/ryankurte/cargo-binstall/releases) | Linux, macOS, Windows | [GPL-3.0](https://github.com/ryankurte/cargo-binstall/blob/HEAD/LICENSE.txt) | | [**cross**](https://github.com/cross-rs/cross) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/cross-rs/cross/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/cross-rs/cross/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/cross-rs/cross/blob/HEAD/LICENSE-MIT) | +| [**mdbook-linkcheck**](https://github.com/Michael-F-Bryan/mdbook-linkcheck) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases) | Linux, macOS, Windows | [MIT](https://github.com/Michael-F-Bryan/mdbook-linkcheck/blob/HEAD/LICENSE) | +| [**mdbook**](https://github.com/rust-lang/mdBook) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rust-lang/mdBook/releases) | Linux, macOS, Windows | [MPL-2.0](https://github.com/rust-lang/mdBook/blob/HEAD/LICENSE) | | [**nextest**](https://github.com/nextest-rs/nextest) (alias: `cargo-nextest`) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/nextest-rs/nextest/releases) | Linux, macOS, Windows | [Apache-2.0](https://github.com/nextest-rs/nextest/blob/HEAD/LICENSE-APACHE) OR [MIT](https://github.com/nextest-rs/nextest/blob/HEAD/LICENSE-MIT) | -| [**shellcheck**](https://www.shellcheck.net) | `/usr/local/bin` | [GitHub Releases](https://github.com/koalaman/shellcheck/releases) | Linux, macOS | [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 | [BSD-3-Clause](https://github.com/mvdan/sh/blob/HEAD/LICENSE) | +| [**protoc**](https://github.com/protocolbuffers/protobuf) | `/usr/local/bin` | [GitHub Releases](https://github.com/protocolbuffers/protobuf/releases) | Linux, macOS, Windows | [BSD-3-Clause](https://github.com/protocolbuffers/protobuf/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) | | [**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) | | [**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) | -| [**mdbook**](https://github.com/rust-lang/mdBook) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/rust-lang/mdBook/releases) | Linux, macOS, Windows | [MPL-2.0](https://github.com/rust-lang/mdBook/blob/HEAD/LICENSE) | -| [**mdbook-linkcheck**](https://github.com/Michael-F-Bryan/mdbook-linkcheck) | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases) | Linux, macOS, Windows | [MIT](https://github.com/Michael-F-Bryan/mdbook-linkcheck/blob/HEAD/LICENSE) | -| [**cargo-binstall**][cargo-binstall] | `$CARGO_HOME/bin` | [GitHub Releases](https://github.com/ryankurte/cargo-binstall/releases) | Linux, macOS, Windows | [GPL-3.0](https://github.com/ryankurte/cargo-binstall/blob/HEAD/LICENSE.txt) | If `$CARGO_HOME/bin` is not available, Rust-related binaries will be installed to `$HOME/.cargo/bin`. If `$HOME/.cargo/bin` is not available, Rust-related binaries will be installed to `/usr/local/bin`. +If `/usr/local/bin` is not available, all binaries will be installed to `$HOME/.install-action/bin`. If a tool not included in the list above is specified, this action uses [cargo-binstall] as a fallback. diff --git a/main.sh b/main.sh index 37db4d6c..918f0789 100755 --- a/main.sh +++ b/main.sh @@ -34,6 +34,16 @@ download() { local url="$1" local bin_dir="$2" local bin="$3" + if [[ "${bin_dir}" == "/usr/"* ]]; then + if [[ ! -d "${bin_dir}" ]]; then + bin_dir="${HOME}/.install-action/bin" + if [[ ! -d "${bin_dir}" ]]; then + mkdir -p "${bin_dir}" + echo "${bin_dir}" >>"${GITHUB_PATH}" + export PATH="${PATH}:${bin_dir}" + fi + fi + fi local tar_args=() case "${url}" in *.tar.gz | *.tgz) tar_args+=("xzf") ;; @@ -213,6 +223,23 @@ for tool in "${tools[@]}"; do retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \ | tar xzf - -C "${cargo_bin}" ;; + protoc) + # https://github.com/protocolbuffers/protobuf/releases + latest_version="3.21.4" + repo="protocolbuffers/protobuf" + case "${version}" in + latest) version="${latest_version}" ;; + esac + miner_patch_version="${latest_version#*.}" + base_url="https://github.com/${repo}/releases/download/v${miner_patch_version}/protoc-${miner_patch_version}" + case "${OSTYPE}" in + linux*) url="${base_url}-linux-x86_64.zip" ;; + darwin*) url="${base_url}-osx-x86_64.zip" ;; + cygwin* | msys*) url="${base_url}-win64.zip" ;; + *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; + esac + download "${url}" /usr/local/bin "bin/protoc${exe}" + ;; shellcheck) # https://github.com/koalaman/shellcheck/releases latest_version="0.8.0" @@ -221,6 +248,7 @@ for tool in "${tools[@]}"; do latest) version="${latest_version}" ;; esac base_url="https://github.com/${repo}/releases/download/v${version}/shellcheck-v${version}" + bin="shellcheck-v${version}/shellcheck${exe}" case "${OSTYPE}" in linux*) if type -P shellcheck &>/dev/null; then @@ -230,25 +258,29 @@ for tool in "${tools[@]}"; do ;; darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;; cygwin* | msys*) - # TODO: In what directory should we install the binaries? - # url="${base_url}.zip" - bail "${tool} for windows is not supported yet by this action" + url="${base_url}.zip" + bin="shellcheck${exe}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; esac - download "${url}" /usr/local/bin "shellcheck-v${version}/shellcheck" + download "${url}" /usr/local/bin "${bin}" ;; shfmt) # https://github.com/mvdan/sh/releases latest_version="3.5.1" repo="mvdan/sh" + bin_dir="/usr/local/bin" case "${OSTYPE}" in linux*) target="linux_amd64" ;; darwin*) target="darwin_amd64" ;; cygwin* | msys*) - # TODO: In what directory should we install the binaries? - # target="windows_amd64" - bail "${tool} for windows is not supported yet by this action" + target="windows_amd64" + bin_dir="${HOME}/.install-action/bin" + if [[ ! -d "${bin_dir}" ]]; then + mkdir -p "${bin_dir}" + echo "${bin_dir}" >>"${GITHUB_PATH}" + export PATH="${PATH}:${bin_dir}" + fi ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; esac @@ -257,8 +289,10 @@ for tool in "${tools[@]}"; do esac url="https://github.com/${repo}/releases/download/v${version}/shfmt_v${version}_${target}${exe}" info "downloading ${url}" - retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o /usr/local/bin/shfmt "${url}" - chmod +x /usr/local/bin/shfmt + retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o "${bin_dir}/shfmt${exe}" "${url}" + case "${OSTYPE}" in + linux* | darwin*) chmod +x "${bin_dir}/shfmt${exe}" ;; + esac ;; valgrind) case "${OSTYPE}" in diff --git a/tools/publish.sh b/tools/publish.sh index 5ed69066..9a4ccc0c 100755 --- a/tools/publish.sh +++ b/tools/publish.sh @@ -81,7 +81,11 @@ tools=( cargo-llvm-cov cargo-minimal-versions parse-changelog + cargo-binstall cross + mdbook + mdbook-linkcheck + protoc nextest cargo-nextest shellcheck @@ -89,9 +93,6 @@ tools=( valgrind wasm-pack wasmtime - mdbook - mdbook-linkcheck - cargo-binstall ) (