-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (146 loc) · 6.44 KB
/
Copy pathdeploy.yml
File metadata and controls
167 lines (146 loc) · 6.44 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
name: Deploy
on:
workflow_dispatch:
inputs:
network:
description: 'Network to deploy to'
required: true
type: choice
options:
- base
- base_sepolia
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Initialize submodules
run: git submodule update --init --recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install dependencies
run: |
mkdir -p lib
cd lib
if [ ! -d "forge-std" ]; then
git clone --depth 1 --branch v1.12.0 https://github.com/foundry-rs/forge-std.git
fi
if [ ! -d "openzeppelin-contracts" ]; then
git clone --depth 1 --branch v4.9.6 https://github.com/OpenZeppelin/openzeppelin-contracts.git
fi
if [ ! -d "openzeppelin-contracts-upgradeable" ]; then
git clone --depth 1 --branch v4.9.6 https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable.git
fi
- name: Set RPC URL
id: rpc
run: |
if [ "${{ inputs.network }}" == "base" ]; then
echo "url=${{ secrets.BASE_RPC_URL || 'https://mainnet.base.org' }}" >> $GITHUB_OUTPUT
else
echo "url=${{ secrets.BASE_SEPOLIA_RPC_URL || 'https://sepolia.base.org' }}" >> $GITHUB_OUTPUT
fi
- name: Deploy LoopTemplateV1
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: |
forge script script/v1/DeployLoopTemplateV1.s.sol:DeployLoopTemplateV1 \
--rpc-url ${{ steps.rpc.outputs.url }} \
--broadcast \
--slow \
-vvv
- name: Deploy MandateV1
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: |
forge script script/v1/DeployMandateV1.s.sol:DeployMandateV1 \
--rpc-url ${{ steps.rpc.outputs.url }} \
--broadcast \
--slow \
-vvv
- name: Extract deployment addresses
id: addresses
run: |
# LoopTemplateV1
LOOP_BROADCAST=$(find broadcast/DeployLoopTemplateV1.s.sol -name "run-latest.json" 2>/dev/null | tail -1)
if [ -f "$LOOP_BROADCAST" ]; then
LOOP_IMPL=$(jq -r '.transactions[] | select(.contractName == "LoopTemplateV1") | .contractAddress' $LOOP_BROADCAST | head -1)
LOOP_PROXY=$(jq -r '.transactions[] | select(.contractName == "ERC1967Proxy") | .contractAddress' $LOOP_BROADCAST | head -1)
echo "loop_implementation=$LOOP_IMPL" >> $GITHUB_OUTPUT
echo "loop_proxy=$LOOP_PROXY" >> $GITHUB_OUTPUT
echo "LoopTemplateV1 Implementation: $LOOP_IMPL"
echo "LoopTemplateV1 Proxy: $LOOP_PROXY"
fi
# MandateV1
MANDATE_BROADCAST=$(find broadcast/DeployMandateV1.s.sol -name "run-latest.json" 2>/dev/null | tail -1)
if [ -f "$MANDATE_BROADCAST" ]; then
MANDATE_IMPL=$(jq -r '.transactions[] | select(.contractName == "MandateV1") | .contractAddress' $MANDATE_BROADCAST | head -1)
MANDATE_PROXY=$(jq -r '.transactions[] | select(.contractName == "ERC1967Proxy") | .contractAddress' $MANDATE_BROADCAST | tail -1)
echo "mandate_implementation=$MANDATE_IMPL" >> $GITHUB_OUTPUT
echo "mandate_proxy=$MANDATE_PROXY" >> $GITHUB_OUTPUT
echo "MandateV1 Implementation: $MANDATE_IMPL"
echo "MandateV1 Proxy: $MANDATE_PROXY"
fi
- name: Wait for block indexing
run: |
echo "Waiting 30 seconds for BaseScan to index blocks..."
sleep 30
- name: Verify contracts
env:
BASESCAN_API_KEY: ${{ secrets.BASESCAN_API_KEY }}
run: |
CHAIN="${{ inputs.network }}"
# Verify LoopTemplateV1 Implementation
if [ -n "${{ steps.addresses.outputs.loop_implementation }}" ]; then
echo "Verifying LoopTemplateV1 Implementation..."
forge verify-contract ${{ steps.addresses.outputs.loop_implementation }} \
src/v1/LoopTemplateV1.sol:LoopTemplateV1 \
--chain ${CHAIN} \
--watch || echo "LoopTemplateV1 verification failed, contract may already be verified"
fi
# Verify MandateV1 Implementation
if [ -n "${{ steps.addresses.outputs.mandate_implementation }}" ]; then
echo "Verifying MandateV1 Implementation..."
forge verify-contract ${{ steps.addresses.outputs.mandate_implementation }} \
src/v1/MandateV1.sol:MandateV1 \
--chain ${CHAIN} \
--watch || echo "MandateV1 verification failed, contract may already be verified"
fi
- name: Save deployment info
run: |
NETWORK=${{ inputs.network }}
mkdir -p deployments
cat > deployments/${NETWORK}.json << EOF
{
"network": "${NETWORK}",
"chainId": "${{ inputs.network == 'base' && '8453' || '84532' }}",
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"contracts": {
"LoopTemplateV1": {
"implementation": "${{ steps.addresses.outputs.loop_implementation }}",
"proxy": "${{ steps.addresses.outputs.loop_proxy }}"
},
"MandateV1": {
"implementation": "${{ steps.addresses.outputs.mandate_implementation }}",
"proxy": "${{ steps.addresses.outputs.mandate_proxy }}"
}
}
}
EOF
cat deployments/${NETWORK}.json
- name: Commit deployment addresses
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add deployments/${{ inputs.network }}.json broadcast/
git commit -m "deploy: LoopTemplateV1 and MandateV1 to ${{ inputs.network }}
Network: ${{ inputs.network }}
Chain ID: ${{ inputs.network == 'base' && '8453' || '84532' }}
LoopTemplateV1:
Implementation: ${{ steps.addresses.outputs.loop_implementation }}
Proxy: ${{ steps.addresses.outputs.loop_proxy }}
MandateV1:
Implementation: ${{ steps.addresses.outputs.mandate_implementation }}
Proxy: ${{ steps.addresses.outputs.mandate_proxy }}" || echo "No changes to commit"
git push