Compare commits

...

22 Commits

Author SHA1 Message Date
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 189 additions and 39 deletions

View File

@@ -1,5 +1,8 @@
binstall
bytecodealliance
distro
doas
Dpkg
jfrimmel
koalaman
libc

View File

@@ -10,7 +10,7 @@ on:
- main
- dev
schedule:
- cron: '0 0 * * *'
- cron: '0 1 * * *'
workflow_dispatch:
defaults:
@@ -27,14 +27,17 @@ jobs:
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
tool:
# Note: Specifying the version of valgrind is not supported.
# 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@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:
# 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.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.9.0,shfmt@3.6.0,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. 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
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
@@ -47,3 +50,40 @@ jobs:
- uses: ./
with:
tool: ${{ matrix.tool }}
test-container:
strategy:
fail-fast: false
matrix:
container:
- ubuntu:20.04
- debian:latest
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:18.04
# The latest mdbook provides prebuilt binaries for musl host, but we don't support it yet (will be done by https://github.com/taiki-e/install-action/pull/27)
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-linkcheck,cargo-watch
- container: alpine:latest
# cargo-udeps,protoc,valgrind,wasmtime,mdbook,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,cargo-binstall
runs-on: ubuntu-latest
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install requirements (ubuntu/debian)
run: |
set -ex
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 (alpine)
run: apk add bash cargo
shell: sh
if: startsWith(matrix.container, 'alpine')
- uses: ./
with:
tool: ${{ matrix.tool }}

View File

