-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
78 lines (66 loc) · 2.49 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
name: "Setup Zarf"
description: "Installs Zarf and includes the Zarf CLI in the PATH"
inputs:
version:
description: "The version of Zarf to install. Uses the latest version if not specified."
download-init-package:
description: "Download the corresponding Zarf init package."
runs:
using: "composite"
steps:
- shell: bash
run: |
#!/bin/bash
# Base url for zarf release artifacts
target_dir="${HOME}/.zarf-cache"
version="${{ inputs.version }}"
# Use latest version if not specified
if [ "${version}" == "" ]; then
version=$(curl -sIX HEAD https://github.com/zarf-dev/zarf/releases/latest | grep -i ^location: | grep -Eo 'v[0-9]+.[0-9]+.[0-9]+')
fi
release_path="https://github.com/zarf-dev/zarf/releases/download/${version}"
mkdir -p $target_dir
# Set the architecture variable
case ${{ runner.arch }} in
X64)
arch="amd64"
;;
ARM64)
arch="arm64"
;;
*)
echo "Unsupported architecture, only X64 and ARM64 are supported."
exit 1
;;
esac
# Set the filename variable
case ${{ runner.os }} in
Linux)
filename="Linux_${arch}"
;;
macOS)
filename="Darwin_${arch}"
;;
Windows)
filename="Windows_${arch}.exe"
suffix=".exe"
;;
*)
echo "Unsupported OS type, only Linux, macOS, and Windows are supported."
exit 1
;;
esac
echo "Downloading Zarf ${version} for ${{ runner.os }} ${arch}"
curl -sL "${release_path}/zarf_${version}_${filename}" -o "${target_dir}/zarf${suffix}"
# Make the file executable if it's not a Windows binary
[ "${{ runner.os }}" == "Windows" ] || chmod +x "${target_dir}/zarf"
if [ "${{ inputs.download-init-package }}" == "true" ]; then
echo "Downloading Zarf init package ${version} for ${{ runner.os }} ${arch}"
curl -sL "${release_path}/zarf-init-${arch}-${version}.tar.zst" -o "${target_dir}/zarf-init-${arch}-${version}.tar.zst"
fi
- if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: echo "${HOME}/.zarf-cache" >> $GITHUB_PATH
shell: bash
- if: ${{ runner.os == 'Windows' }}
run: echo "${HOME}/.zarf-cache" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh