-
Notifications
You must be signed in to change notification settings - Fork 4
207 lines (176 loc) · 6.86 KB
/
release.yml
File metadata and controls
207 lines (176 loc) · 6.86 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
name: Release
on:
release:
types: [created]
env:
CARGO_TERM_COLOR: always
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32v1-none
components: rustfmt, clippy
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install Stellar CLI
run: |
curl -L https://github.com/stellar/stellar-cli/releases/download/v25.2.0/stellar-cli-25.2.0-x86_64-unknown-linux-gnu.tar.gz | tar -xz
sudo mv stellar /usr/local/bin/
stellar --version
- name: Build contracts with optimization
run: stellar contract build
- name: Create and fund testnet account
run: |
# Generate a new keypair for deployment
stellar keys generate deployer --network testnet --overwrite
# Fund the account on testnet
stellar keys fund deployer --network testnet
# Verify account was funded
stellar keys address deployer
- name: Generate TypeScript bindings
run: |
# Generate bindings for smart account
stellar contract bindings typescript \
--wasm target/wasm32v1-none/release/smart_account.wasm \
--output-dir bindings \
--overwrite
# Overwrite generated tsconfig to prevent bs58 ambient type resolution error in TS 5.x
cat > bindings/tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "nodenext",
"declaration": true,
"outDir": "./dist",
"strictNullChecks": true,
"skipLibCheck": true,
"types": []
},
"include": ["src/*"]
}
EOF
# Generate bindings for factory
stellar contract bindings typescript \
--wasm target/wasm32v1-none/release/contract_factory.wasm \
--output-dir bindings-factory \
--overwrite
cat > bindings-factory/tsconfig.json << 'EOF'
{
"compilerOptions": {
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "nodenext",
"declaration": true,
"outDir": "./dist",
"strictNullChecks": true,
"skipLibCheck": true,
"types": []
},
"include": ["src/*"]
}
EOF
- name: Build TypeScript packages
run: |
cd bindings
pnpm install
pnpm run build
cd ../bindings-factory
pnpm install
pnpm run build
cd ..
- name: Optimize WASM contracts
run: |
set -euo pipefail
OUT_DIR="target/wasm32v1-none/release/optimized"
mkdir -p "$OUT_DIR"
for wasm in target/wasm32v1-none/release/*.wasm; do
[ -e "$wasm" ] || continue
base="$(basename "$wasm" .wasm)"
stellar contract optimize \
--wasm "$wasm" \
--wasm-out "$OUT_DIR/${base}.optimized.wasm"
done
- name: Upload WASM files to testnet
run: |
# Upload smart account contract (optimized)
SMART_ACCOUNT_HASH=$(stellar contract upload \
--wasm target/wasm32v1-none/release/optimized/smart_account.optimized.wasm \
--source deployer \
--network testnet)
echo "SMART_ACCOUNT_HASH=$SMART_ACCOUNT_HASH" >> $GITHUB_ENV
# Upload contract factory (optimized)
FACTORY_HASH=$(stellar contract upload \
--wasm target/wasm32v1-none/release/optimized/contract_factory.optimized.wasm \
--source deployer \
--network testnet)
echo "FACTORY_HASH=$FACTORY_HASH" >> $GITHUB_ENV
echo "Smart Account WASM Hash: $SMART_ACCOUNT_HASH"
echo "Factory WASM Hash: $FACTORY_HASH"
- name: Calculate WASM hashes and create release tarfile
run: |
# Create release directory
mkdir -p release-artifacts
# Copy unoptimized WASM files
cp target/wasm32v1-none/release/*.wasm release-artifacts/
# Copy optimized WASM files (if present)
mkdir -p release-artifacts/optimized
if [ -d "target/wasm32v1-none/release/optimized" ]; then
cp target/wasm32v1-none/release/optimized/*.wasm release-artifacts/optimized/ || true
fi
# Generate hash files
cd release-artifacts
sha256sum *.wasm > wasm-hashes.txt
if [ -d "optimized" ] && ls optimized/*.wasm >/dev/null 2>&1; then
(cd optimized && sha256sum *.wasm > ../optimized-wasm-hashes.txt)
fi
cd ..
# Copy TypeScript packages
cp -r bindings/dist release-artifacts/smart_account_types
cp -r bindings-factory/dist release-artifacts/factory_types
# Copy package.json files for reference
cp bindings/package.json release-artifacts/smart_account_types/
cp bindings-factory/package.json release-artifacts/factory_types/
# Create tarfile including both optimized and unoptimized artifacts
tar -czf stellar-smart-account-release-${{ github.event.release.tag_name }}.tar.gz -C release-artifacts .
# List contents for verification
echo "Release tarfile contents:"
tar -tzf stellar-smart-account-release-${{ github.event.release.tag_name }}.tar.gz
- name: Upload release artifact
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} \
stellar-smart-account-release-${{ github.event.release.tag_name }}.tar.gz
- name: Create deployment summary
run: |
echo "## Release Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Smart Account WASM Hash**: \`$SMART_ACCOUNT_HASH\`" >> $GITHUB_STEP_SUMMARY
echo "- **Factory WASM Hash**: \`$FACTORY_HASH\`" >> $GITHUB_STEP_SUMMARY
echo "- **Network**: Stellar Testnet" >> $GITHUB_STEP_SUMMARY
echo "- **Release Artifact**: stellar-smart-account-release-${{ github.event.release.tag_name }}.tar.gz" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Tarfile Contents:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tar -tzf stellar-smart-account-release-${{ github.event.release.tag_name }}.tar.gz >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY