|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: ["v*"] |
| 7 | + pull_request: |
| 8 | + branches: [main] |
| 9 | + |
| 10 | +env: |
| 11 | + CARGO_TERM_COLOR: always |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint: |
| 15 | + name: Lint & Format |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + - uses: dtolnay/rust-toolchain@stable |
| 20 | + with: |
| 21 | + components: clippy, rustfmt |
| 22 | + - uses: Swatinem/rust-cache@v2 |
| 23 | + - run: cargo fmt --check |
| 24 | + - run: cargo clippy -- -D warnings |
| 25 | + |
| 26 | + test: |
| 27 | + name: Test |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - uses: dtolnay/rust-toolchain@stable |
| 32 | + - uses: Swatinem/rust-cache@v2 |
| 33 | + - run: cargo test |
| 34 | + |
| 35 | + build: |
| 36 | + name: Build (${{ matrix.name }}) |
| 37 | + needs: [lint, test] |
| 38 | + runs-on: ${{ matrix.runner }} |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + include: |
| 42 | + - name: linux-x86_64 |
| 43 | + runner: ubuntu-latest |
| 44 | + target: x86_64-unknown-linux-gnu |
| 45 | + artifact: ptywrap-linux-x86_64 |
| 46 | + - name: linux-arm64 |
| 47 | + runner: ubuntu-24.04-arm |
| 48 | + target: aarch64-unknown-linux-gnu |
| 49 | + artifact: ptywrap-linux-arm64 |
| 50 | + - name: macos-arm64 |
| 51 | + runner: macos-14 |
| 52 | + target: aarch64-apple-darwin |
| 53 | + artifact: ptywrap-macos-arm64 |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + - uses: dtolnay/rust-toolchain@stable |
| 57 | + - uses: Swatinem/rust-cache@v2 |
| 58 | + with: |
| 59 | + key: ${{ matrix.target }} |
| 60 | + - run: cargo build --release |
| 61 | + - uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: ${{ matrix.artifact }} |
| 64 | + path: target/release/ptywrap |
| 65 | + |
| 66 | + release: |
| 67 | + name: Release |
| 68 | + if: startsWith(github.ref, 'refs/tags/v') |
| 69 | + needs: [build] |
| 70 | + runs-on: ubuntu-latest |
| 71 | + permissions: |
| 72 | + contents: write |
| 73 | + steps: |
| 74 | + - uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + path: artifacts |
| 77 | + |
| 78 | + - name: Prepare release assets |
| 79 | + run: | |
| 80 | + for dir in artifacts/ptywrap-*; do |
| 81 | + name=$(basename "$dir") |
| 82 | + chmod +x "$dir/ptywrap" |
| 83 | + tar -czf "${name}.tar.gz" -C "$dir" ptywrap |
| 84 | + shasum -a 256 "${name}.tar.gz" >> checksums.txt |
| 85 | + done |
| 86 | +
|
| 87 | + - uses: softprops/action-gh-release@v2 |
| 88 | + with: |
| 89 | + files: | |
| 90 | + ptywrap-*.tar.gz |
| 91 | + checksums.txt |
| 92 | + generate_release_notes: true |
0 commit comments