|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + branches: |
| 8 | + - main |
| 9 | + pull_request: |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: Swatinem/rust-cache@v2 |
| 20 | + with: |
| 21 | + prefix-key: v1-rust |
| 22 | + shared-key: debug |
| 23 | + cache-all-crates: true |
| 24 | + - name: Setup Rust |
| 25 | + uses: actions-rs/toolchain@v1 |
| 26 | + with: |
| 27 | + toolchain: stable |
| 28 | + override: true |
| 29 | + - name: Check formatting |
| 30 | + run: cargo fmt -- --check |
| 31 | + - name: Clippy |
| 32 | + run: cargo clippy -- -Dwarnings |
| 33 | + - name: Build |
| 34 | + run: cargo build --all-features --all-targets |
| 35 | + test: |
| 36 | + needs: [build] |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v3 |
| 40 | + - uses: Swatinem/rust-cache@v2 |
| 41 | + with: |
| 42 | + prefix-key: v1-rust |
| 43 | + shared-key: debug |
| 44 | + cache-all-crates: false |
| 45 | + - name: Setup Rust |
| 46 | + uses: actions-rs/toolchain@v1 |
| 47 | + with: |
| 48 | + toolchain: stable |
| 49 | + override: true |
| 50 | + - name: Tests |
| 51 | + run: cargo test -- --nocapture --report-time --format junit --logfile target/report.xml |
| 52 | + - name: Publish Test Report |
| 53 | + uses: mikepenz/action-junit-report@v5 |
| 54 | + if: success() || failure() # always run even if the previous step fails |
| 55 | + with: |
| 56 | + report_paths: "**/target/report-*.xml" |
| 57 | + detailed_summary: true |
| 58 | + include_passed: true |
| 59 | + publish: |
| 60 | + needs: [test] |
| 61 | + if: "startsWith(github.ref, 'refs/tags/v')" |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v3 |
| 66 | + with: |
| 67 | + submodules: true |
| 68 | + - name: Setup Rust |
| 69 | + uses: actions-rs/toolchain@v1 |
| 70 | + with: |
| 71 | + toolchain: stable |
| 72 | + override: true |
| 73 | + - name: Install Protoc |
| 74 | + uses: arduino/setup-protoc@v3 |
| 75 | + with: |
| 76 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + - id: get_version |
| 78 | + uses: battila7/get-version-action@v2 |
| 79 | + - name: Publish crates |
| 80 | + env: |
| 81 | + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |
| 82 | + run: | |
| 83 | + export VERSION="${{ steps.get_version.outputs.version-without-v }}" |
| 84 | + sed -i "s/0.0.0/$VERSION/g" Cargo.toml |
| 85 | + cargo publish -p moonbit-component-generator --all-features --allow-dirty |
0 commit comments