forked from iter8-tools/iter8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
52 lines (49 loc) · 2.2 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
name: "Iter8 Install"
description: "Install Iter8 CLI"
branding:
icon: check-circle
color: green
runs:
using: "composite"
steps:
- name: Install Iter8 CLI
shell: bash
env:
VERSION: ${{ github.action_ref }}
run: |
# For details on context variables runner.os and runner.arch, see:
# https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
# The returned values do not match those used by the build artifacts.
# See https://github.com/iter8-tools/iter8/blob/master/Makefile#L4 (and for other valid combinations: https://github.com/mitchellh/gox/blob/master/platform.go#L28-L101)
# Therefore, this code trasforms the context variables as follows:
# os: Linux -> linux, Windows -> windows, macOS -> darwin
# arch: X86 -> 386 amd X64 -> amd64
OS=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]' | sed 's/macos/darwin/')
ARCH=$(echo ${{ runner.arch }} | sed 's/X86/386/' | sed 's/X64/amd64/')
RELEASE="${{ env.VERSION }}"
if [ -z $RELEASE ] || [ $RELEASE = "stable" ]; then
REL=$(curl -s "https://api.github.com/repos/iter8-tools/iter8/releases/latest" | jq -r '.tag_name')
fi
if [ -z $REL ]; then
REL=$(curl -s "https://api.github.com/repos/iter8-tools/iter8/tags" | jq --arg RELEASE $RELEASE -r '.[] | select(.commit.sha==$RELEASE) | .name')
fi
if [ -z $REL ]; then
REL=$(curl -s "https://api.github.com/repos/iter8-tools/iter8/releases" | jq -r '.[] | .tag_name' | grep $RELEASE | head -1)
fi
if [ -z $REL ]; then
echo "Invalid release specified: $RELEASE"
exit 1
fi
echo "Installing Iter8 version $REL"
ASSET="iter8-$OS-$ARCH.tar.gz"
ASSET_URL="https://github.com/iter8-tools/iter8/releases/download/$REL/$ASSET"
echo "Downloading $ASSET_URL"
wget -q $ASSET_URL && rc=$? || rc=$?
if [ $rc -eq 0 ]; then
# echo "SUCCESS: downloaded $ASSET from $ASSET_URL"
tar -xvf $ASSET
mv $OS-$ARCH/iter8 /usr/local/bin
else
echo "ERROR: unable to download $ASSET from $ASSET_URL"
exit 1
fi