-
Notifications
You must be signed in to change notification settings - Fork 88
97 lines (80 loc) · 3.2 KB
/
Copy pathversion-check.yaml
File metadata and controls
97 lines (80 loc) · 3.2 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
name: Version Check
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
check-bytecode-changes:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install dependencies
run: npm ci
- name: Build contracts on base branch
run: |
git checkout origin/${{ github.base_ref }}
forge clean
forge install
forge build --force
mkdir -p /tmp/base-artifacts
cp -r out/* /tmp/base-artifacts/
- name: Build contracts on PR branch
run: |
git checkout -f ${{ github.event.pull_request.head.sha }}
forge clean
forge install
forge build --force
- name: Check bytecode changes and version
id: check
run: |
node prep/check-bytecode-changes.js /tmp/base-artifacts out
- name: Bump version if needed
if: steps.check.outputs.needs_version_bump == 'true'
run: |
# Configure git
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Get the contracts that need bumping
CONTRACTS_TO_BUMP="${{ steps.check.outputs.contracts_to_bump }}"
echo "Bumping versions for contracts: $CONTRACTS_TO_BUMP"
# Update Solidity files using the upgrade script with specific contracts
CONTRACTS_TO_BUMP="$CONTRACTS_TO_BUMP" node prep/update-version.js
# Commit changes (only Solidity files, not package.json)
git add src/*.sol
git commit -m "chore: bump contract versions due to bytecode changes - Contracts updated: $CONTRACTS_TO_BUMP"
# Pull latest changes and rebase
# Pull latest changes and rebase
if ! git pull origin ${{ github.event.pull_request.head.ref }} --rebase; then
echo "Failed to rebase version bump changes. Manual intervention required."
exit 1
fi
# Push to the PR branch
git push origin HEAD:${{ github.event.pull_request.head.ref }}
- name: Create PR comment
if: steps.check.outputs.needs_version_bump == 'true'
uses: actions/github-script@v7
with:
script: |
const contractsToBump = '${{ steps.check.outputs.contracts_to_bump }}';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🤖 Bytecode changes detected! EIP-712 domain versions have been automatically updated for: ${contractsToBump}`
})