Skip to content

Initial content

Initial content #2

Workflow file for this run

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: [ubuntu-latest, macos-latest, windows-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: Configure CMake
working-directory: ${{runner.workspace}}/build
run: cmake $GITHUB_WORKSPACE -G "${{ matrix.cmake_generator }}"
- name: Build
working-directory: ${{runner.workspace}}/build
run: cmake --build . --config Release
- 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)
});
}
}