forked from firebase/flutterfire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_publish.sh
executable file
·41 lines (35 loc) · 1.36 KB
/
check_publish.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
#!/bin/bash
set -e
# This script checks to make sure that each of the plugins *could* be published.
# It doesn't actually publish anything.
# So that users can run this script from anywhere and it will work as expected.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"
source "$SCRIPT_DIR/common.sh"
function check_publish() {
local failures=()
for dir in $(pub global run flutter_plugin_tools list --plugins="$1"); do
local package_name=$(basename "$dir")
echo "Checking that $package_name can be published."
if [[ $(cd "$dir" && cat pubspec.yaml | grep -E "^publish_to: none") ]]; then
echo "Package $package_name is marked as unpublishable. Skipping."
elif (cd "$dir" && flutter pub publish -- --dry-run > /dev/null); then
echo "Package $package_name is able to be published."
else
error "Unable to publish $package_name"
failures=("${failures[@]}" "$package_name")
fi
done
if [[ "${#failures[@]}" != 0 ]]; then
error "FAIL: The following ${#failures[@]} package(s) failed the publishing check:"
for failure in "${failures[@]}"; do
error "$failure"
done
fi
return "${#failures[@]}"
}
# Sets CHANGED_PACKAGE_LIST and CHANGE_PACKAGES
check_changed_packages
if [[ "${#CHANGED_PACKAGE_LIST[@]}" != 0 ]]; then
check_publish "${CHANGED_PACKAGES}"
fi