forked from openclaw/openclaw
-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (236 loc) · 8.76 KB
/
release.yml
File metadata and controls
277 lines (236 loc) · 8.76 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
name: Release
on:
push:
tags:
- "v*.daydreams.*"
workflow_dispatch:
inputs:
tag:
description: "Tag to release (must already exist, e.g. v2026.2.17.daydreams.1)"
required: true
type: string
permissions: {}
concurrency:
group: release-${{ github.workflow }}-${{ inputs.tag || github.ref_name }}
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Resolve and validate tag
id: tag
run: |
set -euo pipefail
if [[ -n "${{ inputs.tag }}" ]]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
if [[ ! "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+\.daydreams\.[0-9]+$ ]]; then
echo "::error::Invalid tag format: ${TAG}"
echo "Expected: v<major>.<minor>.<patch>.daydreams.<n>"
exit 1
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
- name: Verify tag exists on remote
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
git ls-remote --exit-code --tags "https://github.com/${{ github.repository }}.git" "refs/tags/${TAG}" >/dev/null
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ steps.tag.outputs.tag }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "22"
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Pack tarball
id: pack
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
TARBALL="openclaw-${TAG}.tgz"
rm -f openclaw-*.tgz
pnpm pack --pack-destination .
mapfile -t PACKED_FILES < <(find . -maxdepth 1 -type f -name "openclaw-*.tgz" -printf "%f\n")
if [[ "${#PACKED_FILES[@]}" -ne 1 ]]; then
echo "::error::Expected exactly 1 tarball, found ${#PACKED_FILES[@]}"
ls -la openclaw-*.tgz 2>/dev/null || true
exit 1
fi
PACKED="${PACKED_FILES[0]}"
if [[ "$PACKED" != "$TARBALL" ]]; then
mv "$PACKED" "$TARBALL"
fi
echo "tarball=${TARBALL}" >> "$GITHUB_OUTPUT"
echo "Packed: ${TARBALL} ($(du -h "$TARBALL" | cut -f1))"
- name: Generate changelog
id: changelog
env:
TAG: ${{ steps.tag.outputs.tag }}
run: |
set -euo pipefail
PREV_TAG="$(git tag --list "v*.daydreams.*" --sort=-version:refname | grep -v "^${TAG}$" | head -1 || true)"
if [[ -z "$PREV_TAG" ]]; then
echo "No previous daydreams tag found; using full log."
PREV_TAG="$(git rev-list --max-parents=0 HEAD | head -1)"
fi
echo "Previous tag: ${PREV_TAG}"
echo "prev_tag=${PREV_TAG}" >> "$GITHUB_OUTPUT"
CHANGE_LINES="$(
git log "${PREV_TAG}..${TAG}" --oneline --no-merges --pretty=format:"%s" \
| sed "/^style:/d" \
| sed "/^chore: mark pending upstream sync/d" \
| awk 'NR<=50 { print "- " $0 }'
)"
if [[ -z "$CHANGE_LINES" ]]; then
CHANGE_LINES="- No notable changes"
fi
{
echo "body<<EOF"
echo "## Changes since ${PREV_TAG}"
echo ""
echo "$CHANGE_LINES"
echo ""
echo ""
echo "## Install"
echo ""
echo '```bash'
echo 'curl -fsSL https://raw.githubusercontent.com/daydreamsai/dreaming-claw/main/scripts/install-openclaw-fork.sh | bash'
echo '```'
echo ""
echo "**Full diff:** [\`${PREV_TAG}...${TAG}\`](https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${TAG})"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.tag.outputs.tag }}
TARBALL: ${{ steps.pack.outputs.tarball }}
BODY: ${{ steps.changelog.outputs.body }}
run: |
set -euo pipefail
if gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then
echo "Release $TAG already exists; updating."
gh release edit "$TAG" \
--repo "${{ github.repository }}" \
--title "x402-claw ${TAG}" \
--notes "$BODY"
gh release upload "$TAG" "$TARBALL" \
--repo "${{ github.repository }}" \
--clobber
else
gh release create "$TAG" "$TARBALL" \
--repo "${{ github.repository }}" \
--title "x402-claw ${TAG}" \
--notes "$BODY"
fi
update-installer:
needs: release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout main
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: main
- name: Determine installer change
id: update
env:
TAG: ${{ needs.release.outputs.tag }}
run: |
set -euo pipefail
FILE="scripts/install-openclaw-fork.sh"
CURRENT="$(grep -oP 'OPENCLAW_REF="\K[^"]+' "$FILE" | tail -1)"
if [[ "$CURRENT" == "$TAG" ]]; then
echo "Installer already points to ${TAG}; skipping."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "previous=${CURRENT}" >> "$GITHUB_OUTPUT"
- name: Create or update PR for installer
if: steps.update.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.release.outputs.tag }}
PREVIOUS: ${{ steps.update.outputs.previous }}
run: |
set -euo pipefail
BRANCH="release/update-installer-${TAG}"
FILE="scripts/install-openclaw-fork.sh"
HEAD_REF="${{ github.repository_owner }}:${BRANCH}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
BRANCH_EXISTS=0
if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
BRANCH_EXISTS=1
git fetch origin "$BRANCH":"$BRANCH"
git checkout "$BRANCH"
else
git checkout -b "$BRANCH"
fi
CURRENT_BRANCH_REF="$(grep -oP 'OPENCLAW_REF="\K[^"]+' "$FILE" | tail -1)"
if [[ "$CURRENT_BRANCH_REF" != "$TAG" ]]; then
sed -i "s|OPENCLAW_REF=\"${CURRENT_BRANCH_REF}\"|OPENCLAW_REF=\"${TAG}\"|" "$FILE"
fi
git add "$FILE"
if ! git diff --cached --quiet; then
git commit -m "chore: update installer default ref to ${TAG}"
if [[ "$BRANCH_EXISTS" == "1" ]]; then
git push origin "$BRANCH"
else
git push -u origin "$BRANCH"
fi
else
echo "No installer commit needed on ${BRANCH}."
fi
PR_BODY="$(cat <<EOF
Automated update from the release workflow.
| | |
|---|---|
| **Previous** | \`${PREVIOUS}\` |
| **New** | \`${TAG}\` |
| **Release** | [${TAG}](https://github.com/${{ github.repository }}/releases/tag/${TAG}) |
Merge this to make \`curl | bash\` installs use the new release.
---
This PR was created by \`.github/workflows/release.yml\`.
EOF
)"
EXISTING_PR="$(gh pr list \
--repo "${{ github.repository }}" \
--base main \
--head "$HEAD_REF" \
--state open \
--json number \
--jq '.[0].number // empty')"
if [[ -n "$EXISTING_PR" ]]; then
gh pr edit "$EXISTING_PR" \
--repo "${{ github.repository }}" \
--title "chore: update installer default ref to ${TAG}" \
--body "$PR_BODY"
echo "Updated existing PR #${EXISTING_PR}"
else
gh pr create \
--repo "${{ github.repository }}" \
--base main \
--head "$HEAD_REF" \
--title "chore: update installer default ref to ${TAG}" \
--body "$PR_BODY"
fi