-
Notifications
You must be signed in to change notification settings - Fork 2
453 lines (371 loc) Β· 15.3 KB
/
Copy pathauto-release.yml
File metadata and controls
453 lines (371 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
450
451
452
name: Automatic Release on Master
# This workflow creates releases without requiring a PAT token
# Version updates are included in the tag commit but NOT pushed back to the branch
# This allows it to work with protected branches that require PRs
#
# To update VERSION and build.zig.zon on master, manually create a PR after release
on:
push:
branches:
- master
- main
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
jobs:
determine-release:
name: Determine Release Version
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.check.outputs.should_release }}
new_version: ${{ steps.version.outputs.new_version }}
version_no_v: ${{ steps.version.outputs.version_no_v }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get latest tag
id: get_tag
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "π Latest tag: $LATEST_TAG"
- name: Check if should release
id: check
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
echo "π Commit message: $COMMIT_MSG"
SHOULD_RELEASE="false"
# Release conditions:
# 1. Manual workflow dispatch
# 2. Commit message contains [release], [major], [minor], or [patch]
# 3. Merge commit
# 4. Skip if commit contains [skip release] or [no release]
if echo "$COMMIT_MSG" | grep -qiE '\[(skip release|no release|skip ci)\]'; then
echo "βοΈ Skipping release (skip keyword found)"
SHOULD_RELEASE="false"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
SHOULD_RELEASE="true"
echo "π― Manual workflow dispatch - will release"
elif echo "$COMMIT_MSG" | grep -qiE '\[(release|major|minor|patch)\]'; then
SHOULD_RELEASE="true"
echo "π Release keyword found in commit message"
elif echo "$COMMIT_MSG" | grep -qiE '^Merge pull request'; then
SHOULD_RELEASE="true"
echo "π Merge commit detected - will release"
else
echo "βΉοΈ No release trigger detected"
fi
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
- name: Determine version bump
id: version
if: steps.check.outputs.should_release == 'true'
run: |
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
COMMIT_MSG=$(git log -1 --pretty=%B)
# Parse current version
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
# Determine bump type
BUMP_TYPE="patch"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
BUMP_TYPE="${{ inputs.version_bump }}"
elif echo "$COMMIT_MSG" | grep -qiE '\[major\]|BREAKING CHANGE:'; then
BUMP_TYPE="major"
elif echo "$COMMIT_MSG" | grep -qiE '\[minor\]|^feat:|^feature:'; then
BUMP_TYPE="minor"
elif echo "$COMMIT_MSG" | grep -qiE '\[patch\]|^fix:|^bugfix:'; then
BUMP_TYPE="patch"
fi
echo "π Bump type: $BUMP_TYPE"
# Calculate new version
case $BUMP_TYPE in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}"
VERSION_NO_V="${MAJOR}.${MINOR}.${PATCH}"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "version_no_v=$VERSION_NO_V" >> $GITHUB_OUTPUT
echo "π New version: $NEW_VERSION"
create-tag:
name: Create Git Tag
needs: determine-release
if: needs.determine-release.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
id: changelog
run: |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
echo "## π Changelog" > /tmp/changelog.md
echo "" >> /tmp/changelog.md
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "v0.0.0" ]]; then
echo "### Initial Release" >> /tmp/changelog.md
echo "" >> /tmp/changelog.md
git log --pretty=format:"- %s (%h)" --no-merges | head -20 >> /tmp/changelog.md
else
echo "### Changes since $LATEST_TAG" >> /tmp/changelog.md
echo "" >> /tmp/changelog.md
git log ${LATEST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges >> /tmp/changelog.md
fi
echo "" >> /tmp/changelog.md
echo "" >> /tmp/changelog.md
echo "## π Project Status" >> /tmp/changelog.md
echo "- β
334 tests passing" >> /tmp/changelog.md
echo "- β
100% feature complete" >> /tmp/changelog.md
echo "- β
13/13 modules production-ready" >> /tmp/changelog.md
echo "- β
ERC-4337 Account Abstraction support" >> /tmp/changelog.md
echo "- β
Integrated with Etherspot v2 API" >> /tmp/changelog.md
cat /tmp/changelog.md
- name: Update version in build.zig.zon
run: |
VERSION="${{ needs.determine-release.outputs.version_no_v }}"
sed -i "s/\.version = \"[^\"]*\"/\.version = \"$VERSION\"/" build.zig.zon
# Also update VERSION file
echo "$VERSION" > VERSION
echo "β
Updated version to $VERSION in build.zig.zon and VERSION"
git diff build.zig.zon VERSION
- name: Commit version update (for tag only, not pushed to branch)
run: |
NEW_VERSION="${{ needs.determine-release.outputs.new_version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add build.zig.zon VERSION
if git diff --staged --quiet; then
echo "βΉοΈ No version changes to commit"
else
git commit -m "chore: bump version to $NEW_VERSION"
echo "β
Version updated in local commit (will be in tag, not pushed to branch)"
echo "βΉοΈ Skipping push to avoid protected branch issues"
fi
- name: Create and push tag
run: |
NEW_VERSION="${{ needs.determine-release.outputs.new_version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Create annotated tag
git tag -a "$NEW_VERSION" -m "Release $NEW_VERSION" -m "$(cat /tmp/changelog.md)"
git push origin "$NEW_VERSION"
echo "β
Created and pushed tag $NEW_VERSION"
build-release:
name: Build Release (${{ matrix.os }})
needs: [determine-release, create-tag]
if: needs.determine-release.outputs.should_release == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-linux
artifact: zigeth-linux-x86_64.tar.gz
- os: ubuntu-latest
target: aarch64-linux
artifact: zigeth-linux-aarch64.tar.gz
- os: macos-latest
target: x86_64-macos
artifact: zigeth-macos-x86_64.tar.gz
- os: macos-latest
target: aarch64-macos
artifact: zigeth-macos-aarch64.tar.gz
- os: windows-latest
target: x86_64-windows
artifact: zigeth-windows-x86_64.zip
env:
ZIG_GLOBAL_CACHE_DIR: ${{ github.workspace }}/.zig-cache/global
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-release.outputs.new_version }}
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
use-cache: false
- name: Create cache directories (Unix)
if: runner.os != 'Windows'
run: mkdir -p .zig-cache/global
- name: Create cache directories (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: New-Item -Path ".zig-cache/global" -ItemType Directory -Force
- name: Cache Zig artifacts
uses: actions/cache@v4
with:
path: |
.zig-cache
~/.cache/zig
key: ${{ runner.os }}-zig-release-${{ hashFiles('build.zig', 'build.zig.zon') }}
restore-keys: |
${{ runner.os }}-zig-release-
- name: Build Release
run: zig build -Doptimize=ReleaseFast
- name: Create Archive (Unix)
if: runner.os != 'Windows'
run: |
cd zig-out
tar czf ../${{ matrix.artifact }} *
cd ..
echo "π¦ Created ${{ matrix.artifact }}"
ls -lh ${{ matrix.artifact }}
- name: Create Archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd zig-out
Compress-Archive -Path * -DestinationPath ../${{ matrix.artifact }}
cd ..
Write-Host "π¦ Created ${{ matrix.artifact }}"
Get-Item ${{ matrix.artifact }} | Format-List
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
retention-days: 90
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [determine-release, create-tag, build-release]
if: needs.determine-release.outputs.should_release == 'true'
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.determine-release.outputs.new_version }}
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display artifacts
run: |
echo "π¦ Downloaded artifacts:"
ls -R artifacts/
# Move artifacts to root for easier access
# actions/download-artifact@v4 creates subdirectories for each artifact
for dir in artifacts/*/; do
if [ -d "$dir" ]; then
# Find files in each artifact directory
find "$dir" -maxdepth 1 -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} . \;
fi
done
echo ""
echo "π¦ Release artifacts:"
ls -lh *.tar.gz *.zip 2>/dev/null || true
- name: Generate release notes
id: notes
run: |
NEW_VERSION="${{ needs.determine-release.outputs.new_version }}"
LATEST_TAG=$(git describe --tags --abbrev=0 $NEW_VERSION^ 2>/dev/null || echo "")
cat > release_notes.md << 'NOTES'
# π Zigeth ${{ needs.determine-release.outputs.new_version }}
A complete Ethereum library for Zig!
## π What's Changed
NOTES
if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "v0.0.0" ]]; then
echo "### π Initial Release" >> release_notes.md
echo "" >> release_notes.md
git log --pretty=format:"- %s (%h)" --no-merges | head -30 >> release_notes.md
else
git log ${LATEST_TAG}..${NEW_VERSION} --pretty=format:"- %s (%h)" --no-merges >> release_notes.md
fi
cat >> release_notes.md << 'NOTES'
## π Library Status
- β
**334 tests passing**
- β
**100% feature complete**
- β
**13/13 modules production-ready**
- β
**ERC-4337 Account Abstraction support**
- β
**Integrated with Etherspot v2 API**
### Modules
| Module | Status | Tests | Description |
|--------|--------|-------|-------------|
| π― Primitives | β
| 48 | Address, Hash, Bytes, Signature, U256, Bloom |
| π¦ Types | β
| 23 | Transaction, Block, Receipt, Log |
| π Crypto | β
| 27 | Keccak-256, secp256k1, ECDSA |
| π‘ ABI | β
| 23 | Encoding, Decoding, EIP-712 |
| π Contract | β
| 19 | Calls, Deploy, Events |
| π RLP | β
| 36 | Encoding, Decoding |
| π RPC | β
| 27 | Full JSON-RPC client |
| π Providers | β
| 26 | HTTP, WebSocket, IPC, Mock |
| π§° Utils | β
| 35 | Hex, Format, Units, Checksum |
| β‘ Solidity | β
| 15 | Type mappings, Interfaces |
| βοΈ Middleware | β
| 23 | Gas, Nonce, Signing |
| π Wallets | β
| 35 | Software, HD, Keystore, Ledger |
| π― Account Abstraction | β
| - | ERC-4337 v0.6/v0.7/v0.8, Bundler, Paymaster |
## π Quick Start
```zig
const zigeth = @import("zigeth");
// Create a wallet
var wallet = try zigeth.signer.Wallet.generate(allocator);
// Connect to Ethereum
var provider = try zigeth.providers.Networks.mainnet(allocator);
defer provider.deinit();
// Get balance
const balance = try provider.getBalance(address);
```
## π₯ Installation
Add to your `build.zig.zon`:
```zig
.dependencies = .{
.zigeth = .{
.url = "https://github.com/ch4r10t33r/zigeth/archive/${{ needs.determine-release.outputs.new_version }}.tar.gz",
.hash = "...", // zig will provide this
},
},
```
## π Documentation
Full documentation: https://github.com/ch4r10t33r/zigeth#readme
## π Supported Networks
- Ethereum (Mainnet, Sepolia)
- Polygon
- Arbitrum
- Optimism
- Base
- Custom RPCs
All using **Etherspot v2 API** endpoints!
NOTES
cat release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.determine-release.outputs.new_version }}
name: Release ${{ needs.determine-release.outputs.new_version }}
body_path: release_notes.md
draft: false
prerelease: false
files: |
*.tar.gz
*.zip
generate_release_notes: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}