Fixed cargo packages #349
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: Cargo build and test | |
on: | |
push: | |
branches: [ develop, main, release/**, hotfix/** ] | |
pull_request: | |
branches: [ develop, main, release/**, hotfix/** ] | |
jobs: | |
build_and_test: | |
name: Build and test Stellar SDK | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: crusty-pie/toolchain@v1 | |
with: | |
toolchain: stable | |
targets: x86_64-unknown-linux-musl | |
override: true | |
components: llvm-tools-preview | |
- name: Download grcov | |
run: | | |
mkdir -p "${HOME}/.local/bin" | |
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.10/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: cargo update | |
run: cargo update | |
- name: cargo test | |
run: | | |
mkdir -p ./coverage | |
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test | |
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o ./coverage/tests.lcov | |
- name: Check test coverage | |
uses: tluijken/code-coverage-threshold@v1 | |
with: | |
coverage-file: ./coverage/tests.lcov | |
minimum-coverage: 90 | |
publish_to_crates_io: | |
name: "Publish to crates.io" | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
- name: "Overwrite version numbers" | |
run: | | |
awk '{gsub(/version = "0.1.0"/, "version = \"'$GitVersion_SemVer'\"")}1' stellar_rust_sdk/Cargo.toml > stellar_rust_sdk/Cargo.tmp && mv stellar_rust_sdk/Cargo.tmp stellar_rust_sdk/Cargo.toml | |
awk '{gsub(/version = "0.1.0"/, "version = \"'$GitVersion_SemVer'\"")}1' stellar_rust_sdk_derive/Cargo.toml > stellar_rust_sdk_derive/Cargo.tmp && mv stellar_rust_sdk_derive/Cargo.tmp stellar_rust_sdk_derive/Cargo.toml | |
- name: Publish to crates.io | |
run: | | |
cargo publish --token ${CRATES_TOKEN} --allow-dirty --manifest-path=stellar_rust_sdk_derive/Cargo.toml && \ | |
cargo publish --token ${CRATES_TOKEN} --allow-dirty --manifest-path=stellar_rust_sdk/Cargo.toml | |
env: | |
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |