-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
83 lines (77 loc) · 2.75 KB
/
action.yml
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
# action.yml
name: soci-installer
author: lerentis
description: 'Installs soci and includes it in your path'
branding:
icon: 'package'
color: 'blue'
inputs:
soci-release:
description: 'soci release version to be installed'
required: false
default: 'v0.4.0'
install-dir:
description: 'Where to install the soci cli'
required: false
default: '$HOME/.soci'
runs:
using: "composite"
steps:
- shell: bash
run: |
#!/bin/bash
shopt -s expand_aliases
if [ -z "$NO_COLOR" ]; then
alias log_info="echo -e \"\033[1;32mINFO\033[0m:\""
alias log_error="echo -e \"\033[1;31mERROR\033[0m:\""
else
alias log_info="echo \"INFO:\""
alias log_error="echo \"ERROR:\""
fi
set -e
mkdir -p ${{ inputs.install-dir }}
_version=${{ inputs.soci-release }}
case ${{ runner.os }} in
Linux)
case ${{ runner.arch }} in
X64)
release_archive="soci-snapshotter-${_version:1}-linux-amd64-static.tar.gz"
release_shasums="${release_archive}.sha256sum"
;;
ARM64)
release_archive="soci-snapshotter-${_version:1}-linux-arm64-static.tar.gz"
release_shasums="${release_archive}.sha256sum"
;;
*)
log_error "unsupported architecture $arch"
exit 1
;;
esac
;;
*)
log_error "unsupported OS ${{ runner.os }}"
log_error "Only Linux binaries are available"
exit 1
;;
esac
SUDO=
if command -v sudo >/dev/null; then
SUDO=sudo
log_info "Sudo functional. Beginngin system installation"
elif [ "$EUID" -eq 0 ]; then
log_info "Root permissions. Beginngin system installation"
else
log_info "Sudo not functional and not root. continue with user permissions"
fi
current_dir=$(pwd)
cd /tmp
curl -sL "https://github.com/awslabs/soci-snapshotter/releases/download/${{ inputs.soci-release }}/${release_archive}" -o "/tmp/${release_archive}"
curl -sL "https://github.com/awslabs/soci-snapshotter/releases/download/${{ inputs.soci-release }}/${release_shasums}" -o "/tmp/${release_shasums}"
sha256sum -c "${release_shasums}";
tar xf "${release_archive}"
$SUDO mv soci "${{ inputs.install-dir }}/soci"
rm THIRD_PARTY_LICENSES NOTICE.md "${release_archive}" "${release_shasums}" soci-snapshotter-grpc
cd "${current_dir}"
- if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: echo "${{ inputs.install-dir }}" >> $GITHUB_PATH
shell: bash