Continuous Integration #461
This file contains hidden or 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: "Continuous Integration" | |
on: | |
push: | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.gitignore' | |
- '**/*.gitattributes' | |
pull_request: | |
paths-ignore: | |
- '**/*.md' | |
- '**/*.gitignore' | |
- '**/*.gitattributes' | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version (e.g. 1.2.3)' | |
required: true | |
release_notes: | |
description: 'Release Notes' | |
required: false | |
deploy_to_nuget: | |
description: 'Publish to nuget? (yes/no)' | |
required: true | |
default: 'no' | |
jobs: | |
# Building & Testing | |
build: | |
name: Build Arch | |
runs-on: ubuntu-latest | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
DOTNET_NOLOGO: true | |
DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false | |
DOTNET_MULTILEVEL_LOOKUP: 0 | |
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true | |
TERM: xterm | |
strategy: | |
matrix: | |
configuration: [Debug, Release] | |
define: [Default, Events, PureECS] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
# Setting up .net | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
8.0.x | |
# Build the project with defines | |
- name: Build project | |
run: | | |
dotnet build src/Arch/Arch.csproj --configuration ${{ matrix.configuration }} --framework net8.0 -p:DefineConstants="${{ matrix.define }}" | |
# Run tests | |
- name: Run tests | |
run: | | |
dotnet test src/Arch.Tests/Arch.Tests.csproj --configuration ${{ matrix.configuration }} --framework net8.0 -p:DefineConstants="${{ matrix.define }}" --logger trx --results-directory "TestResults" | |
# Upload test results | |
- name: Upload dotnet test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-results-${{ matrix.configuration }}-${{ matrix.define }} | |
path: TestResults/**/*.trx | |
# Use always() to always run this step to publish test results when there are test failures | |
if: ${{ always() }} | |
# Upload build output for dlls and nuget | |
- name: Upload build output for Unity & NuGet | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-output-${{ matrix.configuration }}-${{ matrix.define }} | |
path: | | |
src/Arch/bin/${{ matrix.configuration }}/net8.0/ | |
# Packing nugets | |
pack: | |
name: Pack NuGet | |
needs: build | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_nuget == 'yes' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
define: [Default, Events, PureECS] | |
steps: | |
- uses: actions/checkout@v4 | |
# Setting up .net | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: | | |
8.0.x | |
# Download build output from build stage | |
- name: Download build output | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-output-Release-${{ matrix.define }} | |
path: src/Arch/bin/Release/net8.0/ | |
# Restore | |
- name: Restore dependencies | |
run: dotnet restore src/Arch/Arch.csproj | |
# Packing | |
- name: Pack with DefineConstants=${{ matrix.define }} | |
run: | | |
PACKAGE_ID="Arch" | |
if [ "${{ matrix.define }}" != "Default" ]; then | |
PACKAGE_ID="Arch-${{ matrix.define }}" | |
fi | |
dotnet pack src/Arch/Arch.csproj --no-build --configuration Release \ | |
-p:TargetFramework=net8.0 \ | |
--include-symbols --include-source \ | |
-p:PackageVersion=${{ github.event.inputs.version }} \ | |
-p:PackageReleaseNotes="${{ github.event.inputs.release_notes }}" \ | |
-p:DefineConstants="${{ matrix.define }}" \ | |
-p:PackageId=$PACKAGE_ID \ | |
-o ./nupkg-${{ matrix.define }} | |
# Uploading artifacts | |
- name: Upload NuGet packages (nupkg + snupkg) | |
uses: actions/upload-artifact@v4 | |
with: | |
name: nuget-${{ matrix.define }} | |
path: ./nupkg-${{ matrix.define }}/*.*nupkg | |
# Deployment to nuget | |
deploy: | |
name: Deploy NuGet & Release | |
needs: pack | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_nuget == 'yes' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
define: [Default, Events, PureECS] | |
steps: | |
# Downloading nuget & dlls | |
- name: Download Artifacts (NuGet + DLLs) | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./artifacts | |
pattern: | | |
nuget-* | |
dlls-* | |
merge-multiple: true | |
# Pushing to nuget the nupkg & snupkg for symbols | |
- name: Push to NuGet | |
run: | | |
dotnet nuget push "./nupkg-${{ matrix.define }}/*.nupkg" \ | |
--api-key ${{ secrets.NUGET_API_KEY }} \ | |
--source https://api.nuget.org/v3/index.json \ | |
--skip-duplicate | |
dotnet nuget push "./nupkg-${{ matrix.define }}/*.snupkg" \ | |
--api-key ${{ secrets.NUGET_API_KEY }} \ | |
--source https://api.nuget.org/v3/index.json \ | |
--skip-duplicate | |
# Creating a github release. | |
- name: Create GitHub Release & Upload Artifacts | |
uses: softprops/action-gh-release@v1 | |
if: matrix.define == 'Default' && !contains(github.event.inputs.version, 'alpha') && !contains(github.event.inputs.version, 'beta') # Create release once only. | |
with: | |
tag_name: v${{ github.event.inputs.version }} | |
name: v${{ github.event.inputs.version }} | |
body: ${{ github.event.inputs.release_notes }} | |
files: | | |
./artifacts/**/*.nupkg | |
./artifacts/**/*.snupkg | |
./artifacts/**/*.dll | |
./artifacts/**/*.xml | |
./artifacts/**/*.pdb | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |