generated from ebi-yade/go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
59 lines (56 loc) · 2.23 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
name: Setup why-go-over
description: "Install a binary from https://github.com/ebi-yade/why-go-over/releases"
inputs:
version:
description: "The version to install why-go-over"
default: latest
required: false
github-token:
description: "The token used when calling GitHub API"
required: false
default: ${{ github.token }}
runs:
using: "composite"
steps:
- shell: bash
env:
github_token: ${{ inputs.github-token }}
VERSION: ${{ inputs.version }}
run: |
set -eo pipefail
ARCH=$(uname -m)
if [ "${ARCH}" = "x86_64" ]; then
GOARCH="amd64"
elif [ "${ARCH}" = "aarch64" ]; then
GOARCH="arm64"
else
echo "Unsupported architecture: ${ARCH}"
exit 1
fi
echo "VERSION=${VERSION} GOARCH=${GOARCH}"
api_request_args=("-sS")
if [[ -n "$github_token" ]]; then
api_request_args=("${api_request_args[@]}" -H "authorization: token $github_token")
fi
if [ "${VERSION}" = "latest" ]; then
DOWNLOAD_URL=$(curl "${api_request_args[@]}" https://api.github.com/repos/ebi-yade/why-go-over/releases \
| jq --arg matcher "linux.${GOARCH}." -r '[.[]|select(.prerelease==false)][0].assets[].browser_download_url|select(match($matcher))')
else
DOWNLOAD_URL=https://github.com/ebi-yade/why-go-over/releases/download/${VERSION}/why-go-over_${VERSION:1}_linux_${GOARCH}.tar.gz
fi
echo "DOWNLOAD_URL=${DOWNLOAD_URL}"
mkdir -p ${RUNNER_TOOL_CACHE}/why-go-over
cd /tmp
curl -sfLO ${DOWNLOAD_URL}
if [[ "${DOWNLOAD_URL}" =~ \.tar\.gz$ ]]; then
FILENAME=$(basename $DOWNLOAD_URL .tar.gz)
tar xzvf ${FILENAME}.tar.gz
sudo install why-go-over ${RUNNER_TOOL_CACHE}/why-go-over/why-go-over
elif [[ "${DOWNLOAD_URL}" =~ \.zip$ ]]; then
FILENAME=$(basename $DOWNLOAD_URL .zip)
unzip ${FILENAME}.zip
sudo install ${FILENAME} ${RUNNER_TOOL_CACHE}/why-go-over/why-go-over
fi
echo "Adding ${RUNNER_TOOL_CACHE}/why-go-over to path..."
echo "${RUNNER_TOOL_CACHE}/why-go-over" >> $GITHUB_PATH
"${RUNNER_TOOL_CACHE}/why-go-over/why-go-over" -v