-
Notifications
You must be signed in to change notification settings - Fork 2
/
set_version.sh
executable file
·61 lines (50 loc) · 2.28 KB
/
set_version.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
#!/bin/bash
# Run this script in the root of the embrace-flutter_sdk repo to automatically set the version and dpendencies of the 4 packages to the given value
# Depends on yq.
if ! command -v yq &> /dev/null
then
echo "Script dependency yq could not be found. Please install and add it to your PATH."
exit 1
fi
if [ $# -ne 1 ]
then
echo 'Please pass a single parameter representing the new package version'
exit 1
fi
new_version=$1
declare -r EMBRACE_PUBSPEC_PATH='embrace/pubspec.yaml'
declare -r EMBRACE_PLATFORM_INTERFACE_PUBSPEC_PATH='embrace_platform_interface/pubspec.yaml'
declare -r EMBRACE_ANDROID_PUBSPEC_PATH='embrace_android/pubspec.yaml'
declare -r EMBRACE_IOS_PUBSPEC_PATH='embrace_ios/pubspec.yaml'
declare -r EMBRACE_DIO_PUBSPEC_PATH='embrace_dio/pubspec.yaml'
declare -r EMBRACE_DEPENDENCY_NAME='.dependencies.embrace'
declare -r PLATFORM_INTERFACE_DEPENDENCY_NAME='.dependencies.embrace_platform_interface'
declare -r ANDROID_DEPENDENCY_NAME='.dependencies.embrace_android'
declare -r IOS_DEPENDENCY_NAME='.dependencies.embrace_ios'
declare -r DIO_DEPENDENCY_NAME='.dependencies.embrace_dio'
set_package_version () {
local pubspec_path=$1
yq -e ".version = \"$new_version\"" -i $pubspec_path
}
set_dependency_version () {
local pubspec_path=$1
local dependency_name=$2
yq -e "$dependency_name = \"$new_version\"" -i $pubspec_path
}
set_package_version $EMBRACE_PUBSPEC_PATH
set_package_version $EMBRACE_PLATFORM_INTERFACE_PUBSPEC_PATH
set_package_version $EMBRACE_ANDROID_PUBSPEC_PATH
set_package_version $EMBRACE_IOS_PUBSPEC_PATH
set_package_version $EMBRACE_DIO_PUBSPEC_PATH
set_dependency_version $EMBRACE_PUBSPEC_PATH $PLATFORM_INTERFACE_DEPENDENCY_NAME
set_dependency_version $EMBRACE_PUBSPEC_PATH $ANDROID_DEPENDENCY_NAME
set_dependency_version $EMBRACE_PUBSPEC_PATH $IOS_DEPENDENCY_NAME
set_dependency_version $EMBRACE_ANDROID_PUBSPEC_PATH $PLATFORM_INTERFACE_DEPENDENCY_NAME
set_dependency_version $EMBRACE_IOS_PUBSPEC_PATH $PLATFORM_INTERFACE_DEPENDENCY_NAME
set_dependency_version $EMBRACE_DIO_PUBSPEC_PATH $EMBRACE_DEPENDENCY_NAME
set_dependency_version $EMBRACE_DIO_PUBSPEC_PATH $PLATFORM_INTERFACE_DEPENDENCY_NAME
# Delete generated version script and regenerate
cd embrace_platform_interface
rm lib/src/version.dart
dart run build_runner build
cd ..