@@ -14,13 +14,46 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
14
14
exit 0
15
15
fi
16
16
17
- # Check the arguments are valid
18
- if [ $# -gt 2 ] || ([ $# -eq 1 ] && [ " $1 " != " --override-release " ] && [ " $1 " != " --dry-run " ]) || ([ $# -eq 2 ] && [ " $1 " != " --override-release " ] && [ " $1 " != " --dry-run " ] && [ " $2 " != " --override-release " ] && [ " $2 " != " --dry-run " ]) ; then
17
+ # Check the number of arguments are valid
18
+ if [ $# -gt 2 ]; then
19
19
echo " Error: Invalid arguments provided"
20
20
echo " $help "
21
21
exit 1
22
22
fi
23
23
24
+ OVERRIDE_RELEASE=0
25
+ DRY_RUN=0
26
+ for arg in " $@ "
27
+ do
28
+ case $arg in
29
+ --override-release)
30
+ OVERRIDE_RELEASE=1
31
+ shift # Remove --override-release from processing
32
+ ;;
33
+ --dry-run)
34
+ DRY_RUN=1
35
+ shift # Remove --dry-run from processing
36
+ ;;
37
+ * )
38
+ echo " Error: Invalid argument provided: $arg "
39
+ echo " $help "
40
+ exit 1
41
+ ;;
42
+ esac
43
+ done
44
+
45
+ # Describe what we're about to do based on the command-line arguments
46
+ if [ $OVERRIDE_RELEASE = 1 ]; then
47
+ echo " Publishing the current HEAD of the automodel repo"
48
+ else
49
+ echo " Publishing the version of the automodel repo specified by the latest official release of the codeml-automodel repo"
50
+ fi
51
+ if [ $DRY_RUN = 1 ]; then
52
+ echo " Dry run: we will step through the process but we won't publish the query pack"
53
+ else
54
+ echo " Not a dry run! Publishing the query pack"
55
+ fi
56
+
24
57
# If we're publishing the codeml-automodel release then we will checkout the sha specified in the release.
25
58
# So we need to check that there are no uncommitted changes in the local branch.
26
59
# And, if we're publishing the current HEAD, it's cleaner to ensure that there are no uncommitted changes.
55
88
CURRENT_BRANCH=$( git rev-parse --abbrev-ref HEAD)
56
89
CURRENT_SHA=$( git rev-parse HEAD)
57
90
58
- if [ " $1 " = " --override-release " ] || [ " $2 " = " --override-release " ]; then
91
+ if [ $OVERRIDE_RELEASE = 1 ]; then
59
92
# Check that the current HEAD is downstream from PREVIOUS_RELEASE_SHA
60
93
if ! git merge-base --is-ancestor " $PREVIOUS_RELEASE_SHA " " $CURRENT_SHA " ; then
61
94
echo " Error: The current HEAD is not downstream from the previous release"
@@ -103,7 +136,7 @@ pushd "$WORKSPACE_ROOT"
103
136
echo " Preparing the release"
104
137
" ${CODEQL_DIST} /codeql" pack release --groups $GRPS -v
105
138
106
- if [ " $1 " = " --dry-run " ] || [ " $2 " = " --dry-run " ]; then
139
+ if [ $DRY_RUN = 1 ]; then
107
140
echo " Dry run: not publishing the query pack"
108
141
" ${CODEQL_DIST} /codeql" pack publish --groups $GRPS --dry-run -v
109
142
else
@@ -132,12 +165,12 @@ mv ./src/qlpack.yml ./src/qlpack.yml.dry-run
132
165
mv " $NEW_CHANGE_NOTES_FILE " ./src/change-notes/released.md.dry-run
133
166
134
167
# If --override-release was not specified, then we need to checkout the original branch
135
- if [ " $1 " != " --override-release " ] && [ " $2 " != " --override-release " ]; then
168
+ if [ $OVERRIDE_RELEASE != 1 ]; then
136
169
echo " Checking out the original branch"
137
170
git checkout " $CURRENT_BRANCH " --force
138
171
fi
139
172
140
- if [ " $1 " = " --dry-run " ] || [ " $2 " = " --dry-run " ]; then
173
+ if [ $DRY_RUN = 1 ]; then
141
174
echo " Inspect the updated dry-run version files:"
142
175
ls -l ./src/* .dry-run
143
176
ls -l ./src/change-notes/* .dry-run
0 commit comments