-
Notifications
You must be signed in to change notification settings - Fork 0
208 lines (175 loc) · 6.31 KB
/
Copy pathrelease.yml
File metadata and controls
208 lines (175 loc) · 6.31 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
# Automated Release Workflow
# Uses semantic-release for automated versioning and changelog generation
#
# Satisfies (release-automation manifold):
# - B1: Version numbers follow semantic versioning
# - B2: Every release has a changelog
# - B3: Breaking changes increment MAJOR version
# - B4: Releases traceable to commits
# - T2: Version bump from commit types (fix→PATCH, feat→MINOR, BREAKING→MAJOR)
# - T4: Release artifacts match tagged version
# - T5: GitHub Action handles full release pipeline
# - S1: Secrets not exposed in logs
# - S2: Only GitHub Actions can create releases
# - O1: Fully automated release process
# - O2: Releases triggered on push to main only
# - O4: Manual trigger available via workflow_dispatch
#
# Satisfies (original constraints):
# - T1: CLI binaries for all 4 platforms
# - T2: Binaries attached to GitHub release
# - S2: Binaries built from tagged commit
# - O3: Release tag matches CLI version
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
dry_run:
description: 'Run semantic-release in dry-run mode'
required: false
default: 'false'
type: boolean
permissions:
contents: write
issues: write
pull-requests: write
jobs:
# Satisfies: RT-2, RT-3, RT-4 (version calculation, changelog, release)
semantic-release:
name: Semantic Release
runs-on: ubuntu-latest
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
new_release_git_tag: ${{ steps.semantic.outputs.new_release_git_tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install semantic-release
run: |
npm install -g semantic-release \
@semantic-release/changelog \
@semantic-release/git \
@semantic-release/github \
conventional-changelog-conventionalcommits
- name: Run semantic-release
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "${{ inputs.dry_run }}" = "true" ]; then
echo "Running in dry-run mode..."
npx semantic-release --dry-run
else
npx semantic-release
fi
build:
name: Build CLI Binaries
needs: semantic-release
if: needs.semantic-release.outputs.new_release_published == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout tagged commit
uses: actions/checkout@v4
with:
ref: ${{ needs.semantic-release.outputs.new_release_git_tag }}
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
working-directory: cli
run: bun install
- name: Run tests
working-directory: cli
run: bun test
- name: Build binaries for all platforms
working-directory: cli
run: |
mkdir -p dist
echo "Building darwin-arm64..."
bun build ./index.ts --compile --target=bun-darwin-arm64 --outfile ./dist/manifold-darwin-arm64
echo "Building darwin-x64..."
bun build ./index.ts --compile --target=bun-darwin-x64 --outfile ./dist/manifold-darwin-x64
echo "Building linux-x64..."
bun build ./index.ts --compile --target=bun-linux-x64 --outfile ./dist/manifold-linux-x64
echo "Building linux-arm64..."
bun build ./index.ts --compile --target=bun-linux-arm64 --outfile ./dist/manifold-linux-arm64
echo "Build complete. Binary sizes:"
ls -lh dist/
- name: Report binary sizes
working-directory: cli
run: |
echo "Binary sizes (bun compile bundles full runtime):"
for binary in dist/manifold-*; do
size=$(stat -c%s "$binary" 2>/dev/null || stat -f%z "$binary")
size_mb=$((size / 1024 / 1024))
echo " $binary: ${size_mb}MB"
done
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v4
with:
name: cli-binaries
path: cli/dist/manifold-*
retention-days: 1
release:
name: Upload Release Assets
needs: [semantic-release, build]
runs-on: ubuntu-latest
steps:
- name: Download binaries
uses: actions/download-artifact@v4
with:
name: cli-binaries
path: binaries
- name: Upload binaries to GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.semantic-release.outputs.new_release_git_tag }}
files: binaries/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
verify:
name: Verify CLI Binary
needs: [semantic-release, release]
runs-on: ubuntu-latest
# Don't fail the workflow if verification fails (assets may take time to propagate)
continue-on-error: true
steps:
- name: Wait for release assets to propagate
run: sleep 30
- name: Download and test CLI binary
run: |
VERSION="${{ needs.semantic-release.outputs.new_release_git_tag }}"
BINARY_URL="https://github.com/dhanesh/manifold/releases/download/${VERSION}/manifold-linux-x64"
echo "Downloading CLI from: $BINARY_URL"
# Retry up to 3 times with 20 second delays
for i in 1 2 3; do
if curl -fsSL "$BINARY_URL" -o /tmp/manifold 2>/dev/null; then
echo "Download successful on attempt $i"
break
fi
echo "Attempt $i failed, retrying in 20s..."
sleep 20
done
if [ ! -f /tmp/manifold ]; then
echo "WARNING: Could not download CLI binary after 3 attempts"
echo "This may be a timing issue - release assets can take time to propagate"
echo "Please verify manually at: https://github.com/dhanesh/manifold/releases/tag/${VERSION}"
exit 0
fi
chmod +x /tmp/manifold
echo "Testing CLI..."
/tmp/manifold --version
/tmp/manifold --help
echo "CLI binary verified successfully!"