-
Notifications
You must be signed in to change notification settings - Fork 1
421 lines (341 loc) · 14.9 KB
/
release.yml
File metadata and controls
421 lines (341 loc) · 14.9 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# ==============================================================================
# RELEASE WORKFLOW — Tag + GitHub Release pipeline
#
# Trigger: workflow_dispatch with version input
# Steps:
# 1. Pre-flight: Validate version, check CI status, verify version in files
# 2. Git Tag: vX.Y.Z on HEAD → triggers ci-cd.yml → Docker Multi-Arch Build
# 3. GitHub Release: Auto-generated changelog + Docker instructions
# 4. Trigger: build-raspi-image.yml for arm64 + armhf
#
# NOTE: Version bumps in package.json / pyproject.toml / CHANGELOG.md must be
# done in the PR BEFORE merging to main. This workflow does NOT push
# commits — it only creates a tag + release on the current HEAD.
# This is required because branch protection blocks direct pushes to main.
# ==============================================================================
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.0 — without v prefix)'
required: true
type: string
prerelease:
description: 'Mark as pre-release (beta/rc)'
required: false
type: boolean
default: false
skip_raspi:
description: 'Skip Raspberry Pi image builds'
required: false
type: boolean
default: false
jobs:
# ============================================================================
# PRE-FLIGHT CHECKS
# ============================================================================
preflight:
name: Pre-flight Checks
runs-on: ubuntu-latest
steps:
- name: Validate version format
run: |
VERSION="${{ inputs.version }}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "::error::Invalid version format: $VERSION"
echo "Expected: X.Y.Z or X.Y.Z-beta.1 (e.g., 1.0.0, 2.1.0-rc.1)"
exit 1
fi
echo "✅ Valid version: $VERSION"
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check tag does not exist
run: |
TAG="v${{ inputs.version }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "::error::Tag $TAG already exists! Delete first: git push --delete origin $TAG && git tag -d $TAG"
exit 1
fi
echo "✅ Tag $TAG is available"
- name: Verify version in package files
run: |
VERSION="${{ inputs.version }}"
echo "🔍 Checking that version $VERSION is present in all package files..."
ERRORS=0
ROOT_VER=$(grep '"version"' package.json | head -1 | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^"]*')
if [ "$ROOT_VER" != "$VERSION" ]; then
echo "::error::package.json version is '$ROOT_VER', expected '$VERSION'"
ERRORS=$((ERRORS + 1))
else
echo " ✅ package.json → $ROOT_VER"
fi
BACKEND_VER=$(grep '^version' apps/backend/pyproject.toml | head -1 | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^"]*')
if [ "$BACKEND_VER" != "$VERSION" ]; then
echo "::error::pyproject.toml version is '$BACKEND_VER', expected '$VERSION'"
ERRORS=$((ERRORS + 1))
else
echo " ✅ apps/backend/pyproject.toml → $BACKEND_VER"
fi
FRONTEND_VER=$(grep '"version"' apps/frontend/package.json | head -1 | grep -o '[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^"]*')
if [ "$FRONTEND_VER" != "$VERSION" ]; then
echo "::error::frontend/package.json version is '$FRONTEND_VER', expected '$VERSION'"
ERRORS=$((ERRORS + 1))
else
echo " ✅ apps/frontend/package.json → $FRONTEND_VER"
fi
if [ "$ERRORS" -gt 0 ]; then
echo ""
echo "::error::Version mismatch! Bump versions in a PR before running the release workflow."
exit 1
fi
echo "✅ All package files match version $VERSION"
- name: Check latest CI status on main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Checking CI/CD status on main..."
LAST_RUN=$(gh run list --workflow=ci-cd.yml --branch=main --limit=1 \
--json conclusion --jq '.[0].conclusion' 2>/dev/null || echo "unknown")
echo "Last CI run: $LAST_RUN"
if [ "$LAST_RUN" = "failure" ]; then
echo "::warning::Last CI/CD run on main failed. Proceeding anyway (manual trigger)."
fi
echo "✅ Pre-flight checks passed"
# ============================================================================
# TAG + RELEASE (no commits — branch protection safe)
# ============================================================================
release:
name: Create Release
runs-on: ubuntu-latest
needs: preflight
permissions:
contents: write
outputs:
tag: ${{ steps.tag.outputs.tag }}
version: ${{ steps.tag.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create and push tag
id: tag
run: |
VERSION="${{ inputs.version }}"
TAG="v${VERSION}"
git tag -a "$TAG" -m "Release $TAG
OpenCloudTouch $TAG — Local control for Bose SoundTouch devices.
See CHANGELOG.md for details."
git push origin "$TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "✅ Tag $TAG created and pushed"
echo "🚀 CI/CD Pipeline will build Docker images automatically"
- name: Generate release notes
id: notes
run: |
VERSION="${{ inputs.version }}"
TAG="v${VERSION}"
# Get previous tag
PREV_TAG=$(git tag --sort=-v:refname | grep -v "$TAG" | head -1 || echo "")
if [ -z "$PREV_TAG" ]; then
RANGE=""
COMPARE_TEXT="🎉 **First release of OpenCloudTouch!**"
else
RANGE="${PREV_TAG}..${TAG}"
COMPARE_TEXT="**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${TAG}"
fi
# Build release notes file
cat > release-notes.md << EOF
## 🚀 OpenCloudTouch v${VERSION}
Local control for Bose® SoundTouch® devices — after the cloud shutdown.
EOF
sed -i 's/^ //' release-notes.md
# Parse conventional commits (only if we have a range)
add_section() {
local title="$1"
local pattern="$2"
local icon="$3"
local content=""
if [ -n "$RANGE" ]; then
content=$(git log $RANGE --pretty=format:"- %s (%h)" --no-merges --grep="$pattern" 2>/dev/null || echo "")
else
content=$(git log --pretty=format:"- %s (%h)" --no-merges --grep="$pattern" 2>/dev/null || echo "")
fi
if [ -n "$content" ]; then
echo "" >> release-notes.md
echo "### ${icon} ${title}" >> release-notes.md
echo "" >> release-notes.md
echo "$content" >> release-notes.md
fi
}
add_section "Features" "^feat" "✨"
add_section "Bug Fixes" "^fix" "🐛"
add_section "Performance" "^perf" "âš¡"
add_section "Refactoring" "^refactor" "♻️"
add_section "Tests" "^test" "🧪"
add_section "Documentation" "^docs" "📚"
add_section "CI/CD" "^ci" "🔧"
add_section "Maintenance" "^chore\|^build" "🛠️"
add_section "Style" "^style" "🎨"
# Docker instructions
cat >> release-notes.md << EOF
---
## 📦 Installation
### Docker (recommended)
\`\`\`bash
# Pull the latest stable release
docker pull ghcr.io/${{ github.repository }}:stable
# Or pull this specific version
docker pull ghcr.io/${{ github.repository }}:${VERSION}
# Run the container
docker run -d \\
--name opencloudtouch \\
--network host \\
-v opencloudtouch-data:/data \\
-e OCT_DISCOVERY_ENABLED=true \\
ghcr.io/${{ github.repository }}:${VERSION}
\`\`\`
### Docker Compose
\`\`\`yaml
services:
opencloudtouch:
image: ghcr.io/${{ github.repository }}:${VERSION}
container_name: opencloudtouch
restart: unless-stopped
network_mode: host
volumes:
- oct-data:/data
environment:
- OCT_DISCOVERY_ENABLED=true
- OCT_LOG_LEVEL=INFO
volumes:
oct-data:
\`\`\`
### Raspberry Pi (SD-Card Image)
Pre-built SD card images for Raspberry Pi 3/4/5 will be attached to this release shortly.
1. Download the \`.img.xz\` file for your architecture (arm64 or armhf)
2. Flash with [Raspberry Pi Imager](https://www.raspberrypi.com/software/) or: \`xz -d *.img.xz && sudo dd if=*.img of=/dev/sdX bs=4M status=progress\`
3. Boot → OpenCloudTouch starts automatically on port 7777
4. Default credentials: \`oct\` / \`opencloudtouch\`
### Available Docker Tags
| Tag | Description |
|-----|-------------|
| \`stable\` | Latest stable release (recommended) |
| \`${VERSION}\` | This specific version |
| \`latest\` | Latest build from main branch |
| \`$(echo $VERSION | cut -d. -f1-2)\` | Latest patch of this minor version |
### Supported Architectures
| Architecture | Platform | Example Devices |
|-------------|----------|-----------------|
| \`amd64\` | x86_64 | Desktop, Server, NAS |
| \`arm64\` | aarch64 | Raspberry Pi 4/5, Apple Silicon |
| \`arm/v7\` | armhf | Raspberry Pi 2/3 |
---
## 🔗 Resources
- 📖 [Documentation (Wiki)](https://github.com/scheilch/opencloudtouch/wiki)
- 🐛 [Report Issues](https://github.com/scheilch/opencloudtouch/issues)
- 📋 [Upgrade Guide](https://github.com/scheilch/opencloudtouch/blob/main/UPGRADING.md)
- 📄 [Full Changelog](https://github.com/scheilch/opencloudtouch/blob/main/CHANGELOG.md)
${COMPARE_TEXT}
EOF
# Remove heredoc indentation
sed -i 's/^ //' release-notes.md
echo "=== Release Notes Preview ==="
head -30 release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ inputs.version }}
name: "🎉 OpenCloudTouch v${{ inputs.version }}"
body_path: release-notes.md
prerelease: ${{ inputs.prerelease }}
draft: false
make_latest: ${{ !inputs.prerelease }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Step summary
run: |
VERSION="${{ inputs.version }}"
cat >> $GITHUB_STEP_SUMMARY << EOF
# 🎉 Release v${VERSION} Created!
| Step | Status |
|------|--------|
| Version check | ✅ All package files match v${VERSION} |
| Git tag | ✅ v${VERSION} |
| GitHub Release | ✅ Published |
## 🚀 Automated Downstream Pipelines
1. **CI/CD** → Docker multi-arch build + push to GHCR
[Watch](https://github.com/${{ github.repository }}/actions/workflows/ci-cd.yml)
2. **Raspberry Pi** → SD card images (arm64 + armhf)
[Watch](https://github.com/${{ github.repository }}/actions/workflows/build-raspi-image.yml)
## 📦 After CI completes
\`\`\`bash
docker pull ghcr.io/${{ github.repository }}:stable
docker pull ghcr.io/${{ github.repository }}:${VERSION}
\`\`\`
**Release:** https://github.com/${{ github.repository }}/releases/tag/v${VERSION}
EOF
# ============================================================================
# TRIGGER RASPBERRY PI IMAGE BUILDS
# ============================================================================
trigger-raspi:
name: Trigger Raspberry Pi Builds
runs-on: ubuntu-latest
needs: release
if: ${{ !inputs.skip_raspi }}
steps:
- name: Trigger build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ needs.release.outputs.version }}"
echo "🍓 Triggering Raspberry Pi image builds for v${VERSION}..."
gh workflow run build-raspi-image.yml \
--repo "${{ github.repository }}" \
--field oct_version="${VERSION}" \
--field architectures=all \
--field attach_to_release=true
echo "✅ Raspberry Pi build triggered"
echo "📋 Images will be automatically attached to the release when ready"
# ============================================================================
# VERIFY DOWNSTREAM WORKFLOWS
# ============================================================================
verify:
name: Verify Downstream
runs-on: ubuntu-latest
needs: [release, trigger-raspi]
if: always() && needs.release.result == 'success'
steps:
- name: Wait and check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sleep 15
VERSION="${{ needs.release.outputs.version }}"
TAG="v${VERSION}"
echo "# 🔍 Downstream Status" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# CI/CD
CI_STATUS=$(gh run list --workflow=ci-cd.yml --limit=1 \
--repo "${{ github.repository }}" \
--json status --jq '.[0].status' 2>/dev/null || echo "unknown")
echo "- **CI/CD Pipeline**: ${CI_STATUS}" >> $GITHUB_STEP_SUMMARY
# RasPi
if [ "${{ needs.trigger-raspi.result }}" = "success" ]; then
RASPI_STATUS=$(gh run list --workflow=build-raspi-image.yml --limit=1 \
--repo "${{ github.repository }}" \
--json status --jq '.[0].status' 2>/dev/null || echo "unknown")
echo "- **Raspberry Pi Builds**: ${RASPI_STATUS}" >> $GITHUB_STEP_SUMMARY
else
echo "- **Raspberry Pi Builds**: ⏭️ Skipped" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "📋 [Release Page](https://github.com/${{ github.repository }}/releases/tag/${TAG})" >> $GITHUB_STEP_SUMMARY