Skip to content

Commit

Permalink
feat: fix release workflow auto deployment logic
Browse files Browse the repository at this point in the history
  • Loading branch information
h5law committed Jul 1, 2024
1 parent 941fe41 commit 9684863
Show file tree
Hide file tree
Showing 172 changed files with 55,817 additions and 1,762 deletions.
22 changes: 22 additions & 0 deletions .coderabit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
early_access: false
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: true
poem: true
review_status: true
collapse_walkthrough: false
auto_review:
enabled: true
drafts: false
path_instructions:
- path: "./bindings"
instructions: |
Ignore the generated files in this directory
- path: "./src/evm/contracts"
instructions: |
Ignore the generated files in this directory
chat:
auto_reply: true
22 changes: 7 additions & 15 deletions .github/workflows/bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,22 @@ jobs:
- name: Setup Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Bun
uses: oven-sh/setup-bun@v2

- name: Install ABIGen
run: |
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.5
- name: Install Bun
uses: oven-sh/setup-bun@v1

- name: Generate Bindings
run: |
bun install --frozen-lockfile
bun run build
- name: Check for Go Bindings Changes
run: |
if [ $(git status --porcelain | sed 's/^...//' | grep bindings/ | wc -l) -ne 0 ]; then
echo "Changes in Go Bindings"
echo $(git status --porcelain | sed 's/^...//' | grep bindings/)
exit 1
fi
- name: Check for TypeScript Bindings Changes
- name: Check for Bindings Changes
run: |
if [ $(git status --porcelain | sed 's/^...//' | grep src/evm/contracts/ | wc -l) -ne 0 ]; then
echo "Changes in TypeScript Bindings"
echo $(git status --porcelain | sed 's/^...//' | grep src/evm/contracts/)
changes=$( git status --porcelain -- ./bindings )
if [ -n "$changes" ]; then
echo -e "Changes in Generated Bindings:\n$changes"
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.5
- name: Install Bun
uses: oven-sh/setup-bun@v1
uses: oven-sh/setup-bun@v2

- name: Install Dependencies
run: |
Expand Down
46 changes: 36 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- "v*.*.*"

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true

jobs:
artifacts:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -35,7 +39,7 @@ jobs:
cp -r out/Moon.sol/Moon.json artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: compiled-contracts
path: artifacts
Expand All @@ -44,12 +48,17 @@ jobs:
runs-on: ubuntu-latest
needs: artifacts
environment: release
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"

- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: compiled-contracts
path: ./artifacts
Expand All @@ -69,6 +78,12 @@ jobs:
needs: release
environment: release
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: "recursive"

- name: Get Latest Version
id: version
uses: pozetroninc/github-action-get-latest-release@master
Expand All @@ -80,20 +95,31 @@ jobs:
with:
go-version: "1.21.3"

- name: Setup Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install ABIGen
run: |
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.13.5
- uses: actions/setup-node@v4
with:
node-version: "22.3.0"
registry-url: "https://registry.npmjs.org"

- name: Install Bun
uses: oven-sh/setup-bun@v2

# Ensure /v2 is updated as the major version changes
- name: Update Go Registry
run: |
GOPROXY=proxy.golang.org go list \
-m github.com/open-ibc/vibc-core-smart-contracts/v2@${{ steps.version.outputs.release }}
- name: Update NPM Registry
run: |
npm ci
npm publish --provenance --access public
bun install --frozen-lockfile
bun run build
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update Go Registry
run: |
( cd ./bindings && \
GOPROXY=proxy.golang.org go list \
-m github.com/open-ibc/vibc-core-smart-contracts/bindings@${{ steps.version.outputs.release }} )
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ src/contracts.template.ts
forge-cache/

node_modules
package-lock.json
.env
coverage
coverage.json
Expand Down
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# specific to npm package
deployments

# Auto generated code Go and TypeScript bindings
bindings/

