-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.sh
executable file
·75 lines (69 loc) · 1.7 KB
/
convert.sh
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
#! /bin/sh
set -ex
os_json() {
local name="$1"
local value="$(
cat "$tmpfile" |
jq -Mc '.os | split(" ") | map(select(startswith("'"$name"'-")))'
)"
echo "$name=$value"
}
targets_json() {
local name="$1"
local value="$(
cat "$tmpfile" |
jq -Mc '."'"$name"'" | split(" ") | map(select(.!=""))'
)"
echo "$name=$value"
}
svn_json() {
local name="$1"
local value="$(jq -r ".\"$name\"" <"$tmpfile")"
case "$value" in
apache/subversion@*|$GITHUB_REPOSITORY_OWNER/*@*)
value="$(
echo "$value" |
jq -RMc 'split("@") | {repository: .[0], ref: .[1]}'
)"
;;
https://dist.apache.org/*/subversion-*.tar.bz2|https://svn.apache.org/*/subversion-*.tar.bz2)
value="$(echo "$value" | jq -RMc '{archive: .}')"
;;
[0-9]*.[0-9]*.[0-9]*)
value="$(echo "https://archive.apache.org/dist/subversion/subversion-$value.tar.bz2" | jq -RMc '{archive: .}')"
;;
*)
echo "Unrecognized inputs.subversion: '$value'" 1>&2
exit 1
;;
esac
echo "$name=$value"
}
deps_json() {
local name="$1"
local value="$(
cat "$tmpfile" |
jq -Mc '."'"$name"'" | split(" ") | map(select(.!="") | split("=") | {(.[0]): .[1]}) | add'
)"
echo "$name=$value"
}
tmpfile="$(mktemp)"
echo "$INPUTS" >"$tmpfile"
{
os_json 'ubuntu'
os_json 'macos'
os_json 'windows'
targets_json 'targets'
svn_json 'subversion'
deps_json 'dependencies'
} >>"$GITHUB_OUTPUT"
{
echo '### Inputs:'
echo '```json'
cat "$tmpfile"
echo '```'
echo '### Outputs:'
echo '```'
cat "$GITHUB_OUTPUT"
echo '```'
} >>"$GITHUB_STEP_SUMMARY"