.github/workflows/release.yml 2.3 K raw
1
name: Release
2
3
on:
4
  push:
5
    tags:
6
      - "v*"
7
8
permissions:
9
  contents: write
10
11
jobs:
12
  build:
13
    name: Build ${{ matrix.target }}
14
    runs-on: ${{ matrix.os }}
15
    strategy:
16
      matrix:
17
        include:
18
          - target: x86_64-unknown-linux-gnu
19
            os: ubuntu-latest
20
            archive: tar.gz
21
          - target: aarch64-unknown-linux-gnu
22
            os: ubuntu-latest
23
            archive: tar.gz
24
          - target: x86_64-apple-darwin
25
            os: macos-latest
26
            archive: tar.gz
27
          - target: aarch64-apple-darwin
28
            os: macos-latest
29
            archive: tar.gz
30
          - target: x86_64-pc-windows-msvc
31
            os: windows-latest
32
            archive: zip
33
34
    steps:
35
      - uses: actions/checkout@v4
36
37
      - name: Install Rust
38
        uses: dtolnay/rust-toolchain@stable
39
        with:
40
          targets: ${{ matrix.target }}
41
42
      - name: Install cross-compilation tools (Linux aarch64)
43
        if: matrix.target == 'aarch64-unknown-linux-gnu'
44
        run: |
45
          sudo apt-get update
46
          sudo apt-get install -y gcc-aarch64-linux-gnu
47
48
      - name: Configure cross-compilation (Linux aarch64)
49
        if: matrix.target == 'aarch64-unknown-linux-gnu'
50
        run: |
51
          echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
52
          echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
53
54
      - name: Build
55
        run: cargo build --release --target ${{ matrix.target }}
56
57
      - name: Package (Unix)
58
        if: matrix.archive == 'tar.gz'
59
        shell: bash
60
        run: |
61
          BINARY=target/${{ matrix.target }}/release/sipp
62
          ARCHIVE=sipp-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
63
          tar -czf "$ARCHIVE" -C "$(dirname $BINARY)" "$(basename $BINARY)"
64
          echo "ASSET=$ARCHIVE" >> $GITHUB_ENV
65
66
      - name: Package (Windows)
67
        if: matrix.archive == 'zip'
68
        shell: pwsh
69
        run: |
70
          $binary = "target\${{ matrix.target }}\release\sipp.exe"
71
          $archive = "sipp-${{ github.ref_name }}-${{ matrix.target }}.zip"
72
          Compress-Archive -Path $binary -DestinationPath $archive
73
          echo "ASSET=$archive" | Out-File -FilePath $env:GITHUB_ENV -Append
74
75
      - name: Upload to release
76
        uses: softprops/action-gh-release@v2
77
        with:
78
          files: ${{ env.ASSET }}
79
          generate_release_notes: true