Skip to content

Commit 3390826

Browse files
authored
Add ABI generation to CI (#1706)
* Add ABI generation to CI * Move to package.json * Tweak commands * Update script * Update dir structure * Add separate package.json for the ABIs * Add NPM token * Use release tags * Use master environment * Add npmrc * Rename npmrc * Prepare for merge
1 parent 5b0abdd commit 3390826

File tree

6 files changed

+65
-3
lines changed

6 files changed

+65
-3
lines changed

.github/workflows/abi.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: DeFi
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
7+
concurrency:
8+
cancel-in-progress: true
9+
group: ${{ github.ref_name }}
10+
11+
jobs:
12+
abi-gen:
13+
name: "Generate and publish ABI"
14+
runs-on: ubuntu-latest
15+
environment: master
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: "16.x"
23+
cache: "yarn"
24+
cache-dependency-path: contracts/yarn.lock
25+
26+
- run: yarn install --frozen-lockfile
27+
working-directory: ./contracts
28+
29+
- name: "Generate ABI files"
30+
run: (yarn run abi:generate) && (yarn run abi:dist)
31+
env:
32+
CONTRACT_SIZE: true
33+
working-directory: ./contracts
34+
35+
- name: Update version from tag
36+
working-directory: ./contracts/dist
37+
run: |
38+
VERSION="0.1.0"
39+
if [ "${{ env.GITHUB_REF_TYPE }}" = "tag" ]; then
40+
VERSION="${GITHUB_REF_NAME#v}"
41+
fi
42+
43+
echo "Version set to $VERSION"
44+
sed -i -e "s/RELEASE_VERSION/$VERSION/g" package.json
45+
46+
- name: "Publish"
47+
run: npm publish --access public
48+
working-directory: ./contracts/dist
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ORIGIN_DEFI }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ contracts/deployments/hardhat*
5858
contracts/coverage/
5959
contracts/coverage.json
6060
contracts/build/
61+
contracts/dist/
6162
dapp/network.json
6263
dapp/keys/
6364
dapp/ganache-network.json

contracts/.npmrc.abi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}
2+
registry=https://registry.npmjs.org/
3+
always-auth=true

contracts/abi.package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@origin/defi",
3+
"version": "RELEASE_VERSION",
4+
"license": "MIT",
5+
"homepage": "https://github.com/originprotocol/origin-dollar",
6+
"engines": {
7+
"node": "16"
8+
}
9+
}

contracts/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"deploy:mainnet": "(npx hardhat deploy --network mainnet --verbose --export '../dapp/network.mainnet.json') && yarn run copy-interface-artifacts",
99
"deploy:oeth": "(rm -rf deployments/hardhat && npx hardhat deploy --export '../dapp-oeth/network.json') && yarn run copy-interface-artifacts:oeth",
1010
"deploy:oeth:mainnet": "(npx hardhat deploy --network mainnet --verbose --export '../dapp-oeth/network.mainnet.json') && yarn run copy-interface-artifacts",
11+
"abi:generate": "(rm -rf deployments/hardhat && mkdir -p dist/abi && npx hardhat deploy --export '../dist/network.json')",
12+
"abi:dist": "find ./artifacts/contracts -name \"*.json\" -type f -exec cp {} ./dist/abi \\; && rm -rf dist/abi/*.dbg.json dist/abi/Mock*.json && cp ./abi.package.json dist/package.json && cp ./.npmrc.abi dist/.npmrc",
1113
"node": "yarn run node:fork",
1214
"node:fork": "./node.sh fork",
1315
"lint": "yarn run lint:js && yarn run lint:sol",

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
"build:oethdapp": "(cd dapp-oeth && NODE_ENV=development yarn install && yarn build)",
1010
"start": "bash devops/start-dapp.sh"
1111
},
12-
"dependencies": {
13-
"react-use": "^17.4.0"
14-
},
1512
"engines": {
1613
"node": "16"
1714
}

0 commit comments

Comments
 (0)