Skip to content

Update azure-pipelines.yml for Azure Pipelines #18

Update azure-pipelines.yml for Azure Pipelines

Update azure-pipelines.yml for Azure Pipelines #18

Workflow file for this run

name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
dotnetBuildConfiguration: 'Release'
dotnetVerbosity: 'Detailed'
jobs:
package_nuget:
name: Build and pack NuGet packages
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
artifactName: activelogin-identity-nuget-windows
- os: macos-latest
artifactName: activelogin-identity-nuget-macos
- os: ubuntu-latest
artifactName: activelogin-identity-nuget-ubuntu
env:
sourceRepositoryBranch: $env:GITHUB_REF_NAME
sourceRepositoryCommit: $env:GITHUB_SHA
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.7.2
- name: Dotnet restore
run: dotnet restore --verbosity ${{ env.dotnetVerbosity }}
shell: pwsh
- name: Dotnet build
run: dotnet build --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }}
shell: pwsh
- name: 'Dotnet pack: ci'
run: |
dotnet pack ./src/ActiveLogin.Identity.Swedish/ActiveLogin.Identity.Swedish.fsproj --output ${{ env.ciOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }} /p:VersionSuffix=ci-$env:GITHUB_RUN_ID
dotnet pack ./src/ActiveLogin.Identity.Swedish.AspNetCore/ActiveLogin.Identity.Swedish.AspNetCore.csproj --output ${{ env.ciOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }} /p:VersionSuffix=ci-$env:GITHUB_RUN_ID
dotnet pack ./src/ActiveLogin.Identity.Swedish.TestData/ActiveLogin.Identity.Swedish.TestData.fsproj --output ${{ env.ciOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }} /p:VersionSuffix=ci-$env:GITHUB_RUN_ID
shell: pwsh
env:
ciOutputFolder: ${{ runner.temp }}/ci
- name: 'Dotnet pack: release'
run: |
dotnet pack ./src/ActiveLogin.Identity.Swedish/ActiveLogin.Identity.Swedish.fsproj --output ${{ env.releaseOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }}
dotnet pack ./src/ActiveLogin.Identity.Swedish.AspNetCore/ActiveLogin.Identity.Swedish.AspNetCore.csproj --output ${{ env.releaseOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }}
dotnet pack ./src/ActiveLogin.Identity.Swedish.TestData/ActiveLogin.Identity.Swedish.TestData.fsproj --output ${{ env.releaseOutputFolder }} --configuration ${{ env.dotnetBuildConfiguration }} --verbosity ${{ env.dotnetVerbosity }} /p:Configuration=${{ env.dotnetBuildConfiguration }} /p:RepositoryBranch=${{ env.sourceRepositoryBranch }} /p:RepositoryCommit=${{ env.sourceRepositoryCommit }}
shell: pwsh
env:
releaseOutputFolder: ${{ runner.temp }}/release
- name: Dotnet test
run: dotnet test --configuration ${{ env.dotnetBuildConfiguration }} --collect "Code coverage" -- Expecto.fail-on-focused-tests=true
shell: pwsh
- name: Upload packages
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.artifactName }}
path: |
${{ runner.temp }}/ci
${{ runner.temp }}/release
sign_nuget:
name: Sign NuGet packages on Windows
runs-on: windows-latest
needs: package_nuget
if: ${{ github.event_name != 'pull_request' }}
env:
sourceArtifactName: 'activelogin-identity-nuget-windows'
targetArtifactName: 'activelogin-identity-nuget-windows-signed'
pathToNugetPackages: '**/*.nupkg'
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.sourceArtifactName }}
path: ${{ env.sourceArtifactName }}
- name: Install NuGet
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
- name: Create file codesigning-cert.pfx
run: |
$certFile = Join-Path -Path $env:RUNNER_TEMP -ChildPath "codesigning-cert.pfx";
$encodedBytes = [System.Convert]::FromBase64String($env:cert_fileb64);
Set-Content $certFile -Value $encodedBytes -AsByteStream;
shell: pwsh
env:
cert_fileb64: ${{ secrets.CODESIGNING_CERT_FILEB64 }}
- name: NuGet sign
run: nuget sign $env:GITHUB_WORKSPACE"/"${{ env.pathToNugetPackages }} -CertificatePath ${{ env.codesigning_cert_path }} -CertificatePassword ${{ env.codesigning_cert_password }} -Timestamper ${{ env.codesigning_timestamper_url }}
env:
codesigning_cert_path: ${{ runner.temp }}/codesigning-cert.pfx
codesigning_cert_password: ${{ secrets.CODESIGNING_CERT_PASSWORD }}
codesigning_timestamper_url: ${{ secrets.CODESIGNING_TIMESTAMPERURL }}
shell: pwsh
- name: Delete file codesigning-cert.pfx
run: |
$certFile = Join-Path -Path $env:RUNNER_TEMP -ChildPath "codesigning-cert.pfx";
Remove-Item $certFile
- name: Upload signed packages
uses: actions/upload-artifact@v2
with:
name: ${{ env.targetArtifactName }}
path: ${{ github.workspace }}\${{ env.sourceArtifactName }}