|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "main" |
| 6 | + tags: |
| 7 | + - "v*" |
| 8 | +env: |
| 9 | + CRATE_NAME: coman |
| 10 | + GITHUB_TOKEN: ${{ github.token }} |
| 11 | + RUST_BACKTRACE: 1 |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + name: Release - ${{ matrix.platform.os_name }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + platform: |
| 18 | + - os_name: Linux-x86_64 |
| 19 | + os: ubuntu-latest |
| 20 | + target: x86_64-unknown-linux-musl |
| 21 | + bin: coman |
| 22 | + name: coman-Linux-x86_64-musl.tar.gz |
| 23 | + cargo_command: cargo |
| 24 | + |
| 25 | + - os_name: Windows-aarch64 |
| 26 | + os: windows-latest |
| 27 | + target: aarch64-pc-windows-msvc |
| 28 | + bin: coman.exe |
| 29 | + name: coman-Windows-aarch64.zip |
| 30 | + cargo_command: cargo |
| 31 | + |
| 32 | + - os_name: macOS-x86_64 |
| 33 | + os: macOS-latest |
| 34 | + target: x86_64-apple-darwin |
| 35 | + bin: coman |
| 36 | + name: coman-Darwin-x86_64.tar.gz |
| 37 | + cargo_command: cargo |
| 38 | + |
| 39 | + runs-on: ${{ matrix.platform.os }} |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v5 |
| 43 | + - name: Install toolchain |
| 44 | + uses: dtolnay/rust-toolchain@stable |
| 45 | + with: |
| 46 | + targets: ${{ matrix.platform.target }} |
| 47 | + - name: Install musl-tools on Linux |
| 48 | + run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools |
| 49 | + if: contains(matrix.platform.os, 'ubuntu') |
| 50 | + - name: Build binary (*nix) |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} |
| 54 | + if: ${{ !contains(matrix.platform.os, 'windows') }} |
| 55 | + - name: Build binary (Windows) |
| 56 | + # We have to use the platform's native shell. If we use bash on |
| 57 | + # Windows then OpenSSL complains that the Perl it finds doesn't use |
| 58 | + # the platform's native paths and refuses to build. |
| 59 | + shell: powershell |
| 60 | + run: | |
| 61 | + & ${{ matrix.platform.cargo_command }} build --locked --release --target ${{ matrix.platform.target }} |
| 62 | + if: contains(matrix.platform.os, 'windows') |
| 63 | + - name: Strip binary |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} |
| 67 | + if: ${{ !( matrix.platform.target == 'aarch64-pc-windows-msvc') }} |
| 68 | + - name: Package as archive |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + cd target/${{ matrix.platform.target }}/release |
| 72 | + if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then |
| 73 | + 7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} |
| 74 | + else |
| 75 | + tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} |
| 76 | + fi |
| 77 | + cd - |
| 78 | + - name: Publish GitHub release |
| 79 | + uses: softprops/action-gh-release@v1 |
| 80 | + with: |
| 81 | + draft: true |
| 82 | + files: "coman*" |
| 83 | + body_path: Changes.md |
| 84 | + if: startsWith( github.ref, 'refs/tags/v' ) |
0 commit comments