diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fec17ad..d6b11b9 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,15 +1,53 @@ name: Rust -on: [push] +on: + push: + release: + types: [created] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always jobs: build: - - runs-on: ubuntu-latest + name: Build Rust with Cargo + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + rust: [stable, nightly] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true - name: Build run: cargo build --verbose + - name: Build examples + run: cargo build --examples --verbose - name: Run tests run: cargo test --verbose + + build_success: + name: Build Rust with Cargo - All environments + runs-on: ubuntu-latest + needs: build + steps: + - run: echo Done! + + publish: + name: Publish tagged release on crates.io + if: github.event_name == 'release' && github.event.action == 'created' + needs: + - build_success + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: katyo/publish-crates@v1 + with: + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}