-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagMe
28 lines (27 loc) · 986 Bytes
/
tagMe
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
#!/bin/bash -vx
TAG=$1
if [ "$TAG" != "" ] ; then
# Determine files in which to update the version
FILES=( .github/workflows/pre-commit.yml )
if [[ "$TAG" =~ "20"* ]] ; then
FILES+=( README.md )
fi
# Update the version and tag
perl -i -p -e 's/(?<=logToCheckStyle\@).*/'"$TAG"'/' "${FILES[@]}" \
&& git add "${FILES[@]}" \
&& git commit --no-verify --fixup HEAD \
&& git rebase --no-verify -i --autosquash HEAD~2
grep "$TAG" README.md \
&& git tag -f "$TAG" \
&& git push --atomic origin main "$TAG" -f
# Update the test case
sourceBranch=$(git symbolic-ref HEAD | cut -d "/" -f 3-);
targetBranch="test_branch";
git checkout $targetBranch \
&& git pull \
&& perl -i -p -e 's/(?<=logToCheckStyle\@).*/'"$TAG"'/' "${FILES[@]}" \
&& ( git commit -a -m "Update version" --no-verify || [ 1 = 1 ] ) \
&& git rebase --onto $sourceBranch \
&& git push -f \
&& git checkout $sourceBranch
fi