name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
gh release create ${{ github.ref_name }} \
--title "${{ github.ref_name }}" \
--notes "Release ${{ github.ref_name }}" \
--target ${{ github.sha }}
build-release:
name: Build Release
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: image-collage
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
binary: image-collage.exe
archive: zip
- os: macos-latest
target: x86_64-apple-darwin
binary: image-collage
archive: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
binary: image-collage
archive: tar.gz
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (tar.gz)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../image-collage-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ${{ matrix.binary }}
- name: Package (zip)
if: matrix.archive == 'zip'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../image-collage-${{ github.ref_name }}-${{ matrix.target }}.zip ${{ matrix.binary }}
- name: Upload Release Asset
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: gh release upload ${{ github.ref_name }} ./image-collage-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive }} --clobber
publish-crate:
name: Publish to crates.io
needs: build-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
run: cargo publish --token $CARGO_REGISTRY_TOKEN