Skip to content

Update workflows.yaml #433

Update workflows.yaml

Update workflows.yaml #433

Workflow file for this run

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:
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]
target_framework: [netcoreapp3.1, net6.0, net8.0]
define: [Default, Events, PureECS]
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
# Build the project with defines
- name: Build project
run: |
dotnet build --configuration ${{ matrix.configuration }} --framework ${{ matrix.target_framework }} -p:DefineConstants="${{ matrix.define }}"
# Run tests
- name: Run tests
run: |
dotnet test --configuration ${{ matrix.configuration }} --framework ${{ matrix.target_framework }} -p:DefineConstants="${{ matrix.define }}"
- name: Upload dotnet test results
uses: actions/upload-artifact@v4
with:
name: dotnet-results
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
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@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
3.1.x
6.0.x
8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Pack with DefineConstants=${{ matrix.define }}
run: |
dotnet pack --no-build --configuration Release \
--include-symbols --include-source \
-p:PackageVersion=${{ github.event.inputs.version }} \
-p:PackageReleaseNotes="${{ github.event.inputs.release_notes }}" \
-p:DefineConstants="${{ matrix.define }}" \
-o ./nupkg-${{ matrix.define }}
- name: Upload NuGet packages (nupkg + snupkg)
uses: actions/upload-artifact@v3
with:
name: nuget-${{ matrix.define }}
path: ./nupkg-${{ matrix.define }}/*.*nupkg
deploy:
name: Deploy NuGet & Release
needs: pack
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_to_nuget == 'yes'
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: nupkg
path: ./nupkg
- name: Push to NuGet
run: |
dotnet nuget push "./nupkg/*.nupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
dotnet nuget push "./nupkg/*.snupkg" \
--api-key ${{ secrets.NUGET_API_KEY }} \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ github.event.inputs.version }}
name: v${{ github.event.inputs.version }}
body: ${{ github.event.inputs.release_notes }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload .nupkg to GitHub Release
uses: softprops/action-gh-release@v1
if: ${{ !contains(github.event.inputs.version, 'alpha') && !contains(github.event.inputs.version, 'beta') }}
with:
tag_name: v${{ github.event.inputs.version }}
files: |
./nupkg/*.nupkg
./nupkg/*.snupkg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}