chore: add build-test-release workflow for Rust #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust Package | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'The reference (branch/tag/commit) to checkout' | |
required: false | |
release-type: | |
type: choice | |
required: false | |
default: 'none' | |
description: 'Indicates whether we want to make a release and if which one' | |
options: | |
- release | |
- none | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-and-test: | |
name: Build and Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-gnu | |
os: linux-arm64 | |
- target: x86_64-apple-darwin | |
os: macos-13 | |
- target: aarch64-apple-darwin | |
os: macos-14 | |
- target: x86_64-pc-windows-gnu | |
os: windows-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.ref }} | |
- name: Setup toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- name: Build | |
run: cargo build --target ${{ matrix.target }} --verbose | |
- name: Run tests | |
run: RUST_BACKTRACE=1 cargo test -p crate_crypto_kzg_multi_open_fk20 --lib -- --nocapture | |
# We really only want to publish the eip7594 crate | |
# However, crates.io forces us to publish its dependencies too. | |
publish: | |
name: Publish in order | |
needs: build-and-test | |
if: ${{ inputs.release-type != 'none' && github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.ref || github.ref }} | |
- name: Setup toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
# These steps are in a specific order so crate dependencies are updated first | |
- name: Publish bls12_381 | |
run: cargo publish --package crate_crypto_internal_eth_kzg_bls12_381 | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }} | |
- name: Publish polynomial | |
run: cargo publish --package crate_crypto_internal_eth_kzg_polynomial | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }} | |
- name: Publish erasure_codes | |
run: cargo publish --package crate_crypto_internal_eth_kzg_erasure_codes | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }} | |
- name: Publish kzg_multi_open | |
run: cargo publish --package crate_crypto_kzg_multi_open_fk20 | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }} | |
- name: Publish eip7594 | |
run: cargo publish --package eip7594 | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_RELEASE_TOKEN }} |