mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-07 21:40:30 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dad9dd51d | ||
|
|
9ff3167a7f | ||
|
|
2a026de3a2 | ||
|
|
f69fae4162 | ||
|
|
c3ee7d751f | ||
|
|
ff96887f37 | ||
|
|
97334a704a | ||
|
|
83639e6b24 | ||
|
|
8bc4e50568 | ||
|
|
1fa8737224 |
2
.github/.cspell/project-dictionary.txt
vendored
2
.github/.cspell/project-dictionary.txt
vendored
@@ -1,5 +1,7 @@
|
||||
binstall
|
||||
bytecodealliance
|
||||
distro
|
||||
doas
|
||||
Dpkg
|
||||
jfrimmel
|
||||
koalaman
|
||||
|
||||
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
@@ -55,13 +55,16 @@ jobs:
|
||||
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:20.04
|
||||
# valgrind: installing snap to container is difficult...
|
||||
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
|
||||
- container: debian:latest
|
||||
# valgrind: installing snap to container is difficult...
|
||||
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
|
||||
- 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
|
||||
@@ -75,10 +78,10 @@ jobs:
|
||||
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 ca-certificates cargo curl unzip xz-utils
|
||||
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 curl tar xz
|
||||
run: apk add bash cargo
|
||||
shell: sh
|
||||
if: startsWith(matrix.container, 'alpine')
|
||||
- uses: ./
|
||||
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -10,6 +10,16 @@ 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.
|
||||
@@ -429,7 +439,8 @@ 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.5...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
|
||||
|
||||
@@ -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.
|
||||
|
||||
93
main.sh
93
main.sh
@@ -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.18.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-*-linux-gnu) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
|
||||
x86_64-*-linux-musl) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
|
||||
|
||||
armv7-*-linux-gnueabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
|
||||
armv7-*-linux-musleabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
|
||||
|
||||
aarch64-*-linux-gnu) url="${base_url}-aarch64-unknown-linux-musl.tgz" ;;
|
||||
aarch64-*-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
|
||||
|
||||
@@ -143,8 +153,12 @@ apt_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
|
||||
@@ -165,6 +179,19 @@ snap_install() {
|
||||
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'"
|
||||
@@ -179,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
|
||||
|
||||
@@ -189,6 +229,12 @@ if [[ ! -d "${cargo_bin}" ]]; then
|
||||
cargo_bin=/usr/local/bin
|
||||
fi
|
||||
|
||||
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
|
||||
version="${tool#*@}"
|
||||
@@ -318,9 +364,10 @@ for tool in "${tools[@]}"; do
|
||||
# https://nexte.st/book/pre-built-binaries.html
|
||||
case "${OSTYPE}" in
|
||||
linux*)
|
||||
host_triple
|
||||
case "${host}" in
|
||||
*-linux-gnu*) url="https://get.nexte.st/${version}/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" ;;
|
||||
esac
|
||||
;;
|
||||
@@ -356,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
|
||||
@@ -439,7 +491,6 @@ 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
|
||||
apt_update
|
||||
# libc6-dbg is needed to run Valgrind
|
||||
apt_install libc6-dbg
|
||||
# Use snap to install the latest Valgrind
|
||||
|
||||
Reference in New Issue
Block a user