node_modules
.env
coverage
Expand All @@ -24,6 +27,7 @@ src/contracts.template.ts
.direnv/
forge-cache/

bun.lockb
node_modules
.env
coverage
Expand Down
56 changes: 25 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,40 +1,34 @@
.SILENT:

CONTRACT_ABI_FILES = \
./out/Dispatcher.sol/Dispatcher.json \
./out/UniversalChannelHandler.sol/UniversalChannelHandler.json \
./out/Mars.sol/Mars.json \
./out/Earth.sol/Earth.json \
./out/Moon.sol/Moon.json

TMP_ABI_DIR = .tmp_abi_vibc

.PHONY: build-contracts abigen clean extract_artifacts
.PHONY: build-contracts bindings-gen-go

build-contracts:
echo "Building contracts"; \
rm -frd ./out; \
forge install; \
forge build

extract_artifacts: build-contracts
echo "Extracting ABI artifacts..."; \
rm -rf $(TMP_ABI_DIR); \
mkdir -p $(TMP_ABI_DIR); \
for abi_file in $(CONTRACT_ABI_FILES); do \
cat $$abi_file | jq .abi > $(TMP_ABI_DIR)/$$(basename $$abi_file); \
done
forge build contracts lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Upgrade.sol -C contracts --lib-paths lib --skip test script $(wildcard contracts/implementation_templates/**/*) utils draft Rc $(wildcard contracts/mocks/**/*) --extra-output-files abi

abigen: extract_artifacts
# Libraries do not generate the correct ABI code (ChannelState enum causes errors)
# So the Ibc.sol abi generated code from abigen throws errors but is not needed.
# This is because the types exported are included in the ABIs of contracts and
# correctly interpreted (enums -> uint8 etc), the library methods are used inside
# of other contract methods and thus bindings for them do not need to be generated
# as they are not publicly exposed, but rather used within the contract itself.
#
# ABIGen issue ref: https://github.com/ethereum/solidity/issues/9278
bindings-gen-go: build-contracts
echo "Generating Go vIBC bindings..."; \
for abi_file in $(wildcard $(TMP_ABI_DIR)/*.json); do \
abi_base=$$(basename $$abi_file); \
type=$$(basename $$abi_file .json | tr "[:upper:]" "[:lower:]"); \
pkg=$$(basename $$abi_base .json | tr "[:upper:]" "[:lower:]"); \
mkdir -p ./bindings/$$pkg; \
abigen --abi $$abi_file --pkg $$pkg --type $$type --out ./bindings/$$pkg/$$type.go; \
done
rm -rfd ./bindings/go/* ; \
files=$$(/usr/bin/find $$(pwd)/out -type d | sed 's,^.*/out/,out/,' | awk -F'/' '{if ($$NF ~ /\.sol$$/) print $$0}' | awk '{split($$1,p,"[/]"); if (p[2] !~ /([Rr]c|[Vv])[0-9]+|Init|Std|AddressUpgradeable|[0-9]\$$/ && gsub(/\./,"",p[2])==1) print $$0}' | grep "out/[A-Z]" | xargs -I {} /usr/bin/find {} -maxdepth 1 -name '*.abi.json'); \
for abi_file in $$files; do \
abi_base=$$(basename $$(dirname $$abi_file)); \
if [ "$$abi_base" = "Ibc.sol" ]; then \
continue; \
fi; \
type=$$(basename $$abi_file .abi.json); \
pkg=$$(basename $$abi_base .sol | tr "[:upper:]" "[:lower:]"); \
mkdir -p ./bindings/go/$$pkg; \
abigen --abi $$abi_file --pkg $$pkg --type $$type --out ./bindings/go/$$pkg/$$type.go; \
done; \
echo "Done."

clean:
echo "Cleaning up all artifacts..."; \
rm -rf $(TMP_ABI_DIR); \
forge clean
Loading

0 comments on commit 9684863

Please sign in to comment.