Skip to content

Commit

Permalink
ci: push bindings to crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Sep 30, 2024
1 parent 699e445 commit f039328
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
64 changes: 63 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ on:
concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
version_or_publish:
name: Version packages or publish them to npmjs.com
runs-on: ubuntu-latest
defaults:
run:
working-directory: onchain/rollups
outputs:
published: ${{ steps.changeset.outputs.published }}
version: ${{ steps.get_version.outputs.version }}

steps:
- uses: actions/checkout@v4
Expand All @@ -35,6 +39,7 @@ jobs:

- name: Create release PR or publish to npm
uses: changesets/action@v1
id: changeset
with:
setupGitUser: false
commit: "chore: version packages"
Expand All @@ -43,3 +48,60 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Get version
id: get_version
run: jq -r '"version=\(.version)"' package.json >> "$GITHUB_OUTPUT"

rust_bindings:
name: Generate and publish Rust bindings
needs: version_or_publish
if: ${{ needs.version_or_publish.outputs.published == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: onchain/rollups

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v4
with:
node-version: 18

- uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
run: yarn install

- name: Install Python dependencies
run: pip install yq

- name: Generate Rust bindings
run: |
forge bind \
--crate-name cartesi-rollups-contracts \
--crate-version "$VERSION" \
--skip test \
--libraries node_modules/@cartesi/util/contracts/CartesiMathV2.sol:CartesiMathV2:0xB634F716BEd5Dd5A2b9a91C92474C499e50Cb27D \
--libraries node_modules/@cartesi/util/contracts/MerkleV2.sol:MerkleV2:0x33436035441927Df1a73FE3AAC5906854632e53d \
--libraries node_modules/@cartesi/util/contracts/Bitmask.sol:Bitmask:0xF5B2d8c81cDE4D6238bBf20D3D77DB37df13f735 \
--alloy
env:
VERSION: ${{ needs.version_or_publish.outputs.version }}

- name: Edit Rust package manifest
working-directory: out/bindings
run: |
tomlq -ti '.package.license = "Apache-2.0"' Cargo.toml
tomlq -ti '.package.description = "Rust bindings for Cartesi Rollups smart contracts"' Cargo.toml
tomlq -ti 'del(.dependencies.alloy.git)' Cargo.toml
tomlq -ti '.dependencies.alloy.version = "0.3.1"' Cargo.toml
- name: Publish Rust package to crates.io
working-directory: out/bindings
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
5 changes: 5 additions & 0 deletions onchain/rollups/.changeset/friendly-kiwis-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": patch
---

Push bindings to crates.io

0 comments on commit f039328

Please sign in to comment.