forked from aquaproj/aqua-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
157 lines (137 loc) · 5.69 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Install aqua
description: Install aqua https://aquaproj.github.io/ and install tools with aqua
inputs:
aqua_version:
description: installed aqua's version (e.g. v0.8.7)
required: true
enable_aqua_install:
required: false
default: "true"
aqua_opts:
required: false
default: "-l"
policy_allow:
required: false
description: |
aqua >= v2.3.0
If this isn't empty, "aqua policy allow" is run.
If this is "true", "aqua policy allow" is run without argument.
If this isn't empty and isn't "true", "aqua policy allow <inputs.policy_allow>" is run.
working_directory:
required: false
default: ""
runs:
using: composite
steps:
- run: |
echo "::error ::aqua_version is required. https://github.com/aquaproj/aqua-installer"
exit 1
shell: bash
if: inputs.aqua_version == ''
- run: echo "${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin" >> $GITHUB_PATH
shell: bash
working-directory: ${{ inputs.working_directory }}
if: inputs.enable_aqua_install == 'true' && runner.os != 'Windows'
- run: |
echo "${AQUA_ROOT_DIR:-$HOME/AppData/Local/aquaproj-aqua}/bin" >> $GITHUB_PATH
echo "${AQUA_ROOT_DIR:-$HOME/AppData/Local/aquaproj-aqua}/bat" >> $GITHUB_PATH
shell: bash
working-directory: ${{ inputs.working_directory }}
if: inputs.enable_aqua_install == 'true' && runner.os == 'Windows'
- run: |
$(if($env:AQUA_ROOT_DIR) {echo $env:AQUA_ROOT_DIR} else {echo "$HOME/AppData/Local/aquaproj-aqua/bin"}) | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$(if($env:AQUA_ROOT_DIR) {echo $env:AQUA_ROOT_DIR} else {echo "$HOME/AppData/Local/aquaproj-aqua/bat"}) | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
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.16.4
checksums="34ad1e7f88e6fcc13f3bed2e7470ab570c4440aaa441e1b545cc514c571e9a2f aqua_darwin_arm64.tar.gz
468c6c51f37196e6c21a096498eb4d3f7ba5cea3593b44af89087f571c207bc9 aqua_windows_amd64.tar.gz
6c2b6165000f3f2c5f04bbb52c8fe97b686cfbaa80493d866ad6770400b1773e aqua_linux_arm64.tar.gz
7457ea4870f953de17c68fe8f86b3243c14890aa94a05e713d3c22ef401968b2 aqua_linux_amd64.tar.gz
c49f010e7e731ed62e7289169162001413f319cb593250a525aae26ee4551c3f aqua_darwin_amd64.tar.gz
dcbc4c160827187504994a8f2ec4b5b7944a05da48b011de7a6cade9becd14e5 aqua_windows_arm64.tar.gz"
filename=aqua_${OS}_${ARCH}.tar.gz
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 aren't found" >&2
fi
tar xvzf "$filename" > /dev/null
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"
working-directory: ${{ inputs.working_directory }}
shell: bash
env:
AQUA_VERSION: ${{ inputs.aqua_version }}
- run: aqua policy allow
working-directory: ${{ inputs.working_directory }}
if: inputs.policy_allow == 'true'
shell: bash
- run: aqua policy allow "$POLICY_FILE"
working-directory: ${{ inputs.working_directory }}
if: |
inputs.policy_allow != 'true' && inputs.policy_allow != ''
shell: bash
env:
POLICY_FILE: ${{ inputs.policy_allow }}
- run: aqua i $AQUA_OPTS
working-directory: ${{ inputs.working_directory }}
shell: bash
env:
AQUA_OPTS: ${{ inputs.aqua_opts }}