|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + test: |
| 11 | + name: Test (${{ matrix.os }}) |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, macos-latest] |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + - name: Install Rust stable |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + with: |
| 21 | + components: rustfmt, clippy |
| 22 | + - uses: Swatinem/rust-cache@v2 |
| 23 | + - name: Check formatting |
| 24 | + run: cargo fmt --check |
| 25 | + - name: Clippy |
| 26 | + run: cargo clippy -- -D warnings |
| 27 | + - name: Test |
| 28 | + run: cargo test |
| 29 | + |
| 30 | + build: |
| 31 | + name: Build (${{ matrix.target }}) |
| 32 | + needs: test |
| 33 | + runs-on: ${{ matrix.runner }} |
| 34 | + strategy: |
| 35 | + matrix: |
| 36 | + include: |
| 37 | + - target: aarch64-apple-darwin |
| 38 | + runner: macos-latest |
| 39 | + - target: x86_64-apple-darwin |
| 40 | + runner: macos-13 |
| 41 | + - target: x86_64-unknown-linux-gnu |
| 42 | + runner: ubuntu-latest |
| 43 | + - target: aarch64-unknown-linux-gnu |
| 44 | + runner: ubuntu-24.04-arm |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + - name: Install Rust stable |
| 48 | + uses: dtolnay/rust-toolchain@stable |
| 49 | + with: |
| 50 | + targets: ${{ matrix.target }} |
| 51 | + - uses: Swatinem/rust-cache@v2 |
| 52 | + - name: Build release binary |
| 53 | + run: cargo build --release --target ${{ matrix.target }} |
| 54 | + - name: Rename binary |
| 55 | + run: cp target/${{ matrix.target }}/release/cship cship-${{ matrix.target }} |
| 56 | + - name: Validate binary |
| 57 | + run: | |
| 58 | + file cship-${{ matrix.target }} |
| 59 | + test -s cship-${{ matrix.target }} || { echo "ERROR: binary is empty"; exit 1; } |
| 60 | + - uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: cship-${{ matrix.target }} |
| 63 | + path: cship-${{ matrix.target }} |
| 64 | + |
| 65 | + release: |
| 66 | + name: Publish GitHub Release |
| 67 | + needs: build |
| 68 | + runs-on: ubuntu-latest |
| 69 | + permissions: |
| 70 | + contents: write |
| 71 | + steps: |
| 72 | + - uses: actions/download-artifact@v4 |
| 73 | + - uses: softprops/action-gh-release@v2 |
| 74 | + with: |
| 75 | + files: cship-*/cship-* |
0 commit comments