Compare commits

...

42 Commits
v1.15.2 ... v1

Author SHA1 Message Date
Taiki Endo
9a29ce630c Release 1.17.3 2022-12-22 11:24:47 +09:00
Taiki Endo
acc0c0687d Update wasmtime@latest to 4.0.0 2022-12-22 11:21:14 +09:00
Taiki Endo
c98c0a5de9 Tweak CI config 2022-12-22 11:21:06 +09:00
Taiki Endo
b5a6a481a3 Release 1.17.2 2022-12-18 01:34:34 +09:00
Taiki Endo
936bda0c55 Update mdbook@latest to 0.4.25 2022-12-18 01:23:18 +09:00
Taiki Endo
e0abba697f Update GitHub workflow badge
See badges/shields issue 8671
2022-12-16 04:13:50 +09:00
Taiki Endo
320900e2b1 Update mdbook@latest to 0.4.24 2022-12-16 00:51:55 +09:00
Taiki Endo
4ea8614f66 Release 1.17.1 2022-12-15 21:13:23 +09:00
Taiki Endo
c4112353fe Update cargo-llvm-cov@latest to 0.5.3 2022-12-15 21:03:09 +09:00
Taiki Endo
d14576d5ee Support mdbook on linux-musl 2022-12-15 20:39:00 +09:00
Taiki Endo
54f239fc7f Update comments on GitHub Actions Runner 2022-12-15 20:23:58 +09:00
Taiki Endo
0c60ab7876 Update mdbook@latest to 0.4.23 2022-12-15 20:23:24 +09:00
Taiki Endo
cb3ffa00b0 Release 1.17.0 2022-12-15 01:51:11 +09:00
Taiki Endo
a68686a8a2 Support aarch64 host more 2022-12-15 01:48:50 +09:00
Taiki Endo
c5a36f2fba Support aarch64 self-hosted runners 2022-12-15 00:16:20 +09:00
Taiki Endo
5e3287fe00 Update protoc@latest to 3.21.12 2022-12-14 23:49:33 +09:00
Taiki Endo
807aa14713 Do not install dnf on CentOS 7 2022-12-14 23:46:06 +09:00
Taiki Endo
1ab447b34f Improve support for Fedora/RHEL based containers/self-hosted runners 2022-12-14 22:40:45 +09:00
Taiki Endo
d66f303732 Update changelog 2022-12-14 12:00:52 +09:00
Taiki Endo
59c6ff35e6 Tweak changelog 2022-12-14 11:51:33 +09:00
Taiki Endo
4dad9dd51d Release 1.16.0 2022-12-14 11:48:06 +09:00
Taiki Endo
9ff3167a7f Add compatibility note 2022-12-14 11:47:44 +09:00
Taiki Endo
2a026de3a2 Test ubuntu:18:04 container in CI 2022-12-14 11:37:45 +09:00
Taiki Endo
f69fae4162 Update changelog 2022-12-14 11:31:32 +09:00
Taiki Endo
c3ee7d751f Add comment 2022-12-14 11:29:57 +09:00
Taiki Endo
ff96887f37 Install packages required for installation if not installed 2022-12-14 11:24:22 +09:00
Taiki Endo
97334a704a Remove needless host_triple call 2022-12-14 10:54:03 +09:00
Taiki Endo
83639e6b24 rustc-independent musl detection, take 2 2022-12-14 10:47:48 +09:00
Taiki Endo
8bc4e50568 Compact case statement in install_cargo_binstall 2022-12-14 10:42:47 +09:00
Jiahao XU
1fa8737224 Bump cargo-binstall to v0.18.1 (#32) 2022-12-14 10:26:38 +09:00
Taiki Endo
a75cc5295d Release 1.15.5 2022-12-13 20:54:41 +09:00
Taiki Endo
ee26d44cfa Update shellcheck@latest to 0.9.0 2022-12-13 20:52:26 +09:00
Taiki Endo
4eef07f07c Release 1.15.4 2022-12-12 23:43:39 +09:00
Taiki Endo
bb72b7ab31 Test GitHub-provided ubuntu-22.04 runner in CI 2022-12-12 23:38:49 +09:00
Taiki Endo
f80dd34cc7 Update cargo-binstall@latest to 0.18.0 2022-12-12 23:26:16 +09:00
Taiki Endo
a252073294 Support installing cargo-binstall on custom linux targets 2022-12-12 23:26:02 +09:00
Taiki Endo
f4a1ca475e Update shfmt@latest to 3.6.0 2022-12-12 23:19:44 +09:00
Taiki Endo
d33a0a9074 Test ubuntu and debian containers in CI 2022-12-11 16:22:13 +09:00
Taiki Endo
3594558506 Test musl container in CI (#31) 2022-12-11 14:21:01 +09:00
Taiki Endo
bbcb7fd5c9 Release 1.15.3 2022-12-11 13:50:42 +09:00
Taiki Endo
155e686da4 Update changelog 2022-12-11 13:50:26 +09:00
Taiki Endo
e5d84f2a67 Revert "Adjust host env check"
This reverts commit 5b5badbee3.

Fixes #29
2022-12-11 13:48:21 +09:00
5 changed files with 339 additions and 72 deletions

View File

@@ -1,19 +1,25 @@
binstall binstall
bytecodealliance bytecodealliance
distro
doas
Dpkg
jfrimmel jfrimmel
koalaman koalaman
libc libc
linkcheck linkcheck
mdbook mdbook
microdnf
mvdan mvdan
nextest nextest
protobuf protobuf
protoc protoc
protocolbuffers protocolbuffers
quickinstall quickinstall
rockylinux
rustwasm rustwasm
shellcheck shellcheck
shfmt shfmt
toolchains toolchains
udeps udeps
wasmtime wasmtime
xscale

View File

@@ -10,7 +10,7 @@ on:
- main - main
- dev - dev
schedule: schedule:
- cron: '0 0 * * *' - cron: '0 1 * * *'
workflow_dispatch: workflow_dispatch:
defaults: defaults:
@@ -27,14 +27,17 @@ jobs:
matrix: matrix:
os: os:
- ubuntu-20.04 - ubuntu-20.04
- ubuntu-22.04
tool: tool:
# 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,cargo-udeps,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch - cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- cargo-hack@0.5.24,cargo-llvm-cov@0.5.2,cargo-minimal-versions@0.1.8,parse-changelog@0.5.2,cargo-udeps@0.1.35,cargo-valgrind@2.1.0,cargo-deny@0.13.5,cross@0.2.4,nextest@0.9.11,protoc@3.21.11,shellcheck@0.8.0,shfmt@3.5.1,wasm-pack@0.10.3,wasmtime@3.0.1,mdbook@0.4.22,mdbook-linkcheck@0.7.7,cargo-watch@8.1.1
# Nextest supports basic version ranges as well
- nextest@0.9
include: include:
# Note: Specifying the version of valgrind and cargo-binstall is not supported.
- os: ubuntu-20.04
tool: cargo-hack@0.5.24,cargo-llvm-cov@0.5.3,cargo-minimal-versions@0.1.8,parse-changelog@0.5.2,cargo-udeps@0.1.35,cargo-valgrind@2.1.0,cargo-deny@0.13.5,cross@0.2.4,nextest@0.9.11,protoc@3.21.12,shellcheck@0.9.0,shfmt@3.6.0,wasm-pack@0.10.3,wasmtime@4.0.0,mdbook@0.4.25,mdbook-linkcheck@0.7.7,cargo-watch@8.1.1
# Nextest supports basic version ranges as well. For other tools, this will be supported by https://github.com/taiki-e/install-action/pull/27.
- os: ubuntu-20.04
tool: nextest@0.9
- os: macos-11 - os: macos-11
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- os: windows-2019 - os: windows-2019
@@ -47,3 +50,69 @@ jobs:
- uses: ./ - uses: ./
with: with:
tool: ${{ matrix.tool }} tool: ${{ matrix.tool }}
test-container:
strategy:
fail-fast: false
matrix:
container:
- ubuntu:18.04 # glibc 2.27
- ubuntu:20.04 # glibc 2.31
- debian:10-slim # glibc 2.28
- debian:11-slim # glibc 2.31
- rockylinux:8 # glibc 2.28
- rockylinux:8-minimal # glibc 2.28
tool:
# valgrind: installing snap to container is difficult...
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-udeps,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
include:
- container: ubuntu:22.04 # glibc 2.35
# cargo-udeps depends on openssl 1.1
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- container: fedora:latest # glibc 2.36 (as of fedora 37)
# cargo-udeps depends on openssl 1.1
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-valgrind,cargo-deny,cross,nextest,protoc,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,mdbook-linkcheck,cargo-watch
- container: centos:7 # glibc 2.17
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
# we don't support nextest on very old glibc due to https://github.com/taiki-e/install-action/issues/13.
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-valgrind,cargo-deny,cross,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall
- container: alpine:latest # musl 1.2.3 (as of alpine 3.17)
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cargo-valgrind,cargo-deny,cross,nextest,shellcheck,shfmt,wasm-pack,mdbook,cargo-binstall
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- name: Install requirements (ubuntu/debian)
run: |
set -euxo pipefail
apt-get -o Acquire::Retries=10 -qq update
apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y --no-install-recommends cargo
if: startsWith(matrix.container, 'ubuntu') || startsWith(matrix.container, 'debian')
- name: Install requirements (fedora/rockylinux)
run: |
set -euxo pipefail
dnf=dnf
if ! type -P dnf &>/dev/null; then
dnf=microdnf
fi
# tar and gzip are required for actions/checkout on rockylinux:*-minimal
$dnf install -y cargo tar gzip
if: startsWith(matrix.container, 'fedora') || startsWith(matrix.container, 'rockylinux')
- name: Install requirements (centos)
run: |
set -euxo pipefail
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable
echo "$HOME/.cargo/bin" >>"${GITHUB_PATH}"
if: startsWith(matrix.container, 'centos')
- name: Install requirements (alpine)
run: |
set -eux
apk add bash cargo
shell: sh
if: startsWith(matrix.container, 'alpine')
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: ./
with:
tool: ${{ matrix.tool }}

View File

@@ -10,6 +10,52 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased] ## [Unreleased]
## [1.17.3] - 2022-12-22
- Update `wasmtime@latest` to 4.0.0.
## [1.17.2] - 2022-12-17
- Update `mdbook@latest` to 0.4.25.
## [1.17.1] - 2022-12-15
- Update `mdbook@latest` to 0.4.23.
- Support `mdbook` on Linux (musl).
- Update `cargo-llvm-cov@latest` to 0.5.3.
## [1.17.0] - 2022-12-14
- Update `protoc@latest` to 3.21.12.
- Support aarch64 self-hosted runners (Linux, macOS, Windows).
- Improve support for Fedora/RHEL based containers/self-hosted runners.
## [1.16.0] - 2022-12-14
- Update `cargo-binstall@latest` to 0.18.1. ([#32](https://github.com/taiki-e/install-action/pull/32), thanks @NobodyXu)
- If the host environment lacks packages required for installation, such as `curl` or `tar`, install them if possible.
It is mainly intended to make the use of this action easy on containers or self-hosted runners, and currently supports Debian-based distributions (including Ubuntu) and Alpine.
The system's package manager is used for these installations. However, `bash`, which is an execution requirement of the action itself, and `cargo`, which is usually preferred for installation by rustup rather than the system's package manager, are *not* covered by these installations.
See also the [compatibility note in readme](https://github.com/taiki-e/install-action#compatibility).
## [1.15.5] - 2022-12-13
- Update `shellcheck@latest` to 0.9.0.
## [1.15.4] - 2022-12-12
- Update `shfmt@latest` to 3.6.0.
- Update `cargo-binstall@latest` to 0.18.0.
- Support installing `cargo-binstall` on linux with custom host targets such as x86_64-alpine-linux-musl.
## [1.15.3] - 2022-12-11
- Fix bug regarding musl host detection. ([#29](https://github.com/taiki-e/install-action/issues/29))
## [1.15.2] - 2022-12-10 ## [1.15.2] - 2022-12-10
- Update `mdbook-linkcheck@latest` to 0.7.7. - Update `mdbook-linkcheck@latest` to 0.7.7.
@@ -415,7 +461,15 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
Initial release Initial release
[Unreleased]: https://github.com/taiki-e/install-action/compare/v1.15.2...HEAD [Unreleased]: https://github.com/taiki-e/install-action/compare/v1.17.3...HEAD
[1.17.3]: https://github.com/taiki-e/install-action/compare/v1.17.2...v1.17.3
[1.17.2]: https://github.com/taiki-e/install-action/compare/v1.17.1...v1.17.2
[1.17.1]: https://github.com/taiki-e/install-action/compare/v1.17.0...v1.17.1
[1.17.0]: https://github.com/taiki-e/install-action/compare/v1.16.0...v1.17.0
[1.16.0]: https://github.com/taiki-e/install-action/compare/v1.15.5...v1.16.0
[1.15.5]: https://github.com/taiki-e/install-action/compare/v1.15.4...v1.15.5
[1.15.4]: https://github.com/taiki-e/install-action/compare/v1.15.3...v1.15.4
[1.15.3]: https://github.com/taiki-e/install-action/compare/v1.15.2...v1.15.3
[1.15.2]: https://github.com/taiki-e/install-action/compare/v1.15.1...v1.15.2 [1.15.2]: https://github.com/taiki-e/install-action/compare/v1.15.1...v1.15.2
[1.15.1]: https://github.com/taiki-e/install-action/compare/v1.15.0...v1.15.1 [1.15.1]: https://github.com/taiki-e/install-action/compare/v1.15.0...v1.15.1
[1.15.0]: https://github.com/taiki-e/install-action/compare/v1.14.7...v1.15.0 [1.15.0]: https://github.com/taiki-e/install-action/compare/v1.14.7...v1.15.0

View File

@@ -1,6 +1,6 @@
# install-action # install-action
[![build status](https://img.shields.io/github/workflow/status/taiki-e/install-action/CI/main?style=flat-square&logo=github)](https://github.com/taiki-e/install-action/actions) [![build status](https://img.shields.io/github/actions/workflow/status/taiki-e/install-action/ci.yml?branch=main&style=flat-square&logo=github)](https://github.com/taiki-e/install-action/actions)
GitHub Action for installing development tools (mainly from GitHub Releases). GitHub Action for installing development tools (mainly from GitHub Releases).
@@ -9,6 +9,7 @@ GitHub Action for installing development tools (mainly from GitHub Releases).
- [Example workflow](#example-workflow) - [Example workflow](#example-workflow)
- [Supported tools](#supported-tools) - [Supported tools](#supported-tools)
- [Security](#security) - [Security](#security)
- [Compatibility](#compatibility)
- [Related Projects](#related-projects) - [Related Projects](#related-projects)
- [License](#license) - [License](#license)
@@ -101,6 +102,14 @@ When installing the tool from GitHub Releases, this action will download the too
If you want a higher level of security, consider working on [#1](https://github.com/taiki-e/install-action/issues/1). If you want a higher level of security, consider working on [#1](https://github.com/taiki-e/install-action/issues/1).
## Compatibility
This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) and containers (Ubuntu, Debian, Alpine, Fedora, CentOS, Rocky).
To use this action in self-hosted runners or in containers, you will need to install at least the following:
- bash
- cargo (if you install cargo subcommands or use cargo-binstall fallback)
## Related Projects ## Related Projects
- [create-gh-release-action]: GitHub Action for creating GitHub Releases based on changelog. - [create-gh-release-action]: GitHub Action for creating GitHub Releases based on changelog.

259
main.sh
View File

@@ -47,14 +47,34 @@ download() {
local tar_args=() local tar_args=()
case "${url}" in case "${url}" in
*.tar.gz | *.tgz) tar_args+=("xzf") ;; *.tar.gz | *.tgz) tar_args+=("xzf") ;;
*.tar.bz2 | *.tbz2) tar_args+=("xjf") ;; *.tar.bz2 | *.tbz2)
*.tar.xz | *.txz) tar_args+=("xJf") ;; tar_args+=("xjf")
if ! type -P bzip2 &>/dev/null; then
case "${base_distro}" in
debian | alpine | fedora) sys_install bzip2 ;;
esac
fi
;;
*.tar.xz | *.txz)
tar_args+=("xJf")
if ! type -P xz &>/dev/null; then
case "${base_distro}" in
debian) sys_install xz-utils ;;
alpine | fedora) sys_install xz ;;
esac
fi
;;
*.zip) *.zip)
if ! type -P unzip &>/dev/null; then
case "${base_distro}" in
debian | alpine | fedora) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp mkdir -p .install-action-tmp
( (
cd .install-action-tmp cd .install-action-tmp
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" -o tmp.zip retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" -o tmp.zip
unzip tmp.zip unzip tmp.zip
mv "${bin}" "${bin_dir}/" mv "${bin}" "${bin_dir}/"
) )
@@ -70,17 +90,12 @@ download() {
tar_args+=(--strip-components "${components}") tar_args+=(--strip-components "${components}")
fi fi
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \ retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" \
| tar "${tar_args[@]}" -C "${bin_dir}" "${bin}" | tar "${tar_args[@]}" -C "${bin_dir}" "${bin}"
} }
host_triple() {
if [[ -z "${host:-}" ]]; then
host="$(rustc -vV | grep host | cut -c 7-)"
fi
}
install_cargo_binstall() { install_cargo_binstall() {
# https://github.com/cargo-bins/cargo-binstall/releases # https://github.com/cargo-bins/cargo-binstall/releases
local binstall_version="0.17.0" local binstall_version="0.18.1"
local install_binstall='1' local install_binstall='1'
if [[ -f "${cargo_bin}/cargo-binstall${exe}" ]]; then if [[ -f "${cargo_bin}/cargo-binstall${exe}" ]]; then
if [[ "$(cargo binstall -V)" == "cargo-binstall ${binstall_version}" ]]; then if [[ "$(cargo binstall -V)" == "cargo-binstall ${binstall_version}" ]]; then
@@ -95,25 +110,12 @@ install_cargo_binstall() {
if [[ -n "${install_binstall}" ]]; then if [[ -n "${install_binstall}" ]]; then
info "installing cargo-binstall" info "installing cargo-binstall"
host_triple
base_url="https://github.com/cargo-bins/cargo-binstall/releases/download/v${binstall_version}/cargo-binstall" base_url="https://github.com/cargo-bins/cargo-binstall/releases/download/v${binstall_version}/cargo-binstall"
case "${host}" in case "${OSTYPE}" in
x86_64-unknown-linux-gnu) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;; linux*) url="${base_url}-${host_arch}-unknown-linux-musl.tgz" ;;
x86_64-unknown-linux-musl) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;; darwin*) url="${base_url}-${host_arch}-apple-darwin.zip" ;;
cygwin* | msys*) url="${base_url}-x86_64-pc-windows-msvc.zip" ;;
armv7-unknown-linux-gnueabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for cargo-binstall" ;;
armv7-unknown-linux-musleabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
aarch64-unknown-linux-gnu) url="${base_url}-aarch64-unknown-linux-musl.tgz" ;;
aarch64-unknown-linux-musl) url="${base_url}-aarch64-unknown-linux-musl.tgz" ;;
x86_64-pc-windows-gnu) url="${base_url}-x86_64-pc-windows-msvc.zip" ;;
x86_64-apple-darwin | aarch64-apple-darwin | x86_64-pc-windows-msvc)
url="${base_url}-${host}.zip"
;;
*) bail "unsupported target '${host}' for cargo-binstall" ;;
esac esac
download "${url}" "${cargo_bin}" "cargo-binstall${exe}" download "${url}" "${cargo_bin}" "cargo-binstall${exe}"
@@ -137,6 +139,59 @@ cargo_binstall() {
*) cargo binstall --force --no-confirm --version "${version}" "${tool}" ;; *) cargo binstall --force --no-confirm --version "${version}" "${tool}" ;;
esac esac
} }
apt_update() {
if type -P sudo &>/dev/null; then
retry sudo apt-get -o Acquire::Retries=10 -qq update
else
retry apt-get -o Acquire::Retries=10 -qq update
fi
apt_updated=1
}
apt_install() {
if [[ -z "${apt_updated:-}" ]]; then
apt_update
fi
if type -P sudo &>/dev/null; then
retry sudo apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y --no-install-recommends "$@"
else
retry apt-get -o Acquire::Retries=10 -qq -o Dpkg::Use-Pty=0 install -y --no-install-recommends "$@"
fi
}
apt_remove() {
if type -P sudo &>/dev/null; then
sudo apt-get -qq -o Dpkg::Use-Pty=0 remove -y "$@"
else
apt-get -qq -o Dpkg::Use-Pty=0 remove -y "$@"
fi
}
snap_install() {
if type -P sudo &>/dev/null; then
retry sudo snap install "$@"
else
retry snap install "$@"
fi
}
apk_install() {
if type -P doas &>/dev/null; then
doas apk add "$@"
else
apk add "$@"
fi
}
dnf_install() {
if type -P sudo &>/dev/null; then
retry sudo "${dnf}" install -y "$@"
else
retry "${dnf}" install -y "$@"
fi
}
sys_install() {
case "${base_distro}" in
debian) apt_install "$@" ;;
alpine) apk_install "$@" ;;
fedora) dnf_install "$@" ;;
esac
}
if [[ $# -gt 0 ]]; then if [[ $# -gt 0 ]]; then
bail "invalid argument '$1'" bail "invalid argument '$1'"
@@ -151,8 +206,60 @@ if [[ -n "${tool}" ]]; then
while read -rd,; do tools+=("${REPLY}"); done <<<"${tool}," while read -rd,; do tools+=("${REPLY}"); done <<<"${tool},"
fi fi
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
case "$(uname -m)" in
aarch64 | arm64) host_arch="aarch64" ;;
xscale | arm | armv6l | armv7l | armv8l)
# Ignore arm for now, as we need to consider the version and whether hard-float is supported.
# https://github.com/rust-lang/rustup/pull/593
# https://github.com/cross-rs/cross/pull/1018
# Does it seem only armv7l is supported?
# https://github.com/actions/runner/blob/6b9e8a6be411a6e63d5ccaf3c47e7b7622c5ec49/src/Misc/externals.sh#L174
bail "32-bit ARM runner is not supported yet by this action"
;;
# GitHub Actions Runner supports Linux (x86_64, aarch64, arm), Windows (x86_64, aarch64),
# and macOS (x86_64, aarch64).
# https://github.com/actions/runner
# https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#supported-architectures-and-operating-systems-for-self-hosted-runners
# So we can assume x86_64 unless it is aarch64 or arm.
*) host_arch="x86_64" ;;
esac
base_distro=""
exe="" exe=""
case "${OSTYPE}" in case "${OSTYPE}" in
linux*)
host_env="gnu"
if (ldd --version 2>&1 || true) | grep -q 'musl'; then
host_env="musl"
fi
if grep -q '^ID_LIKE=' /etc/os-release; then
base_distro="$(grep '^ID_LIKE=' /etc/os-release | sed 's/^ID_LIKE=//')"
case "${base_distro}" in
*debian*) base_distro=debian ;;
*alpine*) base_distro=alpine ;;
*fedora*) base_distro=fedora ;;
esac
else
base_distro="$(grep '^ID=' /etc/os-release | sed 's/^ID=//')"
fi
case "${base_distro}" in
fedora)
dnf=dnf
if ! type -P dnf &>/dev/null; then
if type -P microdnf &>/dev/null; then
# fedora-based distributions have "minimal" images that
# use microdnf instead of dnf.
dnf=microdnf
else
# If neither dnf nor microdnf is available, it is
# probably an RHEL7-based distribution that does not
# have dnf installed by default.
dnf=yum
fi
fi
;;
esac
;;
cygwin* | msys*) exe=".exe" ;; cygwin* | msys*) exe=".exe" ;;
esac esac
@@ -161,15 +268,11 @@ if [[ ! -d "${cargo_bin}" ]]; then
cargo_bin=/usr/local/bin cargo_bin=/usr/local/bin
fi fi
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh if ! type -P curl &>/dev/null || ! type -P tar &>/dev/null; then
case "${OSTYPE}" in case "${base_distro}" in
linux*) debian | alpine | fedora) sys_install ca-certificates curl tar ;;
host_env="gnu" esac
if ldd --version 2>&1 | grep -q 'musl'; then fi
host_env="musl"
fi
;;
esac
for tool in "${tools[@]}"; do for tool in "${tools[@]}"; do
if [[ "${tool}" == *"@"* ]]; then if [[ "${tool}" == *"@"* ]]; then
@@ -189,7 +292,7 @@ for tool in "${tools[@]}"; do
# https://github.com/taiki-e/cargo-hack/releases # https://github.com/taiki-e/cargo-hack/releases
cargo-hack) latest_version="0.5.24" ;; cargo-hack) latest_version="0.5.24" ;;
# https://github.com/taiki-e/cargo-llvm-cov/releases # https://github.com/taiki-e/cargo-llvm-cov/releases
cargo-llvm-cov) latest_version="0.5.2" ;; cargo-llvm-cov) latest_version="0.5.3" ;;
# https://github.com/taiki-e/cargo-minimal-versions/releases # https://github.com/taiki-e/cargo-minimal-versions/releases
cargo-minimal-versions) latest_version="0.1.8" ;; cargo-minimal-versions) latest_version="0.1.8" ;;
# https://github.com/taiki-e/parse-changelog/releases # https://github.com/taiki-e/parse-changelog/releases
@@ -201,9 +304,14 @@ for tool in "${tools[@]}"; do
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="${host_arch}-unknown-linux-musl" ;;
darwin*) target="x86_64-apple-darwin" ;; darwin*) target="${host_arch}-apple-darwin" ;;
cygwin* | msys*) target="x86_64-pc-windows-msvc" ;; cygwin* | msys*)
case "${tool}" in
cargo-llvm-cov) target="x86_64-pc-windows-msvc" ;;
*) target="${host_arch}-pc-windows-msvc" ;;
esac
;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac 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"
@@ -236,7 +344,7 @@ for tool in "${tools[@]}"; do
download "${url}" "${cargo_bin}" "./${tool}-v${version}-${target}/${tool}${exe}" download "${url}" "${cargo_bin}" "./${tool}-v${version}-${target}/${tool}${exe}"
;; ;;
cargo-valgrind) cargo-valgrind)
# https://github.com/jfrimmel/cargo-valgrind # https://github.com/jfrimmel/cargo-valgrind/releases
latest_version="2.1.0" latest_version="2.1.0"
repo="jfrimmel/${tool}" repo="jfrimmel/${tool}"
case "${version}" in case "${version}" in
@@ -269,7 +377,7 @@ for tool in "${tools[@]}"; do
esac 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="${host_arch}-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
@@ -300,6 +408,8 @@ for tool in "${tools[@]}"; do
# https://nexte.st/book/pre-built-binaries.html # https://nexte.st/book/pre-built-binaries.html
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
# musl build of nextest is slow, so use glibc build if host_env is gnu.
# https://github.com/taiki-e/install-action/issues/13
case "${host_env}" in case "${host_env}" in
gnu) url="https://get.nexte.st/${version}/linux" ;; gnu) url="https://get.nexte.st/${version}/linux" ;;
*) url="https://get.nexte.st/${version}/linux-musl" ;; *) url="https://get.nexte.st/${version}/linux-musl" ;;
@@ -310,19 +420,19 @@ for tool in "${tools[@]}"; do
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \ retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" \
| tar xzf - -C "${cargo_bin}" | tar xzf - -C "${cargo_bin}"
;; ;;
protoc) protoc)
# https://github.com/protocolbuffers/protobuf/releases # https://github.com/protocolbuffers/protobuf/releases
latest_version="3.21.11" latest_version="3.21.12"
repo="protocolbuffers/protobuf" repo="protocolbuffers/protobuf"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
miner_patch_version="${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}"
# Copying files to /usr/local/include requires sudo. # Copying files to /usr/local/include requires sudo, so do not use it.
bin_dir="${HOME}/.install-action/bin" bin_dir="${HOME}/.install-action/bin"
include_dir="${HOME}/.install-action/include" include_dir="${HOME}/.install-action/include"
if [[ ! -d "${bin_dir}" ]]; then if [[ ! -d "${bin_dir}" ]]; then
@@ -332,16 +442,21 @@ for tool in "${tools[@]}"; do
export PATH="${PATH}:${bin_dir}" export PATH="${PATH}:${bin_dir}"
fi fi
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) url="${base_url}-linux-x86_64.zip" ;; linux*) url="${base_url}-linux-${host_arch/aarch/aarch_}.zip" ;;
darwin*) url="${base_url}-osx-x86_64.zip" ;; darwin*) url="${base_url}-osx-${host_arch/aarch/aarch_}.zip" ;;
cygwin* | msys*) url="${base_url}-win64.zip" ;; cygwin* | msys*) url="${base_url}-win64.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac esac
if ! type -P unzip &>/dev/null; then
case "${base_distro}" in
debian | alpine | fedora) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp mkdir -p .install-action-tmp
( (
cd .install-action-tmp cd .install-action-tmp
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" -o tmp.zip retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 "${url}" -o tmp.zip
unzip tmp.zip unzip tmp.zip
mv "bin/protoc${exe}" "${bin_dir}/" mv "bin/protoc${exe}" "${bin_dir}/"
mkdir -p "${include_dir}/" mkdir -p "${include_dir}/"
@@ -358,7 +473,7 @@ 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.9.0"
repo="koalaman/${tool}" repo="koalaman/${tool}"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
@@ -368,9 +483,9 @@ for tool in "${tools[@]}"; do
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) linux*)
if type -P shellcheck &>/dev/null; then if type -P shellcheck &>/dev/null; then
sudo apt-get -qq -o Dpkg::Use-Pty=0 remove -y shellcheck apt_remove shellcheck
fi fi
url="${base_url}.linux.x86_64.tar.xz" url="${base_url}.linux.${host_arch}.tar.xz"
;; ;;
darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;; darwin*) url="${base_url}.darwin.x86_64.tar.xz" ;;
cygwin* | msys*) cygwin* | msys*)
@@ -383,15 +498,25 @@ for tool in "${tools[@]}"; do
;; ;;
shfmt) shfmt)
# https://github.com/mvdan/sh/releases # https://github.com/mvdan/sh/releases
latest_version="3.5.1" latest_version="3.6.0"
repo="mvdan/sh" repo="mvdan/sh"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
bin_dir="/usr/local/bin" bin_dir="/usr/local/bin"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="linux_amd64" ;; linux*)
darwin*) target="darwin_amd64" ;; case "${host_arch}" in
aarch64) target="linux_arm64" ;;
*) target="linux_amd64" ;;
esac
;;
darwin*)
case "${host_arch}" in
aarch64) target="darwin_arm64" ;;
*) target="darwin_amd64" ;;
esac
;;
cygwin* | msys*) cygwin* | msys*)
target="windows_amd64" target="windows_amd64"
bin_dir="${HOME}/.install-action/bin" bin_dir="${HOME}/.install-action/bin"
@@ -405,7 +530,7 @@ for tool in "${tools[@]}"; do
esac esac
url="https://github.com/${repo}/releases/download/v${version}/${tool}_v${version}_${target}${exe}" url="https://github.com/${repo}/releases/download/v${version}/${tool}_v${version}_${target}${exe}"
info "downloading ${url}" info "downloading ${url}"
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused -o "${bin_dir}/${tool}${exe}" "${url}" retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 -o "${bin_dir}/${tool}${exe}" "${url}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux* | darwin*) chmod +x "${bin_dir}/${tool}${exe}" ;; linux* | darwin*) chmod +x "${bin_dir}/${tool}${exe}" ;;
esac esac
@@ -420,12 +545,11 @@ for tool in "${tools[@]}"; do
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
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 apt_install libc6-dbg
# Use snap to install the latest Valgrind # Use snap to install the latest Valgrind
# https://snapcraft.io/install/valgrind/ubuntu # https://snapcraft.io/install/valgrind/ubuntu
retry sudo snap install valgrind --classic snap_install valgrind --classic
;; ;;
wasm-pack) wasm-pack)
# https://github.com/rustwasm/wasm-pack/releases # https://github.com/rustwasm/wasm-pack/releases
@@ -435,7 +559,7 @@ for tool in "${tools[@]}"; do
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
esac esac
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) target="x86_64-unknown-linux-musl" ;; linux*) target="${host_arch}-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}" ;;
@@ -445,7 +569,7 @@ for tool in "${tools[@]}"; do
;; ;;
wasmtime) wasmtime)
# https://github.com/bytecodealliance/wasmtime/releases # https://github.com/bytecodealliance/wasmtime/releases
latest_version="3.0.1" latest_version="4.0.0"
repo="bytecodealliance/${tool}" repo="bytecodealliance/${tool}"
case "${version}" in case "${version}" in
latest) version="${latest_version}" ;; latest) version="${latest_version}" ;;
@@ -453,11 +577,11 @@ for tool in "${tools[@]}"; do
base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-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="${host_arch}-linux"
url="${base_url}-${target}.tar.xz" url="${base_url}-${target}.tar.xz"
;; ;;
darwin*) darwin*)
target="x86_64-macos" target="${host_arch}-macos"
url="${base_url}-${target}.tar.xz" url="${base_url}-${target}.tar.xz"
;; ;;
cygwin* | msys*) cygwin* | msys*)
@@ -470,14 +594,19 @@ for tool in "${tools[@]}"; do
;; ;;
mdbook) mdbook)
# https://github.com/rust-lang/mdBook/releases # https://github.com/rust-lang/mdBook/releases
latest_version="0.4.22" latest_version="0.4.25"
repo="rust-lang/mdBook" repo="rust-lang/mdBook"
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}/${tool}-v${version}" base_url="https://github.com/${repo}/releases/download/v${version}/${tool}-v${version}"
case "${OSTYPE}" in case "${OSTYPE}" in
linux*) url="${base_url}-x86_64-unknown-linux-gnu.tar.gz" ;; linux*)
case "${version}" in
0.[1-3].* | 0.4.? | 0.4.1? | 0.4.2[0-1]) url="${base_url}-x86_64-unknown-linux-gnu.tar.gz" ;;
*) url="${base_url}-${host_arch}-unknown-linux-musl.tar.gz" ;;
esac
;;
darwin*) url="${base_url}-x86_64-apple-darwin.tar.gz" ;; darwin*) url="${base_url}-x86_64-apple-darwin.tar.gz" ;;
cygwin* | msys*) url="${base_url}-x86_64-pc-windows-msvc.zip" ;; cygwin* | msys*) url="${base_url}-x86_64-pc-windows-msvc.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;; *) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;