-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathentrypoint.sh
executable file
·66 lines (52 loc) · 1.38 KB
/
entrypoint.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
#! /bin/bash
set -x
PREV_TARGET=
function set_output() {
printf "%s=%s\n" "$1" "$2" >> "$GITHUB_OUTPUT"
}
function cleanup() {
mv target deb-target
test -n "$PREV_TARGET" && mv "$PREV_TARGET" target
true
}
function process_variant() {
local _args _outp
_args="deb"
[ "$1" != "default" ] && _args="$_args --variant $1"
[ -n "$INPUT_DEBVERSION" ] && _args="$_args --deb-version $INPUT_DEBVERSION"
echo "cargo $_args" >&2
if test -z "$INPUT_SUBDIR"; then
_outp="$(cargo $_args | tail -1)"
else
_outp="$( (cd "$INPUT_SUBDIR" && cargo $_args | tail -1) )"
fi
if [ -n "$INPUT_PKGNAME" ] && [ -n "$INPUT_DEBVERSION" ]; then
if [ "$1" = "default" ]; then
set_output "deb" "deb-${_outp#$PWD/}"
else
set_output "deb_$1" "deb-${_outp#$PWD/}"
fi
fi
}
function main() {
local _var
cd "$GITHUB_WORKSPACE" || return 1
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git describe --tag --abbrev=0 "--match=v[0-9]*" "--match=pre-rel-v[0-9]*"
rustup default stable
if test -d ./target; then
mv target prev-target
PREV_TARGET=prev-target
fi
test -d deb-target && mv deb-target target
for _var in $INPUT_VARIANTS; do
process_variant "$_var" || {
local _rv
_rv=$?
cleanup
return $_rv
}
done
cleanup
}
main || exit $?