Merge pull request #1 from locaal-ai/roy.initial_content #7
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 and Release | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- 'v*' | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: ${{ matrix.os }}-build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest] # ubuntu-latest, macos-latest, | |
include: | |
- os: ubuntu-latest | |
cmake_generator: "Unix Makefiles" | |
- os: macos-latest | |
cmake_generator: "Unix Makefiles" | |
- os: windows-latest | |
cmake_generator: "Visual Studio 17 2022" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Create Build Environment | |
run: cmake -E make_directory ${{runner.workspace}}/build | |
- name: Run Build Script Windows | |
if: matrix.os == 'windows-latest' | |
working-directory: ${{runner.workspace}} | |
run: ./scripts/build-windows.ps1 | |
shell: pwsh | |
- name: Run Build Script Linux and MacOS | |
if: matrix.os != 'windows-latest' | |
working-directory: ${{runner.workspace}} | |
run: ./scripts/build-nix.sh | |
shell: bash | |
- name: Package | |
working-directory: ${{runner.workspace}}/build | |
run: | | |
cmake --install . --prefix installed | |
7z a ${{ matrix.os }}-package.zip ./installed/* | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-package | |
path: ${{runner.workspace}}/build/${{ matrix.os }}-package.zip | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Assets | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const fs = require('fs').promises; | |
const { repo: { owner, repo }, sha } = context; | |
for (const file of await fs.readdir('.')) { | |
if (file.endsWith('-package')) { | |
const path = `${file}/${file}.zip`; | |
console.log(`Uploading ${path}`); | |
await github.repos.uploadReleaseAsset({ | |
owner, | |
repo, | |
release_id: ${{ steps.create_release.outputs.id }}, | |
name: `${file}.zip`, | |
data: await fs.readFile(path) | |
}); | |
} | |
} |