Merge pull request #164 #76
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
# 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 | |
# Triggers build on pushes to the main and develop branches. | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'develop' | |
paths: | |
- '**.h' | |
- '**.c' | |
- '**.cs' | |
- '**.csproj' | |
- '**.sln' | |
- '.github/workflows/build.yml' | |
workflow_dispatch: | |
inputs: | |
push-to-dev: | |
description: 'Push to internal NuGet' | |
required: false | |
default: false | |
type: boolean | |
version: | |
description: 'Version' | |
required: false | |
default: "0.0.0-prerelease.YYYYMMDD.B" | |
type: string | |
jobs: | |
run-tests: | |
name: Run tests | |
permissions: | |
checks: write | |
contents: read | |
packages: read | |
pull-requests: write | |
uses: ./.github/workflows/test.yml | |
with: | |
build-coverage-report: false | |
build-artifacts: | |
name: Build artifacts | |
runs-on: windows-2019 | |
needs: run-tests | |
permissions: | |
contents: read | |
packages: read | |
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" | |
- name: Modify version for internal builds | |
if: ${{ github.event.inputs.push-to-dev == 'true' }} | |
run: | | |
$file = gci ./build/Versions.props | |
$versionProp = [xml](gc $file.FullName) | |
$versionProp.Project.PropertyGroup.YubicoDotNetPolyfillsVersion = "${{ github.event.inputs.version }}" | |
$versionProp.Project.PropertyGroup.YubicoCoreVersion = "${{ github.event.inputs.version }}" | |
$versionProp.Project.PropertyGroup.YubicoYubiKeyVersion = "${{ github.event.inputs.version }}" | |
$versionProp.Save($file.FullName) | |
# Build the project | |
- name: Build Yubico.NET.SDK.sln | |
run: dotnet build --configuration ReleaseWithDocs --nologo --verbosity minimal Yubico.NET.SDK.sln | |
# Upload artifacts | |
- name: Save documentation artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Documentation | |
path: Yubico.YubiKey/docs/_site/ | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Nuget Packages | |
path: | | |
Yubico.DotNetPolyfills/src/bin/ReleaseWithDocs/*.nupkg | |
Yubico.Core/src/bin/ReleaseWithDocs/*.nupkg | |
Yubico.YubiKey/src/bin/ReleaseWithDocs/*.nupkg | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Symbols Packages | |
path: | | |
Yubico.DotNetPolyfills/src/bin/ReleaseWithDocs/*.snupkg | |
Yubico.Core/src/bin/ReleaseWithDocs/*.snupkg | |
Yubico.YubiKey/src/bin/ReleaseWithDocs/*.snupkg | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Assemblies | |
path: | | |
Yubico.DotNetPolyfills/src/bin/ReleaseWithDocs/**/*.dll | |
Yubico.Core/src/bin/ReleaseWithDocs/**/*.dll | |
Yubico.YubiKey/src/bin/ReleaseWithDocs/**/*.dll | |
# Package the OATH sample code source | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: OATH Sample Code | |
path: | | |
Yubico.YubiKey/examples/OathSampleCode | |
Yubico.YubiKey/examples/SharedSampleCode | |
# Package the PIV sample code source | |
- name: Save build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: PIV Sample Code | |
path: | | |
Yubico.YubiKey/examples/PivSampleCode | |
Yubico.YubiKey/examples/SharedSampleCode | |
upload-docs: | |
name: Upload docs | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
permissions: | |
id-token: write | |
contents: read | |
uses: ./.github/workflows/upload-docs.yml | |
needs: build-artifacts | |
publish-internal: | |
name: Publish to internal NuGet | |
runs-on: windows-2019 | |
needs: build-artifacts | |
if: ${{ github.event.inputs.push-to-dev }} | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/download-artifact@v4 | |
id: download | |
with: | |
name: Nuget Packages | |
- run: | | |
$polyfills = (Get-ChildItem -Recurse Yubico.DotnetPolyfills/*.nupkg)[0].FullName | |
$core = (Get-ChildItem -Recurse Yubico.Core/*.nupkg)[0].FullName | |
$yubikey = (Get-ChildItem -Recurse Yubico.YubiKey/*.nupkg)[0].FullName | |
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" | |
dotnet nuget push $polyfills --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} | |
dotnet nuget push $core --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} | |
dotnet nuget push $yubikey --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} |