Skip to content

Set up dotnet in dependent workflows #1

Set up dotnet in dependent workflows

Set up dotnet in dependent workflows #1

# Copyright 2021 Yubico AB
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build pull request
# Triggers build on pull requests and pushes to the main and develop branches.
on:
pull_request:
branches:
- main
- 'develop**'
- 'release/**'
push:
branches:
- 'release/**'
jobs:
build:
# Give this job a friendly name to show in GitHub UI.
name: Build and test
runs-on: windows-latest
# Build both Debug and ReleaseWithDocs configurations. Most people are probably building 'Debug' the most often. We
# should be sure that Release also builds, and that our documentation also compiles successfully.
strategy:
matrix:
configuration: [Debug, ReleaseWithDocs]
steps:
# Checkout the local repository
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Add local NuGet repository
run: dotnet nuget add source --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/Yubico/index.json"
# Build the project
- name: Build Yubico.NET.SDK.sln
run: dotnet build --configuration ${{matrix.configuration}} --nologo --verbosity normal Yubico.NET.SDK.sln
# Save the built NuGet packages, just in case we need to inspect the build output.
- name: Save build artifacts
uses: actions/upload-artifact@v4
with:
name: Nuget Packages ${{matrix.configuration}}
path: |
Yubico.DotNetPolyfills/src/bin/${{matrix.configuration}}/*.nupkg
Yubico.Core/src/bin/${{matrix.configuration}}/*.nupkg
Yubico.YubiKey/src/bin/${{matrix.configuration}}/*.nupkg
- name: Save build artifacts
uses: actions/upload-artifact@v4
with:
name: Assemblies ${{matrix.configuration}}
path: |
Yubico.DotNetPolyfills/src/bin/${{matrix.configuration}}/**/*.dll
Yubico.Core/src/bin/${{matrix.configuration}}/**/*.dll
Yubico.YubiKey/src/bin/${{matrix.configuration}}/**/*.dll
# Test the project
- name: Test Yubico.YubiKey
run: dotnet test --configuration ${{matrix.configuration}} --verbosity normal --no-build --nologo Yubico.YubiKey/tests/unit/Yubico.YubiKey.UnitTests.csproj
- name: Test Yubico.Core
run: dotnet test --configuration ${{matrix.configuration}} --verbosity normal --no-build --nologo Yubico.Core/tests/Yubico.Core.UnitTests.csproj