-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
120 lines (107 loc) · 4.56 KB
/
Copy pathaction.yml
File metadata and controls
120 lines (107 loc) · 4.56 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Install fda
# Marketplace rejects a description of 125 characters or more.
description: >-
Install the Feldera CLI (fda) from GitHub releases and add it to PATH. Linux,
macOS and Windows.
author: Feldera
branding:
icon: download
color: blue
inputs:
version:
description: >-
Release to install, with or without a leading `v` (for example `0.327.0`).
`latest` resolves the newest release of feldera/feldera.
required: false
default: latest
outputs:
version:
description: "The release that was installed, without the leading `v`"
value: ${{ steps.install.outputs.version }}
path:
description: "Directory the binary was installed into"
value: ${{ steps.install.outputs.path }}
runs:
using: composite
steps:
- id: install
shell: bash
env:
FDA_INPUT_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
# RUNNER_OS/RUNNER_ARCH rather than uname: uname reports MINGW64_NT on
# Windows runners, and these are the values Actions guarantees.
case "${RUNNER_OS}:${RUNNER_ARCH}" in
Linux:X64) target=x86_64-unknown-linux-gnu ;;
Linux:ARM64) target=aarch64-unknown-linux-gnu ;;
macOS:ARM64) target=aarch64-apple-darwin ;;
Windows:X64) target=x86_64-pc-windows-msvc ;;
*)
echo "::error::No fda build is published for ${RUNNER_OS} ${RUNNER_ARCH}." >&2
echo "Published targets: Linux X64, Linux ARM64, macOS ARM64, Windows X64." >&2
exit 1
;;
esac
if [ "$FDA_INPUT_VERSION" = "latest" ]; then
# /releases/latest redirects to the newest release's tag page. Read the
# tag off that redirect rather than asking the API: the job's token is
# scoped to the caller's own repository and is refused for another
# repository's API, and an unauthenticated API call is rate limited per
# IP, which runners share.
effective=$(curl -sSLI -o /dev/null -w '%{url_effective}' \
https://github.com/feldera/feldera/releases/latest)
tag="${effective##*/}"
case "$tag" in
v[0-9]*) ;;
*)
echo "::error::Could not resolve the latest feldera release (got '${effective}')." >&2
exit 1
;;
esac
else
tag="v${FDA_INPUT_VERSION#v}"
fi
version="${tag#v}"
# Keyed by target, not by arch alone: two targets can share an arch,
# and a stale entry would otherwise be reused for the wrong platform.
dest="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:-/tmp}}/fda/${version}/${target}"
binary="fda"
[ "$RUNNER_OS" = "Windows" ] && binary="fda.exe"
if [ ! -x "$dest/$binary" ]; then
mkdir -p "$dest"
archive="${RUNNER_TEMP:-/tmp}/fda-${target}.zip"
url="https://github.com/feldera/feldera/releases/download/${tag}/fda-${target}.zip"
echo "Downloading $url"
# --fail-with-body so a 404 for an unknown version reports the status
# rather than saving the error page and failing later in unzip.
if ! curl -sSL --fail-with-body -o "$archive" "$url"; then
echo "::error::No fda ${version} build for ${target}. Check the version and that the release publishes this target." >&2
exit 1
fi
# Git Bash on Windows runners ships no unzip.
if [ "$RUNNER_OS" = "Windows" ]; then
powershell -NoProfile -NonInteractive -Command \
"Expand-Archive -LiteralPath '$(cygpath -w "$archive")' -DestinationPath '$(cygpath -w "$dest")' -Force"
else
unzip -q -o "$archive" -d "$dest"
fi
rm -f "$archive"
chmod +x "$dest/$binary" 2>/dev/null || true
else
echo "Reusing the copy already in the tool cache"
fi
if [ ! -x "$dest/$binary" ]; then
echo "::error::$binary is missing from the extracted archive." >&2
exit 1
fi
# $GITHUB_PATH applies to later steps, so check the binary directly here
# rather than reporting success on something that cannot run.
"$dest/$binary" --version
# Other shells need the native path; bash on Windows produces /d/a/...
path_out="$dest"
[ "$RUNNER_OS" = "Windows" ] && path_out="$(cygpath -w "$dest")"
echo "$path_out" >> "$GITHUB_PATH"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "path=$path_out" >> "$GITHUB_OUTPUT"
echo "Installed fda $version for $target"