Skip to content

fix: fetch full git history in release workflow for git-cliff #12

fix: fetch full git history in release workflow for git-cliff

fix: fetch full git history in release workflow for git-cliff #12

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*.*.*'
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-24.04
env:
BLAS_INCLUDE_DIRS: /usr/include/x86_64-linux-gnu
OPENBLAS_PATH: /usr
ORT_STRATEGY: system
ORT_LIB_LOCATION: /usr/local/lib
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for git-cliff to access previous tags
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
portaudio19-dev \
libclang-dev \
pkg-config \
libxkbcommon-dev \
libwayland-dev \
libx11-dev \
libxcursor-dev \
libxi-dev \
libxrandr-dev \
libasound2-dev \
libssl-dev \
libfftw3-dev \
curl \
cmake \
libvulkan-dev \
libopenblas-dev \
glslc
- name: Install ONNX Runtime
run: |
ONNX_VERSION=1.20.0
wget https://github.com/microsoft/onnxruntime/releases/download/v${ONNX_VERSION}/onnxruntime-linux-x64-${ONNX_VERSION}.tgz
tar -xzf onnxruntime-linux-x64-${ONNX_VERSION}.tgz
sudo cp -r onnxruntime-linux-x64-${ONNX_VERSION}/include/* /usr/local/include/
sudo cp -r onnxruntime-linux-x64-${ONNX_VERSION}/lib/* /usr/local/lib/
sudo ldconfig
- name: Install git-cliff
run: |
wget https://github.com/orhun/git-cliff/releases/download/v2.7.0/git-cliff-2.7.0-x86_64-unknown-linux-gnu.tar.gz
tar -xzf git-cliff-2.7.0-x86_64-unknown-linux-gnu.tar.gz
sudo mv git-cliff-2.7.0/git-cliff /usr/local/bin/
git-cliff --version
- name: Build release binary
run: cargo build --release --verbose
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create release tarball
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
ARCHIVE_NAME="sonori-${VERSION}-x86_64-linux"
mkdir -p "${ARCHIVE_NAME}"
cp target/release/sonori "${ARCHIVE_NAME}/"
cp README.md LICENSE CONFIGURATION.md "${ARCHIVE_NAME}/"
tar -czf "${ARCHIVE_NAME}.tar.gz" "${ARCHIVE_NAME}"
echo "ARCHIVE_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
- name: Generate release notes
id: release_notes
run: |
VERSION=${{ steps.get_version.outputs.VERSION }}
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
# Generate changelog using git-cliff
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git-cliff --strip all ${PREV_TAG}..HEAD)
else
CHANGELOG=$(git-cliff --strip all HEAD)
fi
# Build release notes
{
echo "RELEASE_NOTES<<EOF"
echo "## Sonori v${VERSION}"
echo ""
echo "### Installation"
echo ""
echo "**NixOS (Recommended):**"
echo '```bash'
echo "nix run github:0xPD33/sonori"
echo "# or"
echo "nix profile install github:0xPD33/sonori"
echo '```'
echo ""
echo "**From Release Tarball:**"
echo "1. Download \`sonori-${VERSION}-x86_64-linux.tar.gz\`"
echo "2. Extract: \`tar -xzf sonori-${VERSION}-x86_64-linux.tar.gz\`"
echo "3. Run: \`./sonori-${VERSION}-x86_64-linux/sonori\`"
echo ""
echo "See README.md for building from source on other distributions."
echo ""
echo "### Changes"
echo ""
echo "${CHANGELOG}"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.ARCHIVE_NAME }}.tar.gz
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}