Skip to content

Commit

Permalink
feat: added solidity exporter action yml file (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDiscotech authored Nov 1, 2023
1 parent b7a5389 commit b38d088
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 11 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/solidity-exporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Export Interfaces And Contracts

on: [push]

jobs:
export:
name: Generate Interfaces And Contracts
# Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
if: false
runs-on: ubuntu-latest
strategy:
matrix:
export_type: ["interfaces", "contracts"]

steps:
- uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: yarn --frozen-lockfile

- name: Build project and generate out directory
run: yarn build

- name: Update version
run: yarn version --new-version "0.0.0-${GITHUB_SHA::8}" --no-git-tag-version

- name: Export Solidity - ${{ matrix.export_type }}
uses: defi-wonderland/[email protected]
with:
# Update package_name with your package name
package_name: "my-cool-project"
out: "out"
interfaces: "solidity/interfaces"
contracts: "solidity/contracts"
export_type: "${{ matrix.export_type }}"

- name: Publish to NPM - ${{ matrix.export_type }}
# Update `my-cool-project` with your package name
run: cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

<dt>Github workflows CI</dt>
<dd>Run all tests and see the coverage as you push your changes.</dd>
<dd>Export your Solidity interfaces and contracts as packages, and publish them to NPM.</dd>
</dl>

## Setup
Expand Down Expand Up @@ -105,3 +106,41 @@ yarn deploy:mainnet
The deployments are stored in ./broadcast

See the [Foundry Book for available options](https://book.getfoundry.sh/reference/forge/forge-create.html).

## Export And Publish

Export TypeScript interfaces from Solidity contracts and interfaces providing compatibility with TypeChain. Publish the exported packages to NPM.

To enable this feature, make sure you've set the `NPM_TOKEN` on your org's secrets. Then set the job's conditional to `true`:

```yaml
solidity-exporter.yml

jobs:
export:
name: Generate Interfaces And Contracts
# Remove the following line if you wish to export your Solidity contracts and interfaces and publish them to NPM
if: true
...
```

Also, remember to update the `package_name` param to your package name:

```yaml
solidity-exporter.yml

- name: Export Solidity - ${{ matrix.export_type }}
uses: defi-wonderland/solidity-exporter-action@1dbf5371c260add4a354e7a8d3467e5d3b9580b8
with:
# Update package_name with your package name
package_name: "my-cool-project"
...


- name: Publish to NPM - ${{ matrix.export_type }}
# Update `my-cool-project` with your package name
run: cd export/my-cool-project-${{ matrix.export_type }} && npm publish --access public
...
```

You can take a look at our [solidity-exporter-action](https://github.com/defi-wonderland/solidity-exporter-action) repository more information and usage examples.
Loading

0 comments on commit b38d088

Please sign in to comment.