forked from VirusTotal/yara-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-tag.sh
55 lines (42 loc) · 1.27 KB
/
update-tag.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
#!/bin/bash
set -e
if [ $# -ne 1 ]; then
echo "Usage: $0 <tag_name>"
exit 1
fi
TAG_NAME=$1
COMMITS_TO_PICK=(
"98ffd1c0d2ac92f6e0e4586af10220e2a8b6c10f"
"20fa8fa7da0fc8248182d2fbc9d0a05a359fa4f2"
)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
cleanup() {
echo "Cleaning up..."
git checkout $CURRENT_BRANCH
git branch -D temp_branch_$TAG_NAME 2>/dev/null || true
}
trap cleanup EXIT
echo "Starting tag update process for $TAG_NAME..."
echo "Creating temporary branch from tag..."
git checkout $TAG_NAME
git checkout -b temp_branch_$TAG_NAME
echo "Cherry-picking commits..."
for commit in "${COMMITS_TO_PICK[@]}"; do
if ! git cherry-pick $commit; then
(
# Resolve conflicts (we get conflicts because we deleted github actions and they change sometimes)
# '-c core.editor=true' is used to avoid opening editor to write commit message
git rm -r .github/* && git -c core.editor=true cherry-pick --continue
) || (
echo "Failed to cherry-pick commit $commit" && exit 1
)
fi
done
echo "Updating tag..."
git tag -d $TAG_NAME
git tag $TAG_NAME
git push origin :refs/tags/$TAG_NAME
git push origin $TAG_NAME
echo "Reverting changes..."
cleanup
echo "Process completed successfully!"