-
-
Notifications
You must be signed in to change notification settings - Fork 2
254 lines (220 loc) · 8.21 KB
/
deploy-v3.yml
File metadata and controls
254 lines (220 loc) · 8.21 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
name: Deploy CastQuest V3
on:
push:
tags:
- 'v3.*'
workflow_dispatch:
inputs:
environment:
description: 'Deployment environment'
required: true
default: 'testnet'
type: choice
options:
- testnet
- mainnet
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env:
NODE_VERSION: '20'
PNPM_VERSION: '9'
jobs:
# Validate contracts
validate-contracts:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Check contracts formatting
working-directory: packages/contracts
run: forge fmt --check
- name: Build contracts
working-directory: packages/contracts
run: forge build --sizes
- name: Run contract tests
working-directory: packages/contracts
run: forge test -vv
- name: Generate gas report
working-directory: packages/contracts
run: forge test --gas-report
# Deploy contracts to testnet or mainnet
deploy-contracts:
needs: validate-contracts
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Deploy to Testnet
if: github.event.inputs.environment == 'testnet' || contains(github.ref, 'alpha') || contains(github.ref, 'beta')
working-directory: packages/contracts
env:
PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
BASE_SEPOLIA_RPC_URL: ${{ secrets.BASE_SEPOLIA_RPC_URL }}
OPTIMISM_SEPOLIA_RPC_URL: ${{ secrets.OPTIMISM_SEPOLIA_RPC_URL }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
OPTIMISM_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISM_ETHERSCAN_API_KEY }}
run: |
forge script script/DeployV3.s.sol \
--rpc-url $BASE_SEPOLIA_RPC_URL \
--broadcast \
--verify \
--etherscan-api-key $BASESCAN_API_KEY \
-vvv
- name: Deploy to Mainnet
if: github.event.inputs.environment == 'mainnet' && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
working-directory: packages/contracts
env:
PRIVATE_KEY: ${{ secrets.DEPLOYER_PRIVATE_KEY }}
BASE_RPC_URL: ${{ secrets.BASE_RPC_URL }}
OPTIMISM_RPC_URL: ${{ secrets.OPTIMISM_RPC_URL }}
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
OPTIMISM_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISM_ETHERSCAN_API_KEY }}
run: |
forge script script/DeployV3.s.sol \
--rpc-url $BASE_RPC_URL \
--broadcast \
--verify \
--etherscan-api-key $BASESCAN_API_KEY \
--slow \
-vvv
- name: Export ABIs
run: bash scripts/extract-abis.sh
- name: Upload deployment artifacts
uses: actions/upload-artifact@v4
with:
name: deployment-artifacts
path: |
packages/contracts/broadcast/
packages/contracts/deployments/
packages/sdk/src/abis/
retention-days: 30
# Build and deploy frontend
deploy-frontend:
needs: deploy-contracts
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
app: [web, admin]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Download deployment artifacts
uses: actions/download-artifact@v3
with:
name: deployment-artifacts
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm build
- name: Deploy Web to Vercel
if: matrix.app == 'web'
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_WEB_PROJECT_ID }}
vercel-args: ${{ github.event.inputs.environment == 'mainnet' && '--prod' || '' }}
working-directory: ./apps/web
- name: Deploy Admin to Vercel
if: matrix.app == 'admin'
uses: amondnet/vercel-action@v25
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_ADMIN_PROJECT_ID }}
vercel-args: ${{ github.event.inputs.environment == 'mainnet' && '--prod' || '' }}
working-directory: ./apps/admin
# Post-deployment verification
verify-deployment:
needs: [deploy-contracts, deploy-frontend]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: ${{ env.PNPM_VERSION }}
- name: Download deployment artifacts
uses: actions/download-artifact@v4
with:
name: deployment-artifacts
- name: Verify contract deployments
run: |
echo "Verifying contract deployments..."
# Check if deployment artifacts exist
if [ ! -d "packages/contracts/broadcast" ]; then
echo "❌ No deployment artifacts found"
exit 1
fi
# Check if ABIs were extracted
if [ ! -d "packages/sdk/src/abis" ]; then
echo "❌ ABIs not extracted"
exit 1
fi
echo "✅ Deployment artifacts verified"
- name: Health check
run: |
echo "Running health checks..."
# Verify SDK builds successfully with new contracts
cd packages/sdk
pnpm build || {
echo "❌ SDK build failed"
exit 1
}
echo "✅ Health checks passed"
- name: Create deployment summary
run: |
echo "## 🚀 CastQuest V3 Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Environment: ${{ github.event.inputs.environment || 'testnet' }}" >> $GITHUB_STEP_SUMMARY
echo "### Version: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "✅ Contracts deployed and verified" >> $GITHUB_STEP_SUMMARY
echo "✅ Frontend deployed" >> $GITHUB_STEP_SUMMARY
echo "✅ Health checks passed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Update contract addresses in environment variables" >> $GITHUB_STEP_SUMMARY
echo "2. Transfer admin roles to multi-sig wallets" >> $GITHUB_STEP_SUMMARY
echo "3. Announce deployment to community" >> $GITHUB_STEP_SUMMARY
echo "4. Monitor for first 24 hours" >> $GITHUB_STEP_SUMMARY