|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + tags: |
| 7 | + - '*' |
| 8 | + pull_request: |
| 9 | + branches: [ "main" ] |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Caching objects |
| 23 | + id: cache-objects |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: | |
| 27 | + ~/.cargo |
| 28 | + ${{ github.workspace }}/target |
| 29 | + key: ${{ runner.os }}-rust-objects |
| 30 | + |
| 31 | + - name: Set env RELEASE_VERSION |
| 32 | + run: | |
| 33 | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV |
| 34 | +
|
| 35 | + - name: pre-commit |
| 36 | + run: | |
| 37 | + pip install pre-commit |
| 38 | + pre-commit autoupdate --repo https://github.com/pre-commit/pre-commit-hooks |
| 39 | + pre-commit run --all-files |
| 40 | +
|
| 41 | + - name: Build |
| 42 | + run: cargo build --verbose |
| 43 | + |
| 44 | + - name: Run tests |
| 45 | + run: cargo test --verbose |
| 46 | + |
| 47 | + - name: Code coverage |
| 48 | + run: | |
| 49 | + cargo install cargo-llvm-cov |
| 50 | + # rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu |
| 51 | + cargo llvm-cov |
| 52 | +
|
| 53 | + # - name: Install Miri |
| 54 | + # run: | |
| 55 | + # rustup toolchain install nightly --component miri |
| 56 | + # rustup override set nightly |
| 57 | + # cargo miri setup |
| 58 | + # - name: Test with Miri |
| 59 | + # run: cargo miri test |
| 60 | + |
| 61 | + # Delivery |
| 62 | + - name: Install package handler |
| 63 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 64 | + run: cargo install cargo-deb |
| 65 | + |
| 66 | + - name: Set Cargo.toml version |
| 67 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + mv Cargo.toml Cargo.toml.orig |
| 71 | + sed "s/0\\.0\\.0-git/${{env.RELEASE_VERSION}}/" Cargo.toml.orig >Cargo.toml |
| 72 | + mv Cargo.lock Cargo.lock.orig |
| 73 | + sed "s/0\\.0\\.0-git/${{env.RELEASE_VERSION}}/" Cargo.lock.orig >Cargo.lock |
| 74 | +
|
| 75 | + - name: Create package |
| 76 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 77 | + run: cargo deb |
| 78 | + |
| 79 | + - name: Publish the release |
| 80 | + if: startsWith(github.event.ref, 'refs/tags/') |
| 81 | + uses: softprops/action-gh-release@v1 |
| 82 | + with: |
| 83 | + files: | |
| 84 | + ${{github.workspace}}/target/debian/*.deb |
0 commit comments