name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build-and-release:
name: Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: lensight-linux-x86_64
- os: macos-latest
target: x86_64-apple-darwin
artifact_name: lensight-macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact_name: lensight-macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: lensight-windows-x86_64.exe
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
env:
CARGO_TERM_COLOR: always
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: target/${{ matrix.target }}/release/lensight${{ matrix.os == 'windows-latest' && '.exe' || '' }}
create-release:
name: Create Release
needs: build-and-release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
lensight-linux-x86_64
lensight-macos-x86_64
lensight-macos-aarch64
lensight-windows-x86_64.exe
generate_release_notes: true
draft: false
prerelease: false
publish-crate:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}