-
Notifications
You must be signed in to change notification settings - Fork 0
449 lines (390 loc) · 15.3 KB
/
release.yml
File metadata and controls
449 lines (390 loc) · 15.3 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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
name: Release
on:
push:
tags:
- 'v*.*.*'
branches:
- main
schedule:
# Run nightly at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., v1.0.0 or nightly-2025-07-20)'
required: true
type: string
prerelease:
description: 'Mark as pre-release'
required: false
type: boolean
default: false
release_type:
description: 'Release type'
required: false
type: choice
options:
- stable
- nightly
default: stable
env:
ZIG_VERSION: 0.14.1
permissions:
contents: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
is_nightly: ${{ steps.version.outputs.is_nightly }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Determine version and release type
id: version
run: |
# Determine if this is a nightly release
if [ "${{ github.event_name }}" = "schedule" ] ||
[ "${{ github.event_name }}" = "push" -a "${{ github.ref }}" = "refs/heads/main" ] ||
[ "${{ github.event.inputs.release_type }}" = "nightly" ]; then
# Nightly release
DATE=$(date -u +%Y%m%d)
SHORT_SHA=$(git rev-parse --short HEAD)
VERSION="nightly-${DATE}-${SHORT_SHA}"
IS_PRERELEASE="true"
IS_NIGHTLY="true"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=$IS_PRERELEASE" >> $GITHUB_OUTPUT
echo "is_nightly=$IS_NIGHTLY" >> $GITHUB_OUTPUT
echo "🌙 Creating nightly release: $VERSION"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Manual release
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "prerelease=${{ github.event.inputs.prerelease }}" >> $GITHUB_OUTPUT
echo "is_nightly=false" >> $GITHUB_OUTPUT
else
# Tag-based release
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
echo "is_nightly=false" >> $GITHUB_OUTPUT
fi
- name: Cleanup old nightly releases
if: steps.version.outputs.is_nightly == 'true'
run: |
echo "🧹 Cleaning up old nightly releases..."
# Keep only the last 7 nightly releases
gh release list --limit 50 | grep "nightly-" | tail -n +8 | while read line; do
tag=$(echo "$line" | awk '{print $1}')
echo "🗑️ Deleting old nightly release: $tag"
gh release delete "$tag" --yes || echo "⚠️ Failed to delete $tag"
done || echo "ℹ️ No old nightly releases to clean up"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate changelog
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
IS_NIGHTLY="${{ steps.version.outputs.is_nightly }}"
echo "📝 Generating changelog for $VERSION..."
if [ "$IS_NIGHTLY" = "true" ]; then
# Nightly release changelog
{
echo "# Nightly Build $VERSION"
echo ""
echo "🌙 **This is a nightly development build** - use at your own risk!"
echo ""
echo "## 📅 Build Information"
echo "- **Build Date**: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo "- **Commit**: \`$(git rev-parse HEAD)\`"
echo "- **Branch**: \`main\`"
echo ""
echo "## 🔄 Recent Changes"
echo ""
# Show last 10 commits
git log --pretty=format:"- %s (%h)" -10 | sed 's/^/ /'
echo ""
echo ""
echo "## ⚠️ Important Notes"
echo ""
echo "- This is an **unstable development build**"
echo "- Features may be incomplete or broken"
echo "- Use stable releases for production"
echo "- Report issues on [GitHub Issues](https://github.com/${{ github.repository }}/issues)"
echo ""
echo "## 📦 Download"
echo ""
echo "Choose the appropriate binary for your platform:"
echo "- **Linux (x86_64)**: \`ora-linux-x86_64\`"
echo "- **macOS (x86_64)**: \`ora-macos-x86_64\`"
echo "- **macOS (ARM64)**: \`ora-macos-arm64\`"
echo ""
echo "---"
echo ""
echo "**Next Stable Release**: Coming soon with v0.0.1"
} > CHANGELOG.md
else
# Stable release changelog (original logic)
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
{
echo "# Release $VERSION"
echo ""
echo "## 🚀 Features"
echo ""
if [ -n "$PREVIOUS_TAG" ]; then
echo "### Changes since $PREVIOUS_TAG"
echo ""
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -E "feat|add|new" | head -10 || echo "- No major feature changes"
else
echo "- Initial release of Ora compiler"
echo "- Complete Zig-based compilation pipeline"
echo "- HIR (High-level Intermediate Representation)"
echo "- Yul code generation with optimizations"
echo "- Formal verification capabilities"
echo "- Type checking and semantic analysis"
fi
echo ""
echo "## 🐛 Bug Fixes"
echo ""
if [ -n "$PREVIOUS_TAG" ]; then
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD | grep -E "fix|bug|issue" | head -5 || echo "- No bug fixes in this release"
else
echo "- Initial stable release"
fi
echo ""
echo "## 📦 Download"
echo ""
echo "Choose the appropriate binary for your platform:"
echo "- **Linux (x86_64)**: \`ora-linux-x86_64\`"
echo "- **macOS (x86_64)**: \`ora-macos-x86_64\`"
echo "- **macOS (ARM64)**: \`ora-macos-arm64\`"
echo ""
echo "## 🔧 Installation"
echo ""
echo "1. Download the binary for your platform"
echo "2. Make it executable: \`chmod +x ora-*\`"
echo "3. Add to your PATH or run directly"
echo ""
echo "## 📖 Usage"
echo ""
echo "\`\`\`bash"
echo "# Compile an Ora source file"
echo "./ora-linux-x86_64 my_contract.ora"
echo ""
echo "# Show help"
echo "./ora-linux-x86_64 --help"
echo "\`\`\`"
echo ""
echo "## 🔍 Verification"
echo ""
echo "You can verify the integrity of downloaded binaries using the provided checksums."
echo ""
echo "---"
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREVIOUS_TAG:-initial}...$VERSION"
} > CHANGELOG.md
fi
echo "📋 Changelog generated"
cat CHANGELOG.md
- name: Create Release
id: create_release
run: |
VERSION="${{ steps.version.outputs.version }}"
IS_PRERELEASE="${{ steps.version.outputs.prerelease }}"
IS_NIGHTLY="${{ steps.version.outputs.is_nightly }}"
if [ "$IS_NIGHTLY" = "true" ]; then
echo "🌙 Creating nightly release $VERSION..."
TITLE="Nightly Build $VERSION"
else
echo "🚀 Creating stable release $VERSION..."
TITLE="Ora Compiler $VERSION"
fi
# Create release using gh CLI
if [ "$IS_PRERELEASE" = "true" ]; then
gh release create "$VERSION" \
--title "$TITLE" \
--notes-file CHANGELOG.md \
--prerelease
else
gh release create "$VERSION" \
--title "$TITLE" \
--notes-file CHANGELOG.md
fi
echo "✅ Release created successfully"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-binaries:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.os }}
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux-x86_64
target: x86_64-linux
- os: macos-latest
platform: macos-x86_64
target: x86_64-macos
- os: macos-latest
platform: macos-arm64
target: aarch64-macos
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ env.ZIG_VERSION }}
- name: Install system dependencies
run: |
echo "🔧 Installing system dependencies for ${{ runner.os }}..."
case "${{ runner.os }}" in
Linux)
sudo apt-get update -qq
sudo apt-get install -y \
build-essential \
cmake \
libboost-all-dev \
libssl-dev \
pkg-config \
git
echo "✅ Linux dependencies installed"
;;
macOS)
brew update
brew install boost openssl cmake
echo "✅ macOS dependencies installed"
;;
esac
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
key: ${{ runner.os }}-zig-${{ env.ZIG_VERSION }}-release-${{ hashFiles('build.zig', 'build.zig.zon') }}
- name: Build release binary
run: |
echo "🔨 Building Ora compiler for ${{ matrix.platform }}..."
# Build optimized release version
zig build -Doptimize=ReleaseFast -Dtarget=${{ matrix.target }}
# Verify the binary was created
if [ -f "zig-out/bin/ora" ]; then
echo "✅ Binary built successfully"
ls -la zig-out/bin/
else
echo "❌ Binary not found"
exit 1
fi
- name: Test binary
run: |
echo "🧪 Testing binary..."
if [ -f "zig-out/bin/ora" ]; then
# Test basic functionality
chmod +x zig-out/bin/ora
./zig-out/bin/ora --version 2>/dev/null || echo "⚠️ Version check failed"
./zig-out/bin/ora --help 2>/dev/null || echo "⚠️ Help check failed"
echo "✅ Binary test completed"
fi
- name: Create binary package
run: |
echo "📦 Creating binary package..."
# Create package directory
mkdir -p release-package
# Copy binary with platform-specific name
cp zig-out/bin/ora release-package/ora-${{ matrix.platform }}
# Add documentation
cp LICENSE release-package/ 2>/dev/null || echo "LICENSE not found"
# Create simple README for the package
cat > release-package/README.txt << EOF
Ora Compiler - ${{ matrix.platform }}
================================
This is the Ora compiler binary for ${{ matrix.platform }}.
Usage:
./ora-${{ matrix.platform }} [options] <file.ora>
Options:
--help Show help information
--version Show version information
For more information, visit:
https://github.com/${{ github.repository }}
EOF
ls -la release-package/
- name: Generate checksums
run: |
echo "🔍 Generating checksums..."
cd release-package
shasum -a 256 "ora-${{ matrix.platform }}" > checksums.txt
echo "📋 Checksums:"
cat checksums.txt
- name: Upload binary to release
run: |
echo "📤 Uploading binary to release..."
# Get version from tag or input
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
version="${{ github.event.inputs.version }}"
else
version="${GITHUB_REF#refs/tags/}"
fi
# Upload binary
gh release upload "$version" \
"release-package/ora-${{ matrix.platform }}" \
--clobber
echo "✅ Binary uploaded"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload checksums to release
run: |
echo "📤 Uploading checksums to release..."
# Get version from tag or input
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
version="${{ github.event.inputs.version }}"
else
version="${GITHUB_REF#refs/tags/}"
fi
# Upload checksums
gh release upload "$version" \
"release-package/checksums.txt#checksums-${{ matrix.platform }}.txt" \
--clobber
echo "✅ Checksums uploaded"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ora-${{ matrix.platform }}
path: release-package/
retention-days: 30
post-release:
name: Post-Release Tasks
runs-on: ubuntu-latest
needs: [create-release, build-binaries]
if: always() && needs.create-release.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update release summary
run: |
VERSION="${{ needs.create-release.outputs.version }}"
IS_NIGHTLY="${{ needs.create-release.outputs.is_nightly }}"
if [ "$IS_NIGHTLY" = "true" ]; then
echo "🌙 Nightly build pipeline completed!"
echo "📦 Nightly Build: $VERSION"
echo "⚠️ This is a development build - use with caution"
else
echo "🚀 Release pipeline completed successfully!"
echo "📦 Release: $VERSION"
fi
echo "🔗 URL: https://github.com/${{ github.repository }}/releases/tag/$VERSION"
echo ""
echo "📊 Post-release tasks completed"
echo "✅ Binaries built for all platforms"
echo "✅ Checksums generated"
echo "✅ Release assets uploaded"