-
Notifications
You must be signed in to change notification settings - Fork 21
/
ship
executable file
·69 lines (65 loc) · 1.61 KB
/
ship
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
#!/usr/bin/env bash
##################################################################
##
## Ship a new version of cli to pub.dev
##
##
## Author: Chaobin Wu
## Email : [email protected]
##
#################################################################
die() {
echo "$*"
exit 1
}
echo "Try to ship cli to pub.dev"
clean() {
if [ -d "stash" ]; then
mv stash workflow
fi
}
echo "Step.1 Ignore stashed files"
if [ -d "workflow" ]; then
mv workflow stash
fi
echo "Step.2 Generate version and release configuration"
echo "Read version form pubspec.yaml"
verionText=$(grep version: < pubspec.yaml)
split=(${verionText//:/})
version="${split[1]}"
{
echo "/// This file will be updated when ship to pub.dev."
echo "/// Do not modify manually."
echo "///"
echo "/// Date: $(date)"
echo "/// Author: $(whoami)"
echo "const VERSION_NAME = '$version';"
echo "const RELEASE = 1;"
} > lib/utils/generated_config.dart
echo "Step.3 publish --dry-run"
flutter pub publish --dry-run
if [ ! $? = 0 ]; then
clean
die "Please fix error before publish."
fi
read -r -p "Looks great! Are you ready to continue (y/n)? " input
if [[ $input != 'y' ]]; then
clean
die "Shipping terminated!"
fi
flutter pub publish
if [ ! $? = 0 ]; then
clean
die "Please fix error before publish."
fi
read -r -p "swith window to commit local changes manually, then backup with git tag(y/n)? " yes
if [[ $yes != 'y' ]]; then
clean
die "Shipping terminated!"
fi
echo "backup with tag v$version"
git tag -a "v$version" -m "Release of $version"
echo "git push remote"
git push -u origin "v$version"
echo "Step.4 Ship completed!"
clean