-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
77 lines (72 loc) · 1.97 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
name: Setup Yampl
description: GitHub Action to install Yampl during CI/CD.
branding:
color: orange
icon: download
inputs:
repo:
description: The Yampl repo to use
default: clevyr/yampl
token:
description: GitHub token
default: ${{ github.token }}
version:
description: The Yampl version to install
default: latest
outputs:
version:
description: The Yampl version that was installed
value: ${{ steps.install.outputs.version }}
runs:
using: composite
steps:
- id: install
name: Install Yampl
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
GH_REPO: ${{ inputs.repo }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [[ "$VERSION" == latest ]]; then
VERSION=
fi
case "${{ runner.os }}" in
Linux)
OS=linux
FILENAME=yampl
;;
macOS)
OS=darwin
FILENAME=yampl
;;
Windows)
OS=windows
FILENAME=yampl.exe
;;
esac
RELEASE="$(gh release view --json=name,assets $VERSION)"
VERSION="$(jq -r '.name' <<<"$RELEASE")"
echo "version=$VERSION" >>$GITHUB_OUTPUT
echo "Installing yampl $VERSION..."
DEST="$RUNNER_TEMP/yampl"
ASSET="$(jq -r --arg OS "$OS" \
'.assets[].name | select(ascii_downcase | test($OS + "_(amd64|x86_64).(tar.gz|zip)$"))' \
<<<"$RELEASE" \
)"
echo "Downloading $ASSET"
mkdir -p "$DEST"
cd "$DEST"
case "$ASSET" in
*.tar.gz)
gh release download "$VERSION" --pattern="$ASSET" --output=- | tar -xzf - "$FILENAME" ;;
*.zip)
gh release download "$VERSION" --pattern="$ASSET"
unzip -o "$ASSET" "$FILENAME"
rm "$ASSET"
;;
*)
echo Invalid file type; exit 1;;
esac
echo "$DEST" >>$GITHUB_PATH