Skip to content

Commit a3d226c

Browse files
committed
Add script and docs for updating glean_parser version
1 parent 054476e commit a3d226c

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

bin/update-glean-parser-version.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This Source Code Form is subject to the terms of the Mozilla Public
4+
# License, v. 2.0. If a copy of the MPL was not distributed with this
5+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
7+
# Update the glean_parser version
8+
9+
set -eo pipefail
10+
11+
run() {
12+
[ "${VERB:-0}" != 0 ] && echo "+ $*"
13+
"$@"
14+
}
15+
16+
# All sed commands below work with either
17+
# GNU sed (standard on Linux distrubtions) or BSD sed (standard on macOS)
18+
SED="sed"
19+
20+
WORKSPACE_ROOT="$( cd "$(dirname "$0")/.." ; pwd -P )"
21+
22+
if [ -z "$1" ]; then
23+
echo "Usage: $(basename "$0") <new version>"
24+
echo
25+
echo "Update the glean_parser version"
26+
exit 1
27+
fi
28+
29+
NEW_VERSION="$1"
30+
31+
# GIT_STATUS_OUTPUT=$(git status --untracked-files=no --porcelain)
32+
# if [ -z "$ALLOW_DIRTY" ] && [ -n "${GIT_STATUS_OUTPUT}" ]; then
33+
# lines=$(echo "$GIT_STATUS_OUTPUT" | wc -l | tr -d '[:space:]')
34+
# echo "error: ${lines} files in the working directory contain changes that were not yet committed into git:"
35+
# echo
36+
# echo "${GIT_STATUS_OUTPUT}"
37+
# echo
38+
# exit 1
39+
# fi
40+
41+
# Update the version in glean/src/cli.ts
42+
FILE=glean/src/cli.ts
43+
run $SED -i.bak -E \
44+
-e "s/const GLEAN_PARSER_VERSION = \"[0-9.]+\"/const GLEAN_PARSER_VERSION = \"${NEW_VERSION}\"/" \
45+
"${WORKSPACE_ROOT}/${FILE}"
46+
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
47+
48+
# Update the version in samples/qt-qml-app/requirements.txt
49+
FILE=samples/qt-qml-app/requirements.txt
50+
run $SED -i.bak -E \
51+
-e "s/glean_parser==[0-9.]+/glean_parser==${NEW_VERSION}/" \
52+
"${WORKSPACE_ROOT}/${FILE}"
53+
run rm "${WORKSPACE_ROOT}/${FILE}.bak"
54+
55+
echo "glean_parser updated to v${NEW_VERSION}"
56+
echo
57+
echo "Changed files:"
58+
git status --untracked-files=no --porcelain || true
59+
echo
60+
echo "Create update commit v${NEW_VERSION} now? [y/N]"
61+
read -r RESP
62+
echo
63+
if [ "$RESP" != "y" ] && [ "$RESP" != "Y" ]; then
64+
echo "No new commit. No new tag. Proceed manually."
65+
exit 0
66+
fi
67+
68+
run git add --update "${WORKSPACE_ROOT}"
69+
run git commit --message "Bumped glean_parser version to ${NEW_VERSION}"
70+
71+
if git remote | grep -q upstream; then
72+
remote=upstream
73+
else
74+
remote=origin
75+
fi
76+
branch=$(git rev-parse --abbrev-ref HEAD)
77+
78+
echo "Don't forget to push this commit:"
79+
echo
80+
echo " git push $remote $branch"
81+

docs/update_glean_parser.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Updating the glean_parser version
2+
3+
To update the version of glean_parser used by the Glean.js, run the `bin/update-glean-parser-version.sh` script, providing the version as a command line parameter:
4+
5+
```bash
6+
bin/update-glean-parser-version.sh 1.28.3
7+
```
8+
9+
This will update the version in all the required places and create a commit with the changes. After that you just need to create a pull request with the changes.
10+
11+
No further action is required.

0 commit comments

Comments
 (0)