Merge pull request #83 from flood-protocol/tests-and-documentation #204
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: Push release to private registry | |
on: | |
push: | |
# This runs the job when new tag is pushed OR a commit/PR is pushed to master | |
tags: | |
- "*" | |
branches: | |
- master | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo and submodules | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Install deps | |
run: forge install | |
- name: Run tests | |
run: forge test -vvv | |
version-tag-match: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo and submodules | |
uses: actions/checkout@v4 | |
- name: Parse cargo.toml and assert version tag matching | |
# Hacky way of parsing the version from Cargo.toml and comparing it to tag | |
run: | | |
if [ "$(cat rust-bindings/Cargo.toml | grep version | head -n 1 |awk '{print $3}' | tr -d '"' )" == "${GITHUB_REF#refs/*/}" ];then exit 0; else exit 1; fi | |
publish: | |
needs: [test, version-tag-match] | |
# Ensure master is tagged | |
if: github.event.base_ref == 'refs/heads/master' | |
name: Build & Deploy to registry | |
env: | |
CARGO_REGISTRY_DEFAULT: fulmin-labs-registry | |
CARGO_REGISTRIES_FULMIN_LABS_REGISTRY_INDEX: ${{ secrets.CARGO_REGISTRY_INDEX_URL }} | |
CARGO_REGISTRIES_FULMIN_LABS_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo and submodules | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install Foundry | |
uses: foundry-rs/foundry-toolchain@v1 | |
with: | |
version: nightly | |
- name: Install deps | |
run: forge install | |
- name: Extract Git Tag | |
run: echo "GIT_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | |
- name: Build contract artifacts | |
run: forge build | |
- name: Publish to cargo | |
working-directory: rust-bindings | |
run: cargo publish --registry fulmin-labs-registry |