chore: add packaging metadata and fix release asset collisions #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: linux | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| artifact_name: macos | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: windows | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Build Binary | |
| run: cargo build --release --target ${{ matrix.target }} | |
| - name: Package Linux (DEB & RPM) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cargo install cargo-deb cargo-generate-rpm | |
| cargo deb --target ${{ matrix.target }} --no-build | |
| cargo generate-rpm --target ${{ matrix.target }} | |
| cp target/${{ matrix.target }}/debian/*.deb image-diff.deb | |
| cp target/${{ matrix.target }}/generate-rpm/*.rpm image-diff.rpm | |
| - name: Prepare Windows | |
| if: matrix.os == 'windows-latest' | |
| run: cp target/${{ matrix.target }}/release/image-diff.exe image-diff-windows.exe | |
| - name: Prepare macOS | |
| if: matrix.os == 'macos-latest' | |
| run: cp target/${{ matrix.target }}/release/image-diff image-diff-macos | |
| - name: Prepare Linux Binary | |
| if: matrix.os == 'ubuntu-latest' | |
| run: cp target/${{ matrix.target }}/release/image-diff image-diff-linux | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }}-artifacts | |
| path: | | |
| image-diff.deb | |
| image-diff.rpm | |
| image-diff-linux | |
| image-diff-windows.exe | |
| image-diff-macos | |
| if-no-files-found: ignore | |
| release: | |
| name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/linux-artifacts/image-diff.deb | |
| artifacts/linux-artifacts/image-diff.rpm | |
| artifacts/linux-artifacts/image-diff-linux | |
| artifacts/windows-artifacts/image-diff-windows.exe | |
| artifacts/macos-artifacts/image-diff-macos | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |