-
Notifications
You must be signed in to change notification settings - Fork 0
516 lines (449 loc) · 18 KB
/
release.yml
File metadata and controls
516 lines (449 loc) · 18 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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
name: Release
on:
push:
tags:
- 'v*.*.*'
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.15.2
LLVM_REPO_URL: https://github.com/llvm/llvm-project.git
LLVM_COMMIT: ee8c14be14deabace692ab51f5d5d432b0a83d58
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 }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
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
VERSION="${{ github.event.inputs.version }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=${{ github.event.inputs.prerelease }}" >> $GITHUB_OUTPUT
echo "is_nightly=false" >> $GITHUB_OUTPUT
echo "🚀 Creating manual release: $VERSION"
else
# Tag-based release
VERSION="${GITHUB_REF#refs/tags/}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "prerelease=false" >> $GITHUB_OUTPUT
echo "is_nightly=false" >> $GITHUB_OUTPUT
echo "🏷️ Creating tag-based release: $VERSION"
fi
# Debug output
echo "Final version: $VERSION"
- 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 (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 (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: $VERSION"
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-14
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 \
clang \
lld \
cmake \
ninja-build \
libboost-dev \
libc++-dev \
libc++abi-dev \
pkg-config \
z3 \
libz3-dev \
git
echo "✅ Linux dependencies installed"
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
;;
macOS)
brew update
brew install boost openssl cmake ninja z3
echo "✅ macOS dependencies installed"
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
;;
esac
- name: Cache build dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/zig
.zig-cache
vendor/mlir/
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.target }}-deps-${{ env.LLVM_COMMIT }}-${{ hashFiles('build.zig', 'src/mlir/ora/**', 'src/mlir/IR/**') }}
- name: Fetch pinned LLVM/MLIR source
shell: bash
run: |
set -euo pipefail
echo "📦 Fetching pinned LLVM/MLIR commit: ${{ env.LLVM_COMMIT }}"
rm -rf vendor/llvm-project
git init vendor/llvm-project
git -C vendor/llvm-project remote add origin "${{ env.LLVM_REPO_URL }}"
git -C vendor/llvm-project fetch --depth=1 origin "${{ env.LLVM_COMMIT }}"
git -C vendor/llvm-project checkout --detach FETCH_HEAD
echo "✅ LLVM/MLIR at $(git -C vendor/llvm-project rev-parse HEAD)"
- name: Build MLIR libraries if needed
shell: bash
run: |
if [ -d "vendor/mlir/lib" ] && [ "$(ls -A vendor/mlir/lib/*.a 2>/dev/null | wc -l)" -gt 0 ]; then
echo "✅ MLIR libraries already built and cached"
else
echo "🔨 Building MLIR libraries..."
zig build
echo "✅ MLIR libraries built"
fi
- 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/
# Show binary info
file zig-out/bin/ora
du -h zig-out/bin/ora
else
echo "❌ Binary not found"
ls -la zig-out/
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
echo "Testing --version..."
./zig-out/bin/ora --version 2>/dev/null || echo "⚠️ Version check failed (expected for now)"
echo "Testing --help..."
./zig-out/bin/ora --help 2>/dev/null || echo "⚠️ Help check failed (expected for now)"
echo "Testing compilation..."
echo 'contract Test { pub fn init() {} }' > test.ora
./zig-out/bin/ora compile test.ora 2>/dev/null || echo "⚠️ Compilation test failed"
rm -f test.ora
echo "✅ Binary test completed"
else
echo "❌ No binary to test"
exit 1
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"
cp README.md release-package/ 2>/dev/null || echo "README not found"
# Create simple README for the package
{
echo "Ora Compiler - ${{ matrix.platform }}"
echo "================================"
echo ""
echo "This is the Ora compiler binary for ${{ matrix.platform }}."
echo ""
echo "Usage:"
echo " ./ora-${{ matrix.platform }} [options] <file.ora>"
echo ""
echo "Options:"
echo " --help Show help information"
echo " --version Show version information"
echo ""
echo "For more information, visit:"
echo "https://github.com/${{ github.repository }}"
} > release-package/README.txt
ls -la release-package/
echo "Package contents:"
du -sh release-package/*
- name: Generate checksums
run: |
echo "🔍 Generating checksums..."
cd release-package
# Generate SHA256 checksums
shasum -a 256 "ora-${{ matrix.platform }}" > "checksums-${{ matrix.platform }}.txt"
echo "📋 Checksums for ${{ matrix.platform }}:"
cat "checksums-${{ matrix.platform }}.txt"
- name: Upload binary to release
run: |
echo "📤 Uploading binary to release..."
VERSION="${{ needs.create-release.outputs.version }}"
echo "Using version: $VERSION"
# Check if release exists
if gh release view "$VERSION" >/dev/null 2>&1; then
echo "✅ Release $VERSION found"
# Upload binary
gh release upload "$VERSION" \
"release-package/ora-${{ matrix.platform }}" \
--clobber
echo "✅ Binary uploaded successfully"
else
echo "❌ Release $VERSION not found"
echo "Available releases:"
gh release list --limit 10
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload checksums to release
run: |
echo "📤 Uploading checksums to release..."
VERSION="${{ needs.create-release.outputs.version }}"
# Upload checksums
gh release upload "$VERSION" \
"release-package/checksums-${{ matrix.platform }}.txt" \
--clobber
echo "✅ Checksums uploaded successfully"
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: Post-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 "🔗 Release URL: https://github.com/${{ github.repository }}/releases/tag/$VERSION"
echo ""
echo "📊 Pipeline Summary:"
echo "✅ Release created: $VERSION"
echo "✅ Binaries built for all platforms"
echo "✅ Checksums generated and uploaded"
echo "✅ Release assets uploaded"
echo "🎯 Next steps:"
echo "- Test the release binaries"
echo "- Update documentation if needed"
echo "- Announce the release"