|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + # act -P ubuntu-latest=-self-hosted -j release --matrix os:ubuntu-latest |
| 10 | + release: |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + include: |
| 14 | + # - os: ubuntu-latest |
| 15 | + - os: ubuntu-24.04 |
| 16 | + target: x86_64-unknown-linux-gnu |
| 17 | + bin: cargo-neat |
| 18 | + - os: ubuntu-24.04-arm |
| 19 | + target: aarch64-unknown-linux-gnu |
| 20 | + bin: cargo-neat |
| 21 | + - os: windows-2022 |
| 22 | + target: x86_64-pc-windows-msvc |
| 23 | + bin: cargo-neat.exe |
| 24 | + - os: macos-14 |
| 25 | + target: x86_64-apple-darwin |
| 26 | + bin: cargo-neat |
| 27 | + - os: macos-14 |
| 28 | + target: aarch64-apple-darwin |
| 29 | + bin: cargo-neat |
| 30 | + runs-on: ${{ matrix.os }} |
| 31 | + permissions: |
| 32 | + contents: write |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v6 |
| 35 | + - uses: dtolnay/rust-toolchain@stable |
| 36 | + with: |
| 37 | + toolchain: stable |
| 38 | + target: ${{ matrix.target }} |
| 39 | + - name: Release build |
| 40 | + run: cargo build --release --target ${{ matrix.target }} --features=openssl |
| 41 | + - name: Package |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + name=cargo-neat |
| 45 | + tag=$(git describe --tags --abbrev=0) |
| 46 | + release_name="$name-$tag-${{ matrix.target }}" |
| 47 | + release_tar="${release_name}.tar.gz" |
| 48 | + mkdir "$release_name" |
| 49 | + if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then |
| 50 | + strip "target/${{ matrix.target }}/release/${{ matrix.bin }}" |
| 51 | + fi |
| 52 | + cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/" |
| 53 | + cp README.md LICENSE-* "$release_name/" |
| 54 | + tar czvf "$release_tar" "$release_name" |
| 55 | + rm -r "$release_name" |
| 56 | + # Windows environments in github actions don't have the gnu coreutils installed, |
| 57 | + # which includes the shasum exe, so we just use powershell instead |
| 58 | + if [ "${{ matrix.target }}" == "x86_64-pc-windows-msvc" ]; then |
| 59 | + echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c - |
| 60 | + else |
| 61 | + echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" |
| 62 | + fi |
| 63 | + - name: Publish |
| 64 | + uses: softprops/action-gh-release@v2 |
| 65 | + with: |
| 66 | + files: "cargo-neat*" |
0 commit comments