mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-21 15:10:27 +00:00
Improve support for Fedora/RHEL based containers/self-hosted runners
This commit is contained in:
2
.github/.cspell/project-dictionary.txt
vendored
2
.github/.cspell/project-dictionary.txt
vendored
@@ -8,12 +8,14 @@ koalaman
|
||||
libc
|
||||
linkcheck
|
||||
mdbook
|
||||
microdnf
|
||||
mvdan
|
||||
nextest
|
||||
protobuf
|
||||
protoc
|
||||
protocolbuffers
|
||||
quickinstall
|
||||
rockylinux
|
||||
rustwasm
|
||||
shellcheck
|
||||
shfmt
|
||||
|
||||
57
.github/workflows/ci.yml
vendored
57
.github/workflows/ci.yml
vendored
@@ -56,34 +56,73 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
container:
|
||||
- ubuntu:20.04
|
||||
- debian:latest
|
||||
- ubuntu:20.04 # glibc 2.31
|
||||
- debian:11-slim # glibc 2.31
|
||||
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
|
||||
- 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: ubuntu:18.04 # glibc 2.27
|
||||
# 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.
|
||||
- container: debian:10-slim # glibc 2.28
|
||||
# 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: 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: rockylinux:8 # glibc 2.28
|
||||
# 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: rockylinux:8-minimal # glibc 2.28
|
||||
# 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: centos:7 # glibc 2.17
|
||||
# cargo-udeps,protoc,valgrind,wasmtime,mdbook-linkcheck,cargo-watch don't provide prebuilt binaries for musl host.
|
||||
# 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)
|
||||
# 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,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.
|
||||
# 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-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 (fedora/rockylinux)
|
||||
run: |
|
||||
set -ex
|
||||
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 -ex
|
||||
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: apk add bash cargo
|
||||
run: |
|
||||
set -ex
|
||||
apk add bash cargo
|
||||
shell: sh
|
||||
if: startsWith(matrix.container, 'alpine')
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: ./
|
||||
with:
|
||||
tool: ${{ matrix.tool }}
|
||||
|
||||
@@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- 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)
|
||||
|
||||
@@ -104,11 +104,11 @@ If you want a higher level of security, consider working on [#1](https://github.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) and containers (Ubuntu, Debian, Alpine).
|
||||
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)
|
||||
- cargo (if you install cargo subcommands or use cargo-binstall fallback)
|
||||
|
||||
## Related Projects
|
||||
|
||||
|
||||
56
main.sh
56
main.sh
@@ -51,7 +51,7 @@ download() {
|
||||
tar_args+=("xjf")
|
||||
if ! type -P bzip2 &>/dev/null; then
|
||||
case "${base_distro}" in
|
||||
debian | alpine) sys_install bzip2 ;;
|
||||
debian | alpine | fedora) sys_install bzip2 ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
@@ -60,21 +60,21 @@ download() {
|
||||
if ! type -P xz &>/dev/null; then
|
||||
case "${base_distro}" in
|
||||
debian) sys_install xz-utils ;;
|
||||
alpine) sys_install xz ;;
|
||||
alpine | fedora) sys_install xz ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
*.zip)
|
||||
if ! type -P unzip &>/dev/null; then
|
||||
case "${base_distro}" in
|
||||
debian | alpine) sys_install unzip ;;
|
||||
debian | alpine | fedora) sys_install unzip ;;
|
||||
esac
|
||||
fi
|
||||
mkdir -p .install-action-tmp
|
||||
(
|
||||
cd .install-action-tmp
|
||||
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
|
||||
mv "${bin}" "${bin_dir}/"
|
||||
)
|
||||
@@ -90,7 +90,7 @@ download() {
|
||||
tar_args+=(--strip-components "${components}")
|
||||
fi
|
||||
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}"
|
||||
}
|
||||
host_triple() {
|
||||
@@ -186,10 +186,18 @@ apk_install() {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -217,9 +225,37 @@ case "${OSTYPE}" in
|
||||
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.
|
||||
if type -P sudo &>/dev/null; then
|
||||
sudo yum update -y
|
||||
sudo yum install -y dnf
|
||||
else
|
||||
yum update -y
|
||||
yum install -y dnf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
cygwin* | msys*) exe=".exe" ;;
|
||||
esac
|
||||
@@ -231,7 +267,7 @@ 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 ;;
|
||||
debian | alpine | fedora) sys_install ca-certificates curl tar ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -376,7 +412,7 @@ for tool in "${tools[@]}"; do
|
||||
*) bail "unsupported OSTYPE '${OSTYPE}' for ${tool}" ;;
|
||||
esac
|
||||
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}"
|
||||
;;
|
||||
protoc)
|
||||
@@ -405,14 +441,14 @@ for tool in "${tools[@]}"; do
|
||||
esac
|
||||
if ! type -P unzip &>/dev/null; then
|
||||
case "${base_distro}" in
|
||||
debian | alpine) sys_install unzip ;;
|
||||
debian | alpine | fedora) sys_install unzip ;;
|
||||
esac
|
||||
fi
|
||||
mkdir -p .install-action-tmp
|
||||
(
|
||||
cd .install-action-tmp
|
||||
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
|
||||
mv "bin/protoc${exe}" "${bin_dir}/"
|
||||
mkdir -p "${include_dir}/"
|
||||
@@ -476,7 +512,7 @@ for tool in "${tools[@]}"; do
|
||||
esac
|
||||
url="https://github.com/${repo}/releases/download/v${version}/${tool}_v${version}_${target}${exe}"
|
||||
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
|
||||
linux* | darwin*) chmod +x "${bin_dir}/${tool}${exe}" ;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user