-
Notifications
You must be signed in to change notification settings - Fork 4
/
zanata-version-update
executable file
·121 lines (109 loc) · 3.12 KB
/
zanata-version-update
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
#!/bin/bash -eu
### NAME
### zanata-version-update - Update the Zanata dependencies
###
### SYNOPSIS
### zanata-version-update [Option] [<module>|<artifact>]
###
### DESCRIPTION
### This program updates pom.xml to use latest release
### of the dependencies in org.zanata
###
### ARGUMENTS
### <module>: module name like zanata-platform
###
### <artifact>: artifact like platform
###
### <branch>: branch to work on. By default it is releasing branch.
###
### OPTIONS
### -h: Show help.
###
### -B: Batch mode
### It will NOT ask question and proceed with default choice.
###
### -j: Just use current directory (no git checkout)
### This assumes that current directory is <module> work directory.
### and correct branch is checked out.
###
### -n: Allow Snapshots
###
### -p: Push after commit
### Git push when it has commit.
###
### ENVIRONMENT_VARIABLES
### EXCLUDE_PROPERTIES: A comma separated list of properties to not update.
: ${EXCLUDE_PROPERTIES:=zanata.api.compat.version}
VERSIONS_PLUGIN="org.codehaus.mojo:versions-maven-plugin:2.3"
###
shopt -s globstar
ScriptDir=$(dirname $(realpath $0))
FunctionScriptFile=${ScriptDir}/zanata-functions
source "${FunctionScriptFile}"
trap exit_print_error EXIT
ProgramName=$(basename $0)
##=== parsing Start ===
print_status -t "parse" -s "Start"
BatchMode=0
JustUseCurrentDirectoryMode=0
PushMode=0
AllowSnapshot=0
VersionGoal=use-latest-releases
declare -a ExtraOptionArray=()
while getopts "hBjnp" opt;do
case $opt in
h )
zanata_script_help $0
exit ${EXIT_OK}
;;
B )
BatchMode=1
;;
j )
JustUseCurrentDirectoryMode=1
;;
n )
AllowSnapshot=1
VersionGoal=use-next-versions
ExtraOptionArray+=(-DallowSnapshots=true)
;;
p )
PushMode=1
;;
* )
failed ${EXIT_FATAL_INVALID_OPTIONS} "$opt"
;;
esac
done
export JustUseCurrentDirectoryMode
shift $((OPTIND-1))
## Get Module
branch_prepare RELEASING "$@"
shift $ShiftOffset
print_status " Module=$Module"
##=== update Start ===
print_status -t update -s "Start"
CmdOptArray=( ${VERSIONS_PLUGIN}:update-parent ${ExtraOptionArray[@]-})
print_status " ${CmdOptArray[*]}"
mvn "${CmdOptArray[@]}"
CmdOptArray=( ${VERSIONS_PLUGIN}:$VersionGoal '-Dincludes=org.zanata:*' ${ExtraOptionArray[@]-} )
print_status " ${CmdOptArray[*]}"
mvn "${CmdOptArray[@]}"
CmdOptArray=( ${VERSIONS_PLUGIN}:update-properties '-Dincludes=org.zanata:*' '-DincludeProperties=zanata.assets.version' '-DexcludeProperties=${EXCLUDE_PROPERTIES}' ${ExtraOptionArray[@]-} )
set -x
mvn "${CmdOptArray[@]}"
set +x
if ! git diff --exit-code ;then
if [ $BatchMode -eq 0 ];then
read -p "### Are the change looks alright? Press [Ctrl-C] to break, [Enter] to continue"
fi
git commit -a -m "chore(version): Update Zanata dependencies"
if [ $PushMode -ge 1 ];then
git push
else
exit ${EXIT_RETURN_FALSE}
fi
else
print_status " No change detected"
fi
exit ${EXIT_OK}