wip2 #98
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
workflow_dispatch: # allows manual triggering | |
inputs: | |
create_release: | |
description: 'Create new release' | |
required: true | |
type: boolean | |
push: | |
branches: | |
- master | |
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal'] | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: ['.github/workflows/build.yml', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} | |
cancel-in-progress: true | |
# Fine-grant permission | |
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token | |
permissions: | |
contents: write # for creating release | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
GGML_NLOOP: 3 | |
GGML_N_THREADS: 1 | |
LLAMA_LOG_COLORS: 1 | |
LLAMA_LOG_PREFIX: 1 | |
LLAMA_LOG_TIMESTAMPS: 1 | |
jobs: | |
windows-msys2-cpu-x86_64: | |
runs-on: windows-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [avx, avx2, avx512, amx] | |
include: | |
- { sys: UCRT64, env: ucrt-x86_64, build: Release } | |
- { arch: avx, defines: '-DGGML_AVX=ON -DGGML_AVX2=OFF -DGGML_AVX512=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' } | |
- { arch: avx2, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=OFF -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' } | |
- { arch: avx512, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON -DGGML_AMX_TILE=OFF -DGGML_AMX_INT8=OFF' } | |
- { arch: amx, defines: '-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_AVX512=ON -DGGML_AMX_TILE=ON -DGGML_AMX_INT8=ON' } | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
- name: Setup ${{ matrix.sys }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
msystem: ${{matrix.sys}} | |
install: >- | |
base-devel | |
mingw-w64-${{matrix.env}}-toolchain | |
mingw-w64-${{matrix.env}}-cmake | |
mingw-w64-${{matrix.env}}-ninja | |
mingw-w64-${{matrix.env}}-curl | |
- name: Configure | |
shell: msys2 {0} | |
run: | | |
cmake -B build -G "Ninja Multi-Config" -DLLAMA_CURL=ON -DGGML_NATIVE=OFF -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON \ | |
${{ matrix.defines }} | |
- name: Build using CMake | |
shell: msys2 {0} | |
run: | | |
cmake --build build --config ${{ matrix.build }} -t ggml-cpu | |
- name: Rename artifacts | |
run: mv build/bin/Release/ggml-cpu.dll ggml-cpu-${{ matrix.arch }}.dll | |
- name: Upload artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ggml-cpu-${{ matrix.arch }}.dll | |
name: ggml-cpu-${{ matrix.arch }}.dll | |
windows-msys2-x86_64: | |
runs-on: windows-latest | |
needs: | |
- windows-msys2-cpu-x86_64 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- { sys: UCRT64, env: ucrt-x86_64, build: Release } | |
steps: | |
- name: Clone | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup ${{ matrix.sys }} | |
uses: msys2/setup-msys2@v2 | |
with: | |
update: true | |
msystem: ${{matrix.sys}} | |
install: >- | |
base-devel | |
mingw-w64-${{matrix.env}}-toolchain | |
mingw-w64-${{matrix.env}}-cmake | |
mingw-w64-${{matrix.env}}-ninja | |
- name: Build using CMake | |
shell: msys2 {0} | |
run: | | |
cmake -B build -G "Ninja Multi-Config" -DBUILD_SHARED_LIBS=ON -DGGML_BACKEND_DL=ON | |
cmake --build build --config ${{ matrix.build }} | |
rm build/bin/Release/ggml-cpu.dll | |
- name: Download CPU artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: 'ggml-cpu-*.dll' | |
path: build/bin/Release | |
- name: Determine tag name | |
id: tag | |
shell: bash | |
run: | | |
BUILD_NUMBER="$(git rev-list --count HEAD)" | |
SHORT_HASH="$(git rev-parse --short=7 HEAD)" | |
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then | |
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT | |
else | |
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') | |
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT | |
fi | |
- name: Pack artifacts | |
id: pack_artifacts | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
run: | | |
Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt | |
7z a llama-${{ steps.tag.outputs.name }}-bin-msys2-cpu-${{ matrix.build }}.zip .\build\bin\Release\* | |
release: | |
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} | |
runs-on: ubuntu-latest | |
needs: | |
- windows-msys2-x86_64 | |
steps: | |
- name: Clone | |
id: checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Determine tag name | |
id: tag | |
shell: bash | |
run: | | |
BUILD_NUMBER="$(git rev-list --count HEAD)" | |
SHORT_HASH="$(git rev-parse --short=7 HEAD)" | |
if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then | |
echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT | |
else | |
SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-') | |
echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT | |
fi | |
- name: Download artifacts | |
id: download-artifact | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifact | |
- name: Move artifacts | |
id: move_artifacts | |
run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release | |
- name: Create release | |
id: create_release | |
uses: anzz1/action-create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.name }} | |
- name: Upload release | |
id: upload_release | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const path = require('path'); | |
const fs = require('fs'); | |
const release_id = '${{ steps.create_release.outputs.id }}'; | |
for (let file of await fs.readdirSync('./artifact/release')) { | |
if (path.extname(file) === '.zip') { | |
console.log('uploadReleaseAsset', file); | |
await github.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release_id, | |
name: file, | |
data: await fs.readFileSync(`./artifact/release/${file}`) | |
}); | |
} | |
} | |