CI #419
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: | |
push: | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
push-packages: | |
description: 'Push nuget packages' | |
required: true | |
default: false | |
type: boolean | |
use-auto-generated-version: | |
description: 'Use auto-generated version' | |
required: true | |
default: true | |
type: boolean | |
nuget-registry: | |
description: 'NuGet registry' | |
required: true | |
default: 'GitLab' | |
type: choice | |
options: | |
- GitLab | |
- NuGet | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-13, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
3.1.x | |
5.0.x | |
6.0.x | |
7.0.x | |
8.0.x | |
- name: Set Version Suffix | |
shell: bash | |
run: | | |
if [ '${{ github.event.inputs.use-auto-generated-version }}' != 'false' ]; then | |
echo "FlecsVersionSuffix=-dev-$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_ENV | |
fi | |
- name: Setup Osx Environment | |
if: matrix.os == 'macos-13' | |
shell: bash | |
run: | | |
IOS_SDK=$(xcrun --sdk iphoneos --show-sdk-path) | |
IOS_SIMULATOR_SDK=$(xcrun --sdk iphonesimulator --show-sdk-path) | |
echo "IOS_SDK=$IOS_SDK" >> $GITHUB_ENV | |
echo "IOS_SIMULATOR_SDK=$IOS_SIMULATOR_SDK" >> $GITHUB_ENV | |
- name: Restore Dependencies | |
shell: bash | |
run: dotnet restore | |
- name: Generate Bindings | |
shell: bash | |
run: dotnet run --project src/Flecs.NET.Bindgen | |
- name: Build Projects | |
shell: bash | |
run: | | |
if [ '${{ matrix.os }}' == 'macos-13' ]; then | |
dotnet build -c Debug --property:IosSdkPath=$IOS_SDK --property:IosSimulatorSdkPath=$IOS_SIMULATOR_SDK | |
dotnet build -c Release --property:IosSdkPath=$IOS_SDK --property:IosSimulatorSdkPath=$IOS_SIMULATOR_SDK | |
else | |
dotnet build -c Debug | |
dotnet build -c Release | |
fi | |
- name: Run Tests | |
shell: bash | |
run: dotnet test --no-build | |
- name: Pack Nuget Packages | |
shell: bash | |
run: | | |
if [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then | |
dotnet pack --property:FlecsVersionSuffix=$FlecsVersionSuffix -c Debug | |
dotnet pack --property:FlecsVersionSuffix=$FlecsVersionSuffix -c Release | |
else | |
dotnet pack --property:FlecsVersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -c Debug | |
dotnet pack --property:FlecsVersionSuffix=$FlecsVersionSuffix --property:FlecsPackPdb=true -c Release | |
fi | |
- name: Upload Artifacts | |
if: matrix.os == 'macos-13' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Nuget Packages | |
path: | | |
src/**/Flecs.NET.*.nupkg | |
src/**/Flecs.NET.*.snupkg | |
- name: Push NuGet Packages | |
if: matrix.os == 'macos-13' && github.event_name == 'workflow_dispatch' && github.event.inputs.push-packages == 'true' | |
shell: bash | |
run: | | |
if [ '${{ github.event.inputs.nuget-registry }}' == 'GitLab' ]; then | |
dotnet nuget push src/**/Flecs.NET.*.nupkg --api-key '${{ secrets.GITLAB_ACCESS_TOKEN }}' --source 'https://gitlab.com/api/v4/projects/51698729/packages/nuget/index.json' | |
elif [ '${{ github.event.inputs.nuget-registry }}' == 'NuGet' ]; then | |
dotnet nuget push src/**/Flecs.NET.*.nupkg --api-key '${{ secrets.NUGET_ACCESS_TOKEN }}' --source 'https://api.nuget.org/v3/index.json' | |
fi |