@@ -10,6 +10,30 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
## [Unreleased]
## [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 rustc, which is usually preferred for installation by rustup rather than the system's package manager, are *not* covered by these installations.
## [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
- Update `mdbook-linkcheck@latest` to 0.7.7.
@@ -415,7 +439,11 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
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.16.0...HEAD
[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.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

View File

@@ -9,6 +9,7 @@ GitHub Action for installing development tools (mainly from GitHub Releases).
- [Example workflow](#example-workflow)
- [Supported tools](#supported-tools)
- [Security](#security)
- [Compatibility](#compatibility)
- [Related Projects](#related-projects)
- [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).
## Compatibility
This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) and containers (Ubuntu, Debian, Alpine).
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)
## Related Projects
- [create-gh-release-action]: GitHub Action for creating GitHub Releases based on changelog.

136
main.sh
View File

@@ -47,9 +47,29 @@ download() {
local tar_args=()
case "${url}" in
*.tar.gz | *.tgz) tar_args+=("xzf") ;;
*.tar.bz2 | *.tbz2) tar_args+=("xjf") ;;
*.tar.xz | *.txz) tar_args+=("xJf") ;;
*.tar.bz2 | *.tbz2)
tar_args+=("xjf")
if ! type -P bzip2 &>/dev/null; then
case "${base_distro}" in
debian | alpine) 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) sys_install xz ;;
esac
fi
;;
*.zip)
if ! type -P unzip &>/dev/null; then
case "${base_distro}" in
debian | alpine) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp
(
cd .install-action-tmp
@@ -80,7 +100,7 @@ host_triple() {
}
install_cargo_binstall() {
# https://github.com/cargo-bins/cargo-binstall/releases
local binstall_version="0.17.0"
local binstall_version="0.18.1"
local install_binstall='1'
if [[ -f "${cargo_bin}/cargo-binstall${exe}" ]]; then
if [[ "$(cargo binstall -V)" == "cargo-binstall ${binstall_version}" ]]; then
@@ -98,21 +118,11 @@ install_cargo_binstall() {
host_triple
base_url="https://github.com/cargo-bins/cargo-binstall/releases/download/v${binstall_version}/cargo-binstall"
case "${host}" in
x86_64-unknown-linux-gnu) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
x86_64-unknown-linux-musl) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
armv7-unknown-linux-gnueabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
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-*-linux-gnu | x86_64-*-linux-musl) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
armv7-*-linux-gnueabihf | armv7-*-linux-musleabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
aarch64-*-linux-gnu | aarch64-*-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"
;;
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
@@ -137,6 +147,51 @@ cargo_binstall() {
*) cargo binstall --force --no-confirm --version "${version}" "${tool}" ;;
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
}
sys_install() {
case "${base_distro}" in
debian) apt_install "$@" ;;
alpine) apk_install "$@" ;;
esac
}
if [[ $# -gt 0 ]]; then
bail "invalid argument '$1'"
@@ -151,8 +206,21 @@ if [[ -n "${tool}" ]]; then
while read -rd,; do tools+=("${REPLY}"); done <<<"${tool},"
fi
base_distro=""
exe=""
case "${OSTYPE}" in
linux*)
host_env="gnu"
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
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=//')"
else
base_distro="$(grep '^ID=' /etc/os-release | sed 's/^ID=//')"
fi
;;
cygwin* | msys*) exe=".exe" ;;
esac
@@ -161,15 +229,11 @@ if [[ ! -d "${cargo_bin}" ]]; then
cargo_bin=/usr/local/bin
fi
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
case "${OSTYPE}" in
linux*)
host_env="gnu"
if ldd --version 2>&1 | grep -q 'musl'; then
host_env="musl"
fi
;;
esac
if ! type -P curl &>/dev/null || ! type -P tar &>/dev/null; then
case "${base_distro}" in
debian | alpine) sys_install ca-certificates curl tar ;;
esac
fi
for tool in "${tools[@]}"; do
if [[ "${tool}" == *"@"* ]]; then
@@ -300,6 +364,8 @@ for tool in "${tools[@]}"; do
# https://nexte.st/book/pre-built-binaries.html
case "${OSTYPE}" in
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
gnu) url="https://get.nexte.st/${version}/linux" ;;
*) url="https://get.nexte.st/${version}/linux-musl" ;;
@@ -322,7 +388,7 @@ for tool in "${tools[@]}"; do
esac
miner_patch_version="${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"
include_dir="${HOME}/.install-action/include"
if [[ ! -d "${bin_dir}" ]]; then
@@ -337,6 +403,11 @@ for tool in "${tools[@]}"; do
cygwin* | msys*) url="${base_url}-win64.zip" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
if ! type -P unzip &>/dev/null; then
case "${base_distro}" in
debian | alpine) sys_install unzip ;;
esac
fi
mkdir -p .install-action-tmp
(
cd .install-action-tmp
@@ -358,7 +429,7 @@ for tool in "${tools[@]}"; do
;;
shellcheck)
# https://github.com/koalaman/shellcheck/releases
latest_version="0.8.0"
latest_version="0.9.0"
repo="koalaman/${tool}"
case "${version}" in
latest) version="${latest_version}" ;;
@@ -368,7 +439,7 @@ for tool in "${tools[@]}"; do
case "${OSTYPE}" in
linux*)
if type -P shellcheck &>/dev/null; then
sudo apt-get -qq -o Dpkg::Use-Pty=0 remove -y shellcheck
apt_remove shellcheck
fi
url="${base_url}.linux.x86_64.tar.xz"
;;
@@ -383,7 +454,7 @@ for tool in "${tools[@]}"; do
;;
shfmt)
# https://github.com/mvdan/sh/releases
latest_version="3.5.1"
latest_version="3.6.0"
repo="mvdan/sh"
case "${version}" in
latest) version="${latest_version}" ;;
@@ -420,12 +491,11 @@ for tool in "${tools[@]}"; do
darwin* | cygwin* | msys*) bail "${tool} for non-linux is not supported yet by this action" ;;
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
esac
retry sudo apt-get -o Acquire::Retries=10 -qq update
# 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
# https://snapcraft.io/install/valgrind/ubuntu
retry sudo snap install valgrind --classic
snap_install valgrind --classic
;;
wasm-pack)
# https://github.com/rustwasm/wasm-pack/releases