add ci-cd #1
Workflow file for this run
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| pull_request: {} | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| RUSTFLAGS: -C debuginfo=0 | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Check formatting | |
| run: cargo fmt --all --check | |
| - name: Run Clippy | |
| run: cargo clippy --all -- -D warnings | |
| release_please: | |
| name: Release Management | |
| needs: [check] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create Release | |
| id: release | |
| uses: googleapis/release-please-action@v4 | |
| with: | |
| config-file: .github/release-please-config.json | |
| manifest-file: .github/release-please-manifest.json | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| name: Publish for ${{ matrix.os }} | |
| needs: release_please | |
| if: ${{ needs.release_please.outputs.release_created == 'true' }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-22.04, ubuntu-24.04] | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install dependencies | |
| run: sudo apt-get update && sudo apt-get install -y dh-make | |
| - name: Install cargo-deb | |
| run: cargo install cargo-deb | |
| - name: Build and Package | |
| run: | | |
| cargo deb -v | |
| VERSION="${{ needs.release_please.outputs.tag_name }}" | |
| VERSION=${VERSION#v} | |
| mv target/debian/*.deb "./target/mmt_${VERSION}_amd64_${{ matrix.os }}.deb" | |
| cd target/release | |
| tar -czf "../../target/mmt_${VERSION}_amd64_${{ matrix.os }}.tar.gz" mmt | |
| - name: Upload Release Artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload --clobber ${{ needs.release_please.outputs.tag_name }} \ | |
| ./target/*.deb \ | |
| ./target/*.tar.gz |