name: Release
on:
push:
tags:
- 'v*'
jobs:
support-target-check:
name: Check ${{ matrix.target }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-linux-android
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 with:
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
- name: Add target
run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: support-${{ matrix.target }}
- name: Check target
run: cargo check --workspace --target ${{ matrix.target }}
build:
name: Build ${{ matrix.target }}
needs: support-target-check
runs-on: ${{ matrix.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7 with:
targets: ${{ matrix.target }}
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Install cross-compilation tools (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure cross-compilation (Linux ARM64)
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 with:
key: ${{ matrix.target }}
- name: Build
run: cargo build --release --features self-update --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../sabiql-${{ matrix.target }}.tar.gz sabiql
cd ../../..
- name: Package (Windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path sabiql.exe -DestinationPath ../../../sabiql-${{ matrix.target }}.zip
cd ../../..
- name: Generate checksum (Unix)
if: runner.os != 'Windows'
run: |
if [ "${{ matrix.archive }}" = "tar.gz" ]; then
shasum -a 256 sabiql-${{ matrix.target }}.tar.gz > sabiql-${{ matrix.target }}.tar.gz.sha256
fi
- name: Generate checksum (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$hash = (Get-FileHash -Algorithm SHA256 sabiql-${{ matrix.target }}.zip).Hash.ToLower()
"$hash sabiql-${{ matrix.target }}.zip" | Out-File -Encoding ASCII sabiql-${{ matrix.target }}.zip.sha256
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 with:
name: sabiql-${{ matrix.target }}
path: |
sabiql-${{ matrix.target }}.${{ matrix.archive }}
sabiql-${{ matrix.target }}.${{ matrix.archive }}.sha256
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Download all artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 with:
path: artifacts
- name: Upload assets and publish release
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 with:
files: |
artifacts/**/*.tar.gz
artifacts/**/*.zip
artifacts/**/*.sha256
draft: false
publish-crate:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@631a55b12751854ce901bb631d5902ceb48146f7
- name: Publish workspace crates to crates.io
run: |
for crate in src/domain src/app src/infra src/ui .; do
cargo publish --manifest-path "$crate/Cargo.toml"
if [ "$crate" != "." ]; then
sleep 30
fi
done
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}