forked from openclaw/openclaw
-
-
Notifications
You must be signed in to change notification settings - Fork 39
203 lines (167 loc) Β· 6.77 KB
/
sync-upstream.yml
File metadata and controls
203 lines (167 loc) Β· 6.77 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Sync Upstream
on:
schedule:
- cron: '0 */1 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ secrets.PAT || github.token }}
- name: Sync upstream into main
run: |
git config --global user.name 'friuns2'
git config --global user.email 'soulkey4@gmail.com'
git remote add upstream https://github.com/openclaw/openclaw.git
git fetch upstream
git checkout main
git pull origin main --rebase
# Mirror upstream to a tracking branch
git checkout -B upstream upstream/main
git push origin upstream --force
# Back to main and merge
git checkout main
git merge upstream/main --no-commit --no-ff --allow-unrelated-histories || true
# Save our docs/ before upstream overwrite
if [ -d docs ]; then
cp -r docs /tmp/our-docs-backup
fi
# Remove upstream workflow files β keep only ours
if ls .github/workflows/*.yml 1> /dev/null 2>&1; then
ls .github/workflows/*.yml \
| grep -v 'build-apk.yml\|sync-upstream.yml' \
| xargs -I {} git rm -f {} 2>/dev/null || true
fi
# Remove upstream docs
git rm -rf docs/ 2>/dev/null || true
# Restore our docs/
if [ -d /tmp/our-docs-backup ]; then
cp -r /tmp/our-docs-backup docs
git add docs/
fi
# Resolve conflicts
if git ls-files -u | grep -q "^"; then
echo "Conflicts detected. Resolving..."
OUR_PATTERNS="README.md AGENTS.md PROJECT_SPEC.md app-ads.txt"
OUR_DIRS="android/ .github/workflows/ docs/ documentation/ screenshots/ openclaw-android/ .agents/skills/codex-app-parity/"
for pattern in $OUR_PATTERNS; do
if git ls-files -u | grep -q "$pattern"; then
echo " --ours: $pattern"
git checkout --ours "$pattern" 2>/dev/null && git add "$pattern"
fi
done
for dir in $OUR_DIRS; do
DIR_CONFLICTS=$(git ls-files -u | awk '{print $4}' | sort -u | grep "^${dir}" || true)
if [ -n "$DIR_CONFLICTS" ]; then
IFS=$'\n'
for file in $DIR_CONFLICTS; do
echo " --ours: $file"
git checkout --ours "$file" 2>/dev/null && git add "$file"
done
unset IFS
fi
done
REMAINING=$(git ls-files -u | awk '{print $4}' | sort -u)
if [ -n "$REMAINING" ]; then
IFS=$'\n'
for file in $REMAINING; do
echo " --theirs: $file"
git checkout --theirs "$file" 2>/dev/null && git add "$file"
done
unset IFS
fi
fi
if git diff --cached --quiet; then
echo "Already up to date."
else
git commit -m "Auto-merge upstream openclaw/openclaw"
git push origin main
fi
- name: Update release notes in landing page
run: |
git checkout main
git pull origin main --rebase
python3 << 'PYEOF'
import json, re, html, urllib.request, sys
from datetime import datetime
resp = urllib.request.urlopen("https://api.github.com/repos/openclaw/openclaw/releases/latest")
rel = json.loads(resp.read())
name = rel.get("name", "")
published = rel.get("published_at", "")[:10]
body = rel.get("body", "")
try:
dt = datetime.strptime(published, "%Y-%m-%d")
date_str = dt.strftime("%b %d, %Y")
except Exception:
date_str = published
body = body.replace("\r\n", "\n").replace("\r", "\n")
lines = body.split("\n")
out = []
bullet_count = 0
in_section = False
for line in lines:
hm = re.match(r"^###\s+(.*)", line)
if hm:
heading = hm.group(1).strip()
if heading in ("Breaking", "Changes", "Fixes"):
if in_section:
out.append("</ul>")
in_section = True
out.append(f"<h3>{html.escape(heading)}</h3>")
out.append("<ul>")
continue
elif heading == "Contributors":
break
else:
continue
bm = re.match(r"^[-*]\s+(.*)", line)
if bm and in_section and bullet_count < 60:
item = bm.group(1).strip()
item = re.sub(r"\(#\d+\)", "", item)
item = re.sub(r"[Tt]hanks @\S+\.?", "", item)
item = re.sub(r"\s+", " ", item).strip().rstrip(".")
if item:
out.append(f"<li>{html.escape(item)}</li>")
bullet_count += 1
if in_section:
out.append("</ul>")
if not out:
print("No release body parsed, skipping.")
sys.exit(0)
body_html = "\n ".join(out)
block = f"""<!-- RELEASE_START -->
<h2><em>{html.escape(name)}</em></h2>
<p class="release-date" style="font-family:var(--mono);font-size:.8rem;color:var(--text-dim);margin-bottom:2rem">Released {date_str}</p>
<div class="release-body" style="color:var(--text-dim);font-size:.92rem;line-height:1.75;max-width:800px">
{body_html}
</div>
<!-- RELEASE_END -->"""
with open("docs/index.html", "r") as f:
content = f.read()
start = content.find("<!-- RELEASE_START -->")
end = content.find("<!-- RELEASE_END -->")
if start == -1 or end == -1:
print("Release markers not found.")
sys.exit(0)
end += len("<!-- RELEASE_END -->")
content = content[:start] + block + content[end:]
with open("docs/index.html", "w") as f:
f.write(content)
print(f"Updated docs/index.html with {name} ({date_str})")
PYEOF
git config --global user.name 'friuns2'
git config --global user.email 'soulkey4@gmail.com'
git add docs/index.html
if git diff --cached --quiet; then
echo "Release notes already up to date."
else
git commit -m "Update landing page with latest openclaw release notes"
git push origin main
fi