-
-
Notifications
You must be signed in to change notification settings - Fork 84
/
release.sh
executable file
·145 lines (121 loc) · 4.68 KB
/
release.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env sh
set -e
if [ -z "$1" ]; then
echo "No version name was supplied"
exit 1
fi
if git diff --quiet; then
echo "No unstashed changes, so continuing"
else
echo "You have unstashed or uncommitted changes. Please commit changes before running this!"
exit 1
fi
VERSION_BASE=300000000
VERSION_NUMBER=""
generate_version_number() {
commit_number=$(git rev-list HEAD --count)
VERSION_NUMBER="$((VERSION_BASE+commit_number))"
if [ -e fastlane/metadata/android/en-US/changelogs/"$VERSION_NUMBER.txt" ]; then
echo "The version $VERSION_NUMBER already exists"
exit 1
fi
}
generate_version_number
VERSION_NUMBER_FDROID_ABI_1="$((VERSION_NUMBER+00000000))"
VERSION_NUMBER_FDROID_ABI_2="$((VERSION_NUMBER+10000000))"
VERSION_NUMBER_FDROID_ABI_3="$((VERSION_NUMBER+20000000))"
VERSION_NAME=$1
VERSION_FLUTTER="3.7.8"
FULL_VERSION="$VERSION_NAME"+"$VERSION_NUMBER"
# Set the new version in pubspec.yaml
sed -i "s/version: .*/version: $FULL_VERSION/g" pubspec.yaml
# Rename the draft changelog with the new version number
if [ -e fastlane/metadata/android/en-US/changelogs/next.txt ]; then
cp fastlane/metadata/android/en-US/changelogs/next.txt fastlane/metadata/android/en-US/changelogs/"$VERSION_NUMBER".txt
cp fastlane/metadata/android/en-US/changelogs/next.txt fastlane/metadata/android/en-US/changelogs/"$VERSION_NUMBER_FDROID_ABI_1".txt
cp fastlane/metadata/android/en-US/changelogs/next.txt fastlane/metadata/android/en-US/changelogs/"$VERSION_NUMBER_FDROID_ABI_2".txt
cp fastlane/metadata/android/en-US/changelogs/next.txt fastlane/metadata/android/en-US/changelogs/"$VERSION_NUMBER_FDROID_ABI_3".txt
fi
# Create a new draft changelog for the next release
echo "" > fastlane/metadata/android/en-US/changelogs/next.txt
# Commit the changes
git add pubspec.yaml fastlane/metadata/android/en-US/changelogs/next.txt fastlane/metadata/android/en-US/changelogs/3*.txt
git commit -m "Tagging v$VERSION_NAME"
git tag v"$VERSION_NAME"
VERSION_COMMIT=$(git rev-parse HEAD)
echo "F-Droid metadata:"
echo ""
FDROID_METADATA=$(cat << EOF
- versionName: $VERSION_NAME
versionCode: $VERSION_NUMBER_FDROID_ABI_1
commit: $VERSION_COMMIT
output: build/app/outputs/flutter-apk/app-x86_64-release.apk
srclibs:
- flutter@$VERSION_FLUTTER
rm:
- ios
- test
prebuild:
# Change pub cache location so that the dart packages are scanned by the scanner
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter config --no-analytics
- \$\$flutter\$\$/bin/flutter pub get
build:
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter packages pub run flutter_oss_licenses:generate.dart
- \$\$flutter\$\$/bin/flutter packages pub run intl_utils:generate
- \$\$flutter\$\$/bin/flutter build apk --release --no-tree-shake-icons --split-per-abi
--target-platform=android-x64 --build-number=\$\$VERCODE\$\$
scandelete:
- .pub-cache
- versionName: $VERSION_NAME
versionCode: $VERSION_NUMBER_FDROID_ABI_2
commit: $VERSION_COMMIT
output: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
srclibs:
- flutter@$VERSION_FLUTTER
rm:
- ios
- test
prebuild:
# Change pub cache location so that the dart packages are scanned by the scanner
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter config --no-analytics
- \$\$flutter\$\$/bin/flutter pub get
build:
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter packages pub run flutter_oss_licenses:generate.dart
- \$\$flutter\$\$/bin/flutter packages pub run intl_utils:generate
- \$\$flutter\$\$/bin/flutter build apk --release --no-tree-shake-icons --split-per-abi
--target-platform=android-arm --build-number=\$\$VERCODE\$\$
scandelete:
- .pub-cache
- versionName: $VERSION_NAME
versionCode: $VERSION_NUMBER_FDROID_ABI_3
commit: $VERSION_COMMIT
output: build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
srclibs:
- flutter@$VERSION_FLUTTER
rm:
- ios
- test
prebuild:
# Change pub cache location so that the dart packages are scanned by the scanner
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter config --no-analytics
- \$\$flutter\$\$/bin/flutter pub get
build:
- export PUB_CACHE=$(pwd)/.pub-cache
- \$\$flutter\$\$/bin/flutter packages pub run flutter_oss_licenses:generate.dart
- \$\$flutter\$\$/bin/flutter packages pub run intl_utils:generate
- \$\$flutter\$\$/bin/flutter build apk --release --no-tree-shake-icons --split-per-abi
--target-platform=android-arm64 --build-number=\$\$VERCODE\$\$
scandelete:
- .pub-cache
EOF
)
echo "$FDROID_METADATA"
# Build the Play Store version
./build-play.sh
git push
git push --tags