Files
llamactl/.github/workflows/release.yaml

211 lines
5.9 KiB
YAML

name: Build and Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build-webui:
name: Build Web UI
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
cache-dependency-path: "./webui/package-lock.json"
- name: Install dependencies
run: |
cd webui
npm ci
- name: Build Web UI
env:
VITE_APP_VERSION: ${{ github.ref_name }}
run: |
cd webui
npm run build
- name: Upload Web UI artifacts
uses: actions/upload-artifact@v4
with:
name: webui-dist
path: webui/dist/
retention-days: 1
build:
name: Build Binaries
needs: build-webui
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- goos: linux
goarch: amd64
runner: ubuntu-latest
- goos: linux
goarch: arm64
runner: ubuntu-latest
cc: aarch64-linux-gnu-gcc
- goos: darwin
goarch: arm64
runner: macos-latest
- goos: windows
goarch: amd64
runner: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"
cache: true
- name: Download Web UI artifacts
uses: actions/download-artifact@v4
with:
name: webui-dist
path: webui/dist/
- name: Install cross-compilation tools (Linux ARM64 only)
if: matrix.cc != ''
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary (Unix)
if: matrix.goos != 'windows'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
CC: ${{ matrix.cc }}
shell: bash
run: |
# Build the binary
go build -ldflags="-s -w -X main.version=${{ github.ref_name }} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o llamactl ./cmd/server
# Create archive
ARCHIVE_OS="${{ matrix.goos }}"
if [ "${{ matrix.goos }}" = "darwin" ]; then
ARCHIVE_OS="macos"
fi
ARCHIVE_NAME="llamactl-${{ github.ref_name }}-${ARCHIVE_OS}-${{ matrix.goarch }}"
tar -czf "${ARCHIVE_NAME}.tar.gz" llamactl
echo "ASSET_PATH=${ARCHIVE_NAME}.tar.gz" >> $GITHUB_ENV
echo "ASSET_NAME=${ARCHIVE_NAME}" >> $GITHUB_ENV
- name: Build binary (Windows)
if: matrix.goos == 'windows'
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 1
shell: pwsh
run: |
# Build the binary
$version = "${{ github.ref_name }}"
$commit = "${{ github.sha }}"
$date = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
$ldflags = "-s -w -X main.version=$version -X main.commit=$commit -X main.date=$date"
go build -ldflags="$ldflags" -o llamactl.exe ./cmd/server
# Create archive
$archiveName = "llamactl-${{ github.ref_name }}-windows-${{ matrix.goarch }}"
Compress-Archive -Path llamactl.exe -DestinationPath "$archiveName.zip"
echo "ASSET_PATH=$archiveName.zip" >> $env:GITHUB_ENV
echo "ASSET_NAME=$archiveName" >> $env:GITHUB_ENV
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: llamactl-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
*.tar.gz
*.zip
retention-days: 1
release:
name: Create Release
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts/ -name "*.tar.gz" -o -name "*.zip" | while read file; do
cp "$file" release-assets/
done
ls -la release-assets/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: Release ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
files: release-assets/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
checksums:
name: Generate Checksums
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Prepare assets and generate checksums
run: |
mkdir -p assets
# Copy all archives to assets directory
find artifacts/ -name "*.tar.gz" -o -name "*.zip" | while read file; do
cp "$file" assets/
done
# List what we have
echo "Files found:"
ls -la assets/
# Generate checksums if we have files
cd assets
if [ "$(ls -A .)" ]; then
sha256sum * > checksums.txt
echo "Generated checksums:"
cat checksums.txt
else
echo "No files found to checksum"
exit 1
fi
- name: Upload checksums to release
uses: softprops/action-gh-release@v2
with:
files: assets/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}