name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
build-release:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: datalab
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
artifact: datalab
- os: macos-latest
target: x86_64-apple-darwin
artifact: datalab
- os: macos-latest
target: aarch64-apple-darwin
artifact: datalab
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: datalab.exe
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl-tools (Linux musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Create archive (Unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar -czvf ../../../datalab-${{ matrix.target }}.tar.gz ${{ matrix.artifact }}
- name: Create archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path ${{ matrix.artifact }} -DestinationPath ../../../datalab-${{ matrix.target }}.zip
- name: Upload artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: datalab-${{ matrix.target }}
path: datalab-${{ matrix.target }}.tar.gz
- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: datalab-${{ matrix.target }}
path: datalab-${{ matrix.target }}.zip
create-release:
name: Create Release
needs: build-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create checksums
run: |
cd artifacts
find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} . \;
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/SHA256SUMS.txt
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-') }}
publish-crates:
name: Publish to crates.io
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}