Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use GITHUB_ACTION_PATH #666

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 1 addition & 89 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,96 +49,8 @@ runs:
working-directory: ${{ inputs.working_directory }}
if: inputs.enable_aqua_install == 'true' && runner.os == 'Windows'

# Copy aqua-installer in action.
# https://github.com/aquaproj/aqua-installer/issues/461
# https://github.com/actions/runner/issues/2185
- run: |
set -eu
set -o pipefail || :

uname_os() {
local os
os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in
cygwin_nt*) os="windows" ;;
mingw*) os="windows" ;;
msys_nt*) os="windows" ;;
esac
echo "$os"
}

uname_arch() {
local arch
arch=$(uname -m)
case $arch in
x86_64) arch="amd64" ;;
aarch64) arch="arm64" ;;
esac
echo "${arch}"
}

OS="$(uname_os)"
ARCH="$(uname_arch)"

install_path=${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin/aqua
if [ "$OS" = windows ]; then
install_path=${AQUA_ROOT_DIR:-$HOME/AppData/Local/aquaproj-aqua}/bin/aqua.exe
fi

bootstrap_version=v2.27.4
checksums="fa04116332b454f9e06020a0afb1fa87c7cda46d2e1e97fd3d9fd93a46cec1e4 aqua_darwin_amd64.tar.gz
3190f8d9d1655e65322f396ae2eb493257a8df0c4ec2e4cf221c6e72bb7a4452 aqua_darwin_arm64.tar.gz
0e6be7a87a5466fe3b236e1909904b0407a5d8b5ce3035f1f5a108ff8f3869e8 aqua_linux_amd64.tar.gz
60361a4c41491f1c3a5615eb14fffa0a2f2b907bbe920a58a7fd44d840ae8941 aqua_linux_arm64.tar.gz
444e9da7249b456def5ac2eee9a42fee86d5e74f1a883a3c8748a36c1c857392 aqua_windows_amd64.zip
eb4032e839c345677b1e86552c6693fe6e6a05c669ecb3882b7d5a4df45c0dcd aqua_windows_arm64.zip"

filename=aqua_${OS}_${ARCH}.tar.gz
if [ "$OS" = windows ]; then
filename=aqua_${OS}_${ARCH}.zip
fi
URL=https://github.com/aquaproj/aqua/releases/download/$bootstrap_version/$filename

tempdir=$(mktemp -d)
echo "[INFO] Installing aqua $bootstrap_version for bootstrapping..." >&2
echo "[INFO] Downloading $URL ..." >&2
if command -v curl > /dev/null 2>&1; then
curl --fail -L "$URL" -o "$tempdir/$filename"
elif command -v wget > /dev/null 2>&1; then
wget -P "$tempdir" "$URL"
else
echo "[ERROR] Neither curl nor wget is found. Please install either curl or wget to download aqua" >&2
exit 1
fi

cd "$tempdir"

echo "[INFO] Verifying checksum of aqua $bootstrap_version ..." >&2
if command -v sha256sum > /dev/null 2>&1; then
echo "$checksums" | grep "$filename" | sha256sum -c
elif command -v shasum > /dev/null 2>&1; then
echo "$checksums" | grep "$filename" | shasum -a 256 -c
else
echo "[WARN] Skipped checksum verification of aqua $bootstrap_version because both sha256sum and shasum commands aren't found" >&2
fi

if [ "$OS" = windows ]; then
unzip "$filename" > /dev/null
else
tar xvzf "$filename" > /dev/null
fi
chmod a+x aqua
if [ -n "${AQUA_VERSION:-}" ]; then
echo "[INFO] $tempdir/aqua update-aqua $AQUA_VERSION" >&2
./aqua update-aqua "$AQUA_VERSION"
else
echo "[INFO] $tempdir/aqua update-aqua" >&2
./aqua update-aqua
fi

"$install_path" -v

rm -R "$tempdir"
"${GITHUB_ACTION_PATH}/aqua-installer" -v "$AQUA_VERSION"
working-directory: ${{ inputs.working_directory }}
shell: bash
env:
Expand Down