-
Notifications
You must be signed in to change notification settings - Fork 24
137 lines (130 loc) · 4.89 KB
/
bump-openclaw.yml
File metadata and controls
137 lines (130 loc) · 4.89 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
name: Check for new OpenClaw release
on:
schedule:
- cron: '0 */12 * * *' # Every 12 hours (midnight and noon UTC)
workflow_dispatch: {}
jobs:
check:
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
steps:
- uses: useblacksmith/checkout@v1
with:
sparse-checkout: kiloclaw/Dockerfile
sparse-checkout-cone-mode: false
- name: Get current pinned version
id: current
run: |
version=$(grep -oP 'openclaw@\K[0-9]+\.[0-9]+\.[0-9]+' kiloclaw/Dockerfile || true)
if [ -z "$version" ]; then
echo "::error::Failed to extract openclaw version from kiloclaw/Dockerfile"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Current pinned version: $version"
- name: Get latest stable release tag
id: latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(
gh api repos/openclaw/openclaw/git/refs/tags \
--paginate --jq '.[].ref' \
| sed 's|refs/tags/v||' \
| grep -vE '-' \
| sort -V \
| tail -1
)
if [ -z "$version" ]; then
echo "::error::Failed to find any stable openclaw release tags"
exit 1
fi
# Validate the version looks like a version number (no shell metacharacters)
if ! echo "$version" | grep -qP '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Latest tag does not look like a valid version: $version"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "Latest stable release: $version"
- name: Check if release is less than 24 hours old
id: age
if: steps.latest.outputs.version != steps.current.outputs.version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LATEST_VERSION: ${{ steps.latest.outputs.version }}
run: |
tag_date=$(
gh api "repos/openclaw/openclaw/git/refs/tags/v${LATEST_VERSION}" \
--jq '.object.url' \
| xargs gh api --jq '.tagger.date // .author.date'
)
if [ -z "$tag_date" ]; then
echo "::error::Failed to retrieve tag date for v${LATEST_VERSION}"
exit 1
fi
tag_epoch=$(date -d "$tag_date" +%s)
now_epoch=$(date +%s)
age_hours=$(( (now_epoch - tag_epoch) / 3600 ))
echo "Tag created $age_hours hours ago ($tag_date)"
if [ "$age_hours" -lt 24 ]; then
echo "recent=true" >> "$GITHUB_OUTPUT"
else
echo "recent=false" >> "$GITHUB_OUTPUT"
echo "Skipping — release is older than 24 hours"
fi
- name: Notify webhook of new release
if: steps.age.outputs.recent == 'true'
continue-on-error: true
env:
WEBHOOK_SECRET: ${{ secrets.KILOCLAW_GITHUB_WEBHOOK_TRIGGER_TOKEN }}
WEBHOOK_URL: ${{ secrets.OPENCLAW_BUMP_WEBHOOK_URL }}
NEW_VERSION: ${{ steps.latest.outputs.version }}
CURRENT_VERSION: ${{ steps.current.outputs.version }}
run: |
echo "New openclaw version available: $NEW_VERSION (current: $CURRENT_VERSION)"
curl -sf -o /dev/null -X POST \
-H "Content-Type: application/json" \
-H "x-webhook-secret: $WEBHOOK_SECRET" \
-d "{\"new_openclaw_version\": \"$NEW_VERSION\"}" \
"$WEBHOOK_URL"
- name: Notify Slack
if: steps.age.outputs.recent == 'true'
continue-on-error: true
uses: slackapi/slack-github-action@v2
env:
CURRENT_VERSION: ${{ steps.current.outputs.version }}
NEW_VERSION: ${{ steps.latest.outputs.version }}
with:
webhook: ${{ secrets.DEPLOY_NOTIFY_SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New OpenClaw Release Available"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Current Version:*\n${{ env.CURRENT_VERSION }}"
},
{
"type": "mrkdwn",
"text": "*New Version:*\n${{ env.NEW_VERSION }}"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<https://github.com/openclaw/openclaw/releases/tag/v${{ env.NEW_VERSION }}|View release notes>"
}
}
]
}