-
Notifications
You must be signed in to change notification settings - Fork 15
/
entrypoint.sh
executable file
·79 lines (68 loc) · 1.36 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
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh
set -e
check_credentials() {
echo "Check credentials"
if [ -z "$INPUT_CREDENTIAL" ]; then
echo "Missing credential"
exit 1
fi
echo "OK"
}
copy_credential() {
echo "Copy credentials"
mkdir -p ~/Library/Application\ Support/dart
cat <<EOF > ~/Library/Application\ Support/dart/pub-credentials.json
$INPUT_CREDENTIAL
EOF
mkdir -p ~/.pub-cache
ln -s ~/Library/Application\ Support/dart/pub-credentials.json credentials.json
echo "OK"
}
switch_working_directory() {
echo "Switching to package directory"
cd "$INPUT_PACKAGE_DIRECTORY"
}
test_dart() {
echo "Run test for dart"
dart pub get
dart run test
}
test_flutter() {
echo "Run test for flutter"
flutter pub get
flutter test
}
run_test_if_needed() {
if "${INPUT_SKIP_TEST}"; then
echo 'Skip test'
else
if "${INPUT_FLUTTER_PACKAGE}"; then
test_flutter
else
test_dart
fi
fi
}
create_prefix() {
EXECUTABLE_PREFIX="dart"
if "${INPUT_FLUTTER_PACKAGE}"; then
EXECUTABLE_PREFIX="flutter"
fi
}
dry_run() {
echo "Executing package validation"
$EXECUTABLE_PREFIX pub publish --dry-run
}
publish_package() {
dry_run
if [ "${INPUT_DRY_RUN}" = false ]; then
echo "Publish package to Pub"
$EXECUTABLE_PREFIX pub publish -f
fi
}
check_credentials
copy_credential
switch_working_directory
run_test_if_needed
create_prefix
publish_package