|
| 1 | +name: Check for new OpenClaw release |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 */12 * * *' # Every 12 hours (midnight and noon UTC) |
| 6 | + workflow_dispatch: {} |
| 7 | + |
| 8 | +jobs: |
| 9 | + check: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + with: |
| 14 | + sparse-checkout: kiloclaw/Dockerfile |
| 15 | + sparse-checkout-cone-mode: false |
| 16 | + |
| 17 | + - name: Get current pinned version |
| 18 | + id: current |
| 19 | + run: | |
| 20 | + version=$(grep -oP 'openclaw@\K[0-9]+\.[0-9]+\.[0-9]+' kiloclaw/Dockerfile || true) |
| 21 | + if [ -z "$version" ]; then |
| 22 | + echo "::error::Failed to extract openclaw version from kiloclaw/Dockerfile" |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 26 | + echo "Current pinned version: $version" |
| 27 | +
|
| 28 | + - name: Get latest stable release tag |
| 29 | + id: latest |
| 30 | + env: |
| 31 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + run: | |
| 33 | + version=$( |
| 34 | + gh api repos/openclaw/openclaw/git/refs/tags \ |
| 35 | + --paginate --jq '.[].ref' \ |
| 36 | + | sed 's|refs/tags/v||' \ |
| 37 | + | grep -vE '-' \ |
| 38 | + | sort -V \ |
| 39 | + | tail -1 |
| 40 | + ) |
| 41 | + if [ -z "$version" ]; then |
| 42 | + echo "::error::Failed to find any stable openclaw release tags" |
| 43 | + exit 1 |
| 44 | + fi |
| 45 | + # Validate the version looks like a version number (no shell metacharacters) |
| 46 | + if ! echo "$version" | grep -qP '^[0-9]+\.[0-9]+\.[0-9]+$'; then |
| 47 | + echo "::error::Latest tag does not look like a valid version: $version" |
| 48 | + exit 1 |
| 49 | + fi |
| 50 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 51 | + echo "Latest stable release: $version" |
| 52 | +
|
| 53 | + - name: Check if release is less than 24 hours old |
| 54 | + id: age |
| 55 | + if: steps.latest.outputs.version != steps.current.outputs.version |
| 56 | + env: |
| 57 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + LATEST_VERSION: ${{ steps.latest.outputs.version }} |
| 59 | + run: | |
| 60 | + tag_date=$( |
| 61 | + gh api "repos/openclaw/openclaw/git/refs/tags/v${LATEST_VERSION}" \ |
| 62 | + --jq '.object.url' \ |
| 63 | + | xargs gh api --jq '.tagger.date // .author.date' |
| 64 | + ) |
| 65 | + if [ -z "$tag_date" ]; then |
| 66 | + echo "::error::Failed to retrieve tag date for v${LATEST_VERSION}" |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + tag_epoch=$(date -d "$tag_date" +%s) |
| 70 | + now_epoch=$(date +%s) |
| 71 | + age_hours=$(( (now_epoch - tag_epoch) / 3600 )) |
| 72 | + echo "Tag created $age_hours hours ago ($tag_date)" |
| 73 | + if [ "$age_hours" -lt 24 ]; then |
| 74 | + echo "recent=true" >> "$GITHUB_OUTPUT" |
| 75 | + else |
| 76 | + echo "recent=false" >> "$GITHUB_OUTPUT" |
| 77 | + echo "Skipping — release is older than 24 hours" |
| 78 | + fi |
| 79 | +
|
| 80 | + - name: Notify webhook of new release |
| 81 | + if: steps.age.outputs.recent == 'true' |
| 82 | + continue-on-error: true |
| 83 | + env: |
| 84 | + WEBHOOK_SECRET: ${{ secrets.KILOCLAW_GITHUB_WEBHOOK_TRIGGER_TOKEN }} |
| 85 | + WEBHOOK_URL: ${{ secrets.OPENCLAW_BUMP_WEBHOOK_URL }} |
| 86 | + NEW_VERSION: ${{ steps.latest.outputs.version }} |
| 87 | + CURRENT_VERSION: ${{ steps.current.outputs.version }} |
| 88 | + run: | |
| 89 | + echo "New openclaw version available: $NEW_VERSION (current: $CURRENT_VERSION)" |
| 90 | + curl -sf -o /dev/null -X POST \ |
| 91 | + -H "Content-Type: application/json" \ |
| 92 | + -H "x-webhook-secret: $WEBHOOK_SECRET" \ |
| 93 | + -d "{\"new_openclaw_version\": \"$NEW_VERSION\"}" \ |
| 94 | + "$WEBHOOK_URL" |
| 95 | +
|
| 96 | + - name: Notify Slack |
| 97 | + if: steps.age.outputs.recent == 'true' |
| 98 | + continue-on-error: true |
| 99 | + uses: slackapi/slack-github-action@v2 |
| 100 | + env: |
| 101 | + CURRENT_VERSION: ${{ steps.current.outputs.version }} |
| 102 | + NEW_VERSION: ${{ steps.latest.outputs.version }} |
| 103 | + with: |
| 104 | + webhook: ${{ secrets.DEPLOY_NOTIFY_SLACK_WEBHOOK_URL }} |
| 105 | + webhook-type: incoming-webhook |
| 106 | + payload: | |
| 107 | + { |
| 108 | + "blocks": [ |
| 109 | + { |
| 110 | + "type": "header", |
| 111 | + "text": { |
| 112 | + "type": "plain_text", |
| 113 | + "text": "New OpenClaw Release Available" |
| 114 | + } |
| 115 | + }, |
| 116 | + { |
| 117 | + "type": "section", |
| 118 | + "fields": [ |
| 119 | + { |
| 120 | + "type": "mrkdwn", |
| 121 | + "text": "*Current Version:*\n${{ env.CURRENT_VERSION }}" |
| 122 | + }, |
| 123 | + { |
| 124 | + "type": "mrkdwn", |
| 125 | + "text": "*New Version:*\n${{ env.NEW_VERSION }}" |
| 126 | + } |
| 127 | + ] |
| 128 | + }, |
| 129 | + { |
| 130 | + "type": "section", |
| 131 | + "text": { |
| 132 | + "type": "mrkdwn", |
| 133 | + "text": "<https://github.com/openclaw/openclaw/releases/tag/v${{ env.NEW_VERSION }}|View release notes>" |
| 134 | + } |
| 135 | + } |
| 136 | + ] |
| 137 | + } |
0 commit comments