-
Notifications
You must be signed in to change notification settings - Fork 54
203 lines (173 loc) · 6.96 KB
/
Copy pathrelease.yml
File metadata and controls
203 lines (173 loc) · 6.96 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
name: Release WASM Artifacts
on:
push:
tags:
- v*
permissions:
contents: write
jobs:
build-and-verify:
name: Build, Optimize and Verify
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: |
crates/contracts/core
- name: Install WASM optimization tools
run: |
set -euo pipefail
cargo install wasm-opt
cargo install wasm-tools
- name: Build WASM artifact
run: |
set -euo pipefail
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-C embed-bitcode=no"
cargo build -p core \
--target wasm32-unknown-unknown \
--release \
- name: Strip WASM binary
run: |
set -euo pipefail
wasm-tools strip \
target/wasm32-unknown-unknown/release/core.wasm \
-o target/wasm32-unknown-unknown/release/core_stripped.wasm
mv target/wasm32-unknown-unknown/release/core_stripped.wasm \
target/wasm32-unknown-unknown/release/core.wasm
- name: Optimize WASM with wasm-opt
run: |
set -euo pipefail
wasm-opt -Oz \
target/wasm32-unknown-unknown/release/core.wasm \
-o target/wasm32-unknown-unknown/release/core_opt.wasm
mv target/wasm32-unknown-unknown/release/core_opt.wasm \
target/wasm32-unknown-unknown/release/core.wasm
- name: Generate SHA256 checksums
run: |
set -euo pipefail
cd target/wasm32-unknown-unknown/release
sha256sum core.wasm > checksums.txt
cat checksums.txt
- name: Create release artifact directory
run: |
set -euo pipefail
mkdir -p release-artifacts
cp target/wasm32-unknown-unknown/release/core.wasm \
release-artifacts/core-${{ github.ref_name }}.wasm
cp target/wasm32-unknown-unknown/release/checksums.txt \
release-artifacts/checksums.txt
- name: Display artifact information
run: |
set -euo pipefail
echo "=== Release Artifacts ==="
find release-artifacts -type f -exec ls -lh {} \;
echo ""
echo "=== Checksum Verification ==="
cat release-artifacts/checksums.txt
- name: Store first checksum for verification
run: |
set -euo pipefail
cd release-artifacts
sha256sum core-${{ github.ref_name }}.wasm > first-checksum.txt
cat first-checksum.txt
- name: Verify build reproducibility
run: |
set -euo pipefail
# Clean build artifacts but keep source
rm -rf target/wasm32-unknown-unknown/release/core.wasm
# Rebuild from scratch
export CARGO_INCREMENTAL=0
export RUSTFLAGS="-C embed-bitcode=no"
cargo build -p core \
--target wasm32-unknown-unknown \
--release
# Strip again
wasm-tools strip \
target/wasm32-unknown-unknown/release/core.wasm \
-o target/wasm32-unknown-unknown/release/core_stripped.wasm
mv target/wasm32-unknown-unknown/release/core_stripped.wasm \
target/wasm32-unknown-unknown/release/core.wasm
# Optimize again
wasm-opt -Oz \
target/wasm32-unknown-unknown/release/core.wasm \
-o target/wasm32-unknown-unknown/release/core_opt.wasm
mv target/wasm32-unknown-unknown/release/core_opt.wasm \
target/wasm32-unknown-unknown/release/core.wasm
# Verify checkpoint
echo "=== Verification Build Complete ==="
- name: Verify artifact integrity
run: |
set -euo pipefail
cd target/wasm32-unknown-unknown/release
# Compute fresh checksum
sha256sum core.wasm > fresh-checksum.txt
cat fresh-checksum.txt
# Extract hash from first build
FIRST_HASH=$(head -c 64 release-artifacts/first-checksum.txt)
SECOND_HASH=$(head -c 64 fresh-checksum.txt)
echo ""
echo "First build hash: $FIRST_HASH"
echo "Verification hash: $SECOND_HASH"
echo ""
if [ "$FIRST_HASH" != "$SECOND_HASH" ]; then
echo "ERROR: Build is NOT reproducible!"
echo "First build: $(cat ../../release-artifacts/first-checksum.txt)"
echo "Second build: $(cat fresh-checksum.txt)"
exit 1
else
echo "✓ BUILD REPRODUCIBILITY VERIFIED"
fi
- name: Upload artifacts to GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
release-artifacts/core-${{ github.ref_name }}.wasm
release-artifacts/checksums.txt
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-release-notes:
name: Publish Release Notes
needs: build-and-verify
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version
id: version
run: |
set -euo pipefail
VERSION="${{ github.ref_name }}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Create release summary
run: |
set -euo pipefail
echo "## Release ${{ steps.version.outputs.version }}" > /tmp/release-summary.md
echo "" >> /tmp/release-summary.md
echo "### Build Information" >> /tmp/release-summary.md
echo "- **Build Date**: $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /tmp/release-summary.md
echo "- **Git Commit**: \`${{ github.sha }}\`" >> /tmp/release-summary.md
echo "- **Rust Toolchain**: Stable (wasm32-unknown-unknown)" >> /tmp/release-summary.md
echo "- **Build Type**: Release (--release)" >> /tmp/release-summary.md
echo "" >> /tmp/release-summary.md
echo "### Verification" >> /tmp/release-summary.md
echo "To verify artifacts locally:" >> /tmp/release-summary.md
echo "\`\`\`bash" >> /tmp/release-summary.md
echo "sha256sum -c checksums.txt" >> /tmp/release-summary.md
echo "\`\`\`" >> /tmp/release-summary.md
echo "" >> /tmp/release-summary.md
echo "### Reproducibility" >> /tmp/release-summary.md
echo "This release was built with reproducible build settings. See [RELEASE.md](./RELEASE.md) for instructions to reproduce the build locally." >> /tmp/release-summary.md
cat /tmp/release-summary.md