Skip to content

Commit ff664a5

Browse files
committed
Add sync_and_release.sh for one-command upstream sync and deploy
Fetches upstream, fast-forwards master, merges to build, creates tag, and pushes everything with confirmation prompt.
1 parent 4d7371b commit ff664a5

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

sync_and_release.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Ensure clean working tree
5+
if [ -n "$(git status --porcelain)" ]; then
6+
echo "Error: Working tree is not clean. Commit or stash changes first."
7+
exit 1
8+
fi
9+
10+
# Ensure merge=ours driver is configured (needed for README.md)
11+
git config merge.ours.driver true
12+
13+
# 1. Fetch upstream
14+
echo "==> Fetching upstream..."
15+
git fetch upstream
16+
17+
# 2. Fast-forward master to upstream/master
18+
echo "==> Updating master..."
19+
git checkout master
20+
git merge --ff-only upstream/master
21+
22+
# 3. Merge master into build (README auto-resolved via merge=ours)
23+
echo "==> Merging master into build..."
24+
git checkout build
25+
git merge master
26+
27+
# 4. Create tag from version in CMakeLists.txt
28+
echo "==> Creating tag..."
29+
./add_git_tag.sh
30+
31+
# Extract version for push
32+
VERSION=$(awk '/project\(TDLib VERSION/ {print $3}' CMakeLists.txt | tr -d '[:space:]()')
33+
34+
# 5. Summary
35+
echo ""
36+
echo "========================================="
37+
echo " Ready to push"
38+
echo "========================================="
39+
echo " master → origin/master"
40+
echo " build → origin/build"
41+
echo " tag → ${VERSION}"
42+
echo "========================================="
43+
echo ""
44+
read -p "Push all? [y/N] " -n 1 -r
45+
echo ""
46+
47+
if [[ $REPLY =~ ^[Yy]$ ]]; then
48+
git push origin master build "${VERSION}"
49+
echo ""
50+
echo "Done! CI/CD will build and release ${VERSION}."
51+
else
52+
echo "Aborted. You can push manually:"
53+
echo " git push origin master build ${VERSION}"
54+
fi

0 commit comments

Comments
 (0)