Skip to content

test: add ChatRequestParsingTests for tool_calls index mapping (#93) #59

test: add ChatRequestParsingTests for tool_calls index mapping (#93)

test: add ChatRequestParsingTests for tool_calls index mapping (#93) #59

Workflow file for this run

name: Release
# Auto-release on every push to main (like llama.cpp)
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create new release'
required: true
type: boolean
push:
branches:
- main
paths:
- '**/*.swift'
- '**/*.c'
- '**/*.cpp'
- '**/*.h'
- '**/*.hpp'
- '**/*.m'
- '**/*.mm'
- '**/*.metal'
- 'Package.swift'
- 'Package.resolved'
- '.github/workflows/release.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build-and-release:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for build number
submodules: recursive
- name: Install Metal Toolchain
run: xcodebuild -downloadComponent MetalToolchain || true
- name: Determine tag name
id: tag
run: |
BUILD_NUMBER="$(git rev-list --count HEAD)"
SHORT_HASH="$(git rev-parse --short=7 HEAD)"
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
echo "full=b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
echo "Build: b${BUILD_NUMBER} (${SHORT_HASH})"
- name: Generate changelog
id: changelog
run: |
# Find the previous release tag
PREV_TAG=$(git tag --sort=-creatordate | head -1 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
# First release — all commits
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges -20)
else
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (%h)" --no-merges)
fi
# Write to file (multi-line safe)
echo "$CHANGELOG" > /tmp/changelog.txt
echo "Generated changelog with $(echo "$CHANGELOG" | wc -l | tr -d ' ') entries"
- name: Cache Swift packages
uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-release-${{ hashFiles('Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-release-
- name: Build (Release)
run: |
swift package resolve
swift build -c release
- name: Install MLX Metal library
run: |
python3 -m venv /tmp/mlx_venv
/tmp/mlx_venv/bin/pip install --quiet mlx
MLX_LIB=$(find /tmp/mlx_venv -name "mlx.metallib" | head -n 1)
cp "$MLX_LIB" .build/release/mlx.metallib
- name: Verify binary
run: |
ls -lh .build/release/SwiftLM
file .build/release/SwiftLM
.build/release/SwiftLM --help || true
- name: Package binary
run: |
mkdir -p release
cp .build/release/SwiftLM release/
cp .build/release/mlx.metallib release/
cp LICENSE README.md release/
cd release
# Verify the tarball will be self-contained before archiving
ls -lh
tar -czvf ../SwiftLM-${{ steps.tag.outputs.name }}-macos-arm64.tar.gz .
- name: Build macOS DMG Wrapper
run: |
cd SwiftBuddy && python3 generate_xcodeproj.py
cd ..
xcodebuild clean build \
-project SwiftBuddy/SwiftBuddy.xcodeproj \
-scheme SwiftBuddy \
-destination "generic/platform=macOS" \
-configuration Release \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_ENTITLEMENTS="" \
CODE_SIGNING_ALLOWED=NO \
TARGET_BUILD_DIR="$RUNNER_TEMP/build" \
BUILT_PRODUCTS_DIR="$RUNNER_TEMP/build"
brew install create-dmg
chmod +x scripts/build_dmg.sh
./scripts/build_dmg.sh "$RUNNER_TEMP/build/SwiftBuddy.app"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: SwiftLM-${{ steps.tag.outputs.name }}-macos-arm64
path: SwiftLM-${{ steps.tag.outputs.name }}-macos-arm64.tar.gz
retention-days: 90
- name: Prepare release notes
id: notes
run: |
CHANGELOG=$(cat /tmp/changelog.txt)
cat > /tmp/release_notes.md << 'RELEASE_EOF'
## SwiftLM ${{ steps.tag.outputs.full }}
<details open>
${{ github.event.head_commit.message }}
</details>
### Changelog
RELEASE_EOF
cat /tmp/changelog.txt >> /tmp/release_notes.md
cat >> /tmp/release_notes.md << 'RELEASE_EOF'
### Download
- **CLI Server**: [macOS Apple Silicon (arm64)](https://github.com/SharpAI/SwiftLM/releases/download/${{ steps.tag.outputs.name }}/SwiftLM-${{ steps.tag.outputs.name }}-macos-arm64.tar.gz)
- **GUI Desktop App**: Download the attached `SwiftBuddy-macOS.dmg` below!
### Quick Start
**For GUI Users (SwiftBuddy)**:
1. Download the attached DMG and open it.
2. Drag `SwiftBuddy.app` into your Applications folder natively or run directly.
3. When launched, click "Model Options" to select or download an MLX local model to chat with.
**For CLI Users (SwiftLM)**:
Please refer to the [Getting Started](https://github.com/SharpAI/SwiftLM#getting-started) section in the README.
> **Note:** `mlx.metallib` is bundled in the tar archive. Keep it in the same directory as the `SwiftLM` binary — Metal GPU compute will fail if it is missing.
RELEASE_EOF
- name: Create release
if: ${{ github.event_name == 'push' || github.event.inputs.create_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.name }}
name: "SwiftLM ${{ steps.tag.outputs.name }}"
body_path: /tmp/release_notes.md
files: |
SwiftLM-${{ steps.tag.outputs.name }}-macos-arm64.tar.gz
output/*.dmg
draft: false
prerelease: false