Support protoc

This commit is contained in:
Taiki Endo
2022-08-01 17:23:02 +09:00
parent 41cb1134d7
commit 27a2597e2a
5 changed files with 70 additions and 29 deletions

View File

@@ -27,19 +27,19 @@ jobs:
tool: tool:
# Note: Specifying the version of valgrind and wasm-pack is not supported. # Note: Specifying the version of valgrind and wasm-pack 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,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,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,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:
# Note: mdBook binary is incompatible with ubuntu 18.04, # Note: mdBook binary is incompatible with ubuntu 18.04,
# see https://github.com/rust-lang/mdBook/issues/1779 # see https://github.com/rust-lang/mdBook/issues/1779
- os: ubuntu-18.04 - 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 - 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 - 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 }} 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 `protoc`.
- Support `shellcheck` on Windows.
- Support `shfmt` on Windows.
## [1.8.4] - 2022-08-01 ## [1.8.4] - 2022-08-01
- Update `cargo-llvm-cov@latest` to 0.4.13. - 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 ## [1.8.1] - 2022-07-26
- Fix cargo-binstall installation failure. - Fix `cargo-binstall` installation failure.
## [1.8.0] - 2022-07-26 ## [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. - 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) - 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 ## [1.6.0] - 2022-07-25
- Support mdbook-linkcheck. - Support `mdbook-linkcheck`.
- Support mdbook on Windows. - Support `mdbook` on Windows.
- Support wasmtime on Windows. - Support `wasmtime` on Windows.
- Support nextest on Linux (musl). - Support `nextest` on Linux (musl).
- Fix installation failure when `$CARGO_HOME/bin` and `$HOME/.cargo/bin` is not available. - Fix installation failure when `$CARGO_HOME/bin` and `$HOME/.cargo/bin` is not available.
## [1.5.11] - 2022-07-25 ## [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 ## [1.5.10] - 2022-07-24

View File

@@ -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-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) | | [**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) | | [**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) | | [**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) | | [**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) | | [**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) |
| [**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) | | [**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) | | [**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 | [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) |
| [**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 `$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 `$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. If a tool not included in the list above is specified, this action uses [cargo-binstall] as a fallback.

52
main.sh
View File

@@ -34,6 +34,16 @@ download() {
local url="$1" local url="$1"
local bin_dir="$2" local bin_dir="$2"
local bin="$3" 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=() local tar_args=()
case "${url}" in case "${url}" in
*.tar.gz | *.tgz) tar_args+=("xzf") ;; *.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}" \ retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
| tar xzf - -C "${cargo_bin}" | 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) shellcheck)
# https://github.com/koalaman/shellcheck/releases # https://github.com/koalaman/shellcheck/releases
latest_version="0.8.0" latest_version="0.8.0"
@@ -221,6 +248,7 @@ for tool in "${tools[@]}"; do
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}/shellcheck-v${version}"
bin="shellcheck-v${version}/shellcheck${exe}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
if type -P shellcheck &>/dev/null; then 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" ;; darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;;
cygwin* | msys*) cygwin* | msys*)
# TODO: In what directory should we install the binaries? url="${base_url}.zip"
# url="${base_url}.zip" bin="shellcheck${exe}"
bail "${tool} for windows is not supported yet by this action"
;; ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
download "${url}" /usr/local/bin "shellcheck-v${version}/shellcheck" download "${url}" /usr/local/bin "${bin}"
;; ;;
shfmt) shfmt)
# 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"
bin_dir="/usr/local/bin"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="linux_amd64" ;; linux*) target="linux_amd64" ;;
darwin*) target="darwin_amd64" ;; darwin*) target="darwin_amd64" ;;
cygwin* | msys*) cygwin* | msys*)
# TODO: In what directory should we install the binaries? target="windows_amd64"
# target="windows_amd64" bin_dir="${HOME}/.install-action/bin"
bail "${tool} for windows is not supported yet by this action" 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}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
@@ -257,8 +289,10 @@ for tool in "${tools[@]}"; do
esac esac
url="https://github.com/${repo}/releases/download/v${version}/shfmt_v${version}_${target}${exe}" 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 /usr/local/bin/shfmt "${url}" retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o "${bin_dir}/shfmt${exe}" "${url}"
chmod +x /usr/local/bin/shfmt case "${OSTYPE}" in
linux* | darwin*) chmod +x "${bin_dir}/shfmt${exe}" ;;
esac
;; ;;
valgrind) valgrind)
case "${OSTYPE}" in case "${OSTYPE}" in

View File

@@ -81,7 +81,11 @@ tools=(
cargo-llvm-cov cargo-llvm-cov
cargo-minimal-versions cargo-minimal-versions
parse-changelog parse-changelog
cargo-binstall
cross cross
mdbook
mdbook-linkcheck
protoc
nextest nextest
cargo-nextest cargo-nextest
shellcheck shellcheck
@@ -89,9 +93,6 @@ tools=(
valgrind valgrind
wasm-pack wasm-pack
wasmtime wasmtime
mdbook
mdbook-linkcheck
cargo-binstall
) )
( (