-
Notifications
You must be signed in to change notification settings - Fork 136
212 lines (185 loc) · 6.76 KB
/
release.yml
File metadata and controls
212 lines (185 loc) · 6.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
name: Release Automation
on:
push:
tags:
- 'v*.*.*'
- 'v*.*.*-rc.*'
- 'v*.*.*-beta.*'
- 'v*.*.*-alpha.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v5.0.0)'
required: true
type: string
env:
NODE_OPTIONS: --max-old-space-size=5500
NODE_VERSION: '24'
GO_VERSION: '1.21'
BUN_VERSION: 'latest'
jobs:
validate-version:
name: Validate Version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
is_prerelease: ${{ steps.check-prerelease.outputs.is_prerelease }}
steps:
- name: Get version from tag or input
id: get-version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "📦 Release version: ${VERSION}"
- name: Check if prerelease
id: check-prerelease
run: |
VERSION="${{ steps.get-version.outputs.version }}"
if [[ "$VERSION" =~ (alpha|beta|rc) ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
echo "🧪 This is a pre-release"
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
echo "🚀 This is a production release"
fi
build-release:
name: Build Release Artifacts
runs-on: ubuntu-latest
needs: validate-version
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git archive
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: src/jetstream/go.sum
- name: Install dependencies
run: bun install
- name: Build all (frontend + cross-compile backends)
run: make build all VERSION=${{ needs.validate-version.outputs.version }}
env:
NODE_ENV: production
- name: Verify binaries
run: |
echo "🔍 Verifying built binaries..."
for binary in dist/bin/jetstream-*; do
echo "✓ $(basename $binary): $(file $binary | cut -d: -f2-)"
done
- name: Package release archives
run: make release github VERSION=${{ needs.validate-version.outputs.version }}
- name: Generate checksums
run: ./build/create-checksums.sh ${{ needs.validate-version.outputs.version }}
- name: Verify release artifacts
run: |
echo "📦 Release artifacts:"
ls -lh dist/release/
echo ""
echo "🔐 Checksums:"
cat dist/release/SHA256SUMS
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: dist/release/*
retention-days: 30
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [validate-version, build-release]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: dist/release/
- name: Extract changelog for version
id: changelog
run: |
VERSION="${{ needs.validate-version.outputs.version }}"
# Try to extract version-specific changelog
if [ -f CHANGELOG.md ]; then
# Extract section between this version and next version header
NOTES=$(awk "/^## \[?${VERSION#v}\]?/,/^## \[?[0-9]/" CHANGELOG.md | sed '1d;$d' || echo "")
fi
if [ -z "$NOTES" ]; then
NOTES="Release $VERSION - See [CHANGELOG.md](CHANGELOG.md) for details."
fi
# Save to file for GitHub release
echo "$NOTES" > /tmp/release-notes.md
echo "📝 Release notes prepared"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.validate-version.outputs.version }}
name: Stratos ${{ needs.validate-version.outputs.version }}
body_path: /tmp/release-notes.md
prerelease: ${{ needs.validate-version.outputs.is_prerelease == 'true' }}
files: |
dist/release/*.tar.gz
dist/release/*.zip
dist/release/SHA256SUMS
draft: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release summary
run: |
echo "# 🎉 Release ${{ needs.validate-version.outputs.version }} Published!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📦 Release Artifacts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Platform | Archive | Size |" >> $GITHUB_STEP_SUMMARY
echo "|----------|---------|------|" >> $GITHUB_STEP_SUMMARY
cd dist/release
for file in *.tar.gz *.zip; do
if [ -f "$file" ]; then
SIZE=$(ls -lh "$file" | awk '{print $5}')
echo "| ${file#stratos-${{ needs.validate-version.outputs.version }}-} | $file | $SIZE |" >> $GITHUB_STEP_SUMMARY
fi
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 🔐 Checksums" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat SHA256SUMS >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ All release artifacts uploaded successfully!" >> $GITHUB_STEP_SUMMARY
trigger-docker-build:
name: Trigger Docker Build
runs-on: ubuntu-latest
needs: [validate-version, create-github-release]
if: needs.validate-version.outputs.is_prerelease == 'false'
steps:
- name: Trigger Docker workflow
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'docker.yml',
ref: '${{ needs.validate-version.outputs.version }}',
inputs: {
version: '${{ needs.validate-version.outputs.version }}'
}
});
console.log('🐳 Docker build triggered for ${{ needs.validate-version.outputs.version }}');