Skip to content

Commit

Permalink
Merge pull request #30 from FirelyTeam/feature/strong-name-signging
Browse files Browse the repository at this point in the history
Strong name signing and other maintenance
  • Loading branch information
marcovisserFurore authored May 11, 2023
2 parents dd574b7 + cf3b08b commit cb8c6f2
Show file tree
Hide file tree
Showing 14 changed files with 510 additions and 350 deletions.
Binary file added FhirMetrics.publickey
Binary file not shown.
Binary file removed FhirNetApi.snk
Binary file not shown.
91 changes: 66 additions & 25 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Repo: FirelyTeam/Fhir.Metrics
# Repo: FirelyTeam/Fhir.Metrics
# File: build/azure-pipelines.yml
name: build-$(Date:yyyyMMdd)$(Rev:-r)

name: build-$(Date:yyyyMMdd)$(Rev:.r)
resources:
repositories:
- repository: templates
Expand All @@ -10,35 +9,77 @@ resources:
endpoint: FirelyTeam

variables:
buildConfiguration: 'Release'
- group: CodeSigning
- group: APIKeys
- template: variables.yml

pool:
vmImage: $(vmImage)

trigger:
branches:
branches:
include:
- develop*
- release*

pr:
branches:
include:
- develop*
- hotfix/*
- refs/tags/v*

stages:
- stage: build
jobs:
- template: build.yml@templates # Template reference
- stage: build
jobs:
- ${{ if not(startswith(variables['Build.SourceBranch'], 'refs/tags/v')) }}: # 'normal' build
- template: templates/build.yml # Template reference
parameters:
dotNetCoreVersion: $(DOTNET_CORE_SDK)
useVersionSuffix: true
packageArtifacts: true
dotNetCoreVersion: '3.1.x'
pool:
vmImage: windows-latest

- stage: deploy
dependsOn: build
jobs:
- template: deploy-plugin-package.yml@templates
restoreDependencies: true
nuGetServiceConnections: GitHubPackageGetFeed
nuGetSources: --source https://nuget.pkg.github.com/FirelyTeam/index.json
pool:
vmImage: $(vmImage)

- ${{ if startswith(variables['Build.SourceBranch'], 'refs/tags/v') }}: # release mode
- template: templates/build.yml # Template reference
parameters:
pool:
vmImage: windows-latest
nugetcredentials: MyGet
dotNetCoreVersion: $(DOTNET_CORE_SDK)
useVersionSuffix: false
packageArtifacts: true
restoreDependencies: true
pool:
vmImage: $(vmImage)

- stage: deployToGitHub
dependsOn: build
displayName: Deploy packages To Github
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # not a PR
jobs:
- deployment: gitHub
displayName: Deploy Packages to GitHub
environment: GitHub
strategy:
runOnce:
deploy:
steps:
- template: push-nuget-package.yml@templates
parameters:
artifact: 'NuGetPackages'
source: https://nuget.pkg.github.com/FirelyTeam/index.json
apiKey: $(GITHUB_PACKAGES_APIKEY)

- stage: deployToNuget
dependsOn: deployToGitHub
displayName: Deploy packages to NuGet
condition: and(succeeded(), startswith(variables['Build.SourceBranch'], 'refs/tags/v'))
jobs:
- deployment: NuGet
displayName: Publish to Nuget
environment: NuGet
strategy:
runOnce:
deploy:
steps:
- template: push-nuget-package.yml@templates
parameters:
artifact: 'NuGetPackages'
source: https://api.nuget.org/v3/index.json
apiKey: $(NUGET_APIKEY)
41 changes: 0 additions & 41 deletions build/azure-release-pipeline.yml

This file was deleted.

68 changes: 68 additions & 0 deletions build/templates/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Repo: FirelyTeam/azure-pipeline-templates
# File: build.yml

parameters:
# Default values
dotNetCoreVersion: '3.1.102' # can also be use with wildcards: latest minor version of 3. , use '3.x'
useVersionSuffix: true
restoreDependencies: false
nuGetServiceConnections: #required when restoreDependies = true
nuGetSources: #required when restoreDependies = true
packageArtifacts: false
publishArtifacts: false
publishWebProjects: false
zipAfterPublish: false
checkoutSubmodules: false
pool: {}

jobs:
- job: Build
pool: ${{ parameters.pool }}
steps:
- task: DotNetCoreInstaller@2
inputs:
version: ${{ parameters.dotNetCoreVersion }}

- ${{ if eq(parameters.checkoutSubmodules, 'true') }}:
- checkout: self
submodules: true

- ${{ if eq(parameters.restoreDependencies, 'true') }}:
- template: restore.yml@templates
parameters:
nuGetServiceConnections: ${{ parameters.nuGetServiceConnections }}
nuGetSources: ${{ parameters.nuGetSources }}

- script: dotnet build --configuration $(buildConfiguration) --version-suffix $(build.buildNumber) --no-restore /p:ContinuousIntegrationBuild=true
displayName: 'dotnet build $(buildConfiguration) with version suffix and no restore'
condition: and(succeeded(), and(eq('${{ parameters.useVersionSuffix }}', 'true'), eq('${{ parameters.restoreDependencies }}', 'true')))

- script: dotnet build --configuration $(buildConfiguration) --version-suffix $(build.buildNumber) /p:ContinuousIntegrationBuild=true
displayName: 'dotnet build $(buildConfiguration) with version suffix'
condition: and(succeeded(), and(eq('${{ parameters.useVersionSuffix }}', 'true'), eq('${{ parameters.restoreDependencies }}', 'false')))

- script: dotnet build --configuration $(buildConfiguration) /p:ContinuousIntegrationBuild=true
displayName: 'dotnet build $(buildConfiguration)'
condition: and(succeeded(), eq('${{ parameters.useVersionSuffix }}', 'false'))

- task: DotNetCoreCLI@2
displayName: 'dotnet test UnitTests'
inputs:
command: test
projects: '**/*Tests/*Tests.csproj'
arguments: '--configuration $(buildConfiguration) --no-build --no-restore'

- template: sign-dlls-template.yml

- ${{ if eq(parameters.packageArtifacts, 'true') }}:
- template: package.yml
parameters:
useVersionSuffix: ${{ parameters.useVersionSuffix }}

- ${{ if eq(parameters.publishArtifacts, 'true') }}:
- template: publish.yml@templates
parameters:
useVersionSuffix: ${{ parameters.useVersionSuffix }}
publishWebProjects: ${{ parameters.publishWebProjects }}
zipAfterPublish: ${{ parameters.zipAfterPublish }}

25 changes: 25 additions & 0 deletions build/templates/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
parameters:
# Default values
useVersionSuffix: true

steps:
# Package nugets
- script: dotnet pack --no-build --configuration $(buildConfiguration) --version-suffix $(build.buildNumber) --output $(Build.artifactStagingDirectory)/packages
displayName: 'dotnet pack $(buildConfiguration) with version suffix'
condition: and(succeeded(), eq('${{ parameters.useVersionSuffix }}', 'true'))

- script: dotnet pack --no-build --configuration $(buildConfiguration) --output $(Build.artifactStagingDirectory)/packages
displayName: 'dotnet pack $(buildConfiguration)'
condition: and(succeeded(), eq('${{ parameters.useVersionSuffix }}', 'false'))

- template: codesign-nuget-packages.yml@templates
parameters:
certificateValue: $(FirelyCodeSignerCertificate)
certificatePasswordValue: $(CodeSigningPassword)
packagePaths: $(Build.ArtifactStagingDirectory)\packages\*.nupkg

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: NuGet Packages'
inputs:
pathtoPublish: '$(Build.artifactStagingDirectory)/packages'
artifactName: 'NuGetPackages'
31 changes: 31 additions & 0 deletions build/templates/sign-dlls-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
steps:
- task: DownloadSecureFile@1
displayName: Download Signing key file
inputs:
secureFile: FhirMetrics.snk
retryCount:
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # not a PR
- task: CopyFiles@2
displayName: Copy key file to $(Build.SourcesDirectory)
inputs:
SourceFolder: $(Agent.TempDirectory)
Contents: FhirMetrics.snk
TargetFolder: $(Build.SourcesDirectory)
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # not a PR
- powershell: |
$files = Get-ChildItem -Path $(Build.SourcesDirectory)\src\Fhir.Metrics\bin\Release\*\Fhir.Metrics.dll
Write-Verbose "Last exitcode before signing: $lastexitcode"
foreach ($file in $files)
{
Write-Verbose "Signing file: $file"
& '$(Build.SourcesDirectory)\build\tools\sn.exe' -R $file $(Build.SourcesDirectory)\FhirMetrics.snk
Write-Verbose "Last exitcode after signing file: $lastexitcode"
}
Write-Verbose "Last exitcode after signing all files: $lastexitcode"
# suppress exitcode
if ($lastexitcode -lt 2) { $global:lastexitcode = 0 }
displayName: Signing the dlls
name: signing
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # not a PR
Binary file added build/tools/sn.exe
Binary file not shown.
10 changes: 10 additions & 0 deletions build/variables.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Repo: FirelyTeam/Fhir.Metrics
# File: build/variables.yml
# Variables used during builds.

variables:
buildConfiguration: 'Release'
vmImage: 'windows-latest'
DOTNET_CORE_SDK: '7.0.x'
GITHUB_PACKAGES_APIKEY: $(GitHubPushPackagesAPIKey) # key is set in UI of Azure Devops
NUGET_APIKEY: $(NuGetFhirMetricsAPIKey)
Binary file added icon-fhir-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 47 additions & 17 deletions src/Fhir.Metrics/Fhir.Metrics.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Conversion system for physical units, with UCUM implementation - The Unified Code for Units of Measure</Description>
<Copyright>Copyright 2015, 2016 Furore Health Informatics</Copyright>
<VersionPrefix>1.3.0</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<Authors>Martijn Harthoorn</Authors>
<DebugType>portable</DebugType>
<AssemblyName>Fhir.Metrics</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>Fhir.Metrics</PackageId>
<PackageTags>FHIR UCUM Metrics conversion unit units</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/ewoutkramer/fhir-net-api/master/icon-fhir-32.png</PackageIconUrl>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Description>Conversion system for physical units, with UCUM implementation - The Unified Code for Units of Measure</Description>
<Copyright>Copyright 2013-2023 Firely. Contains materials (C) HL7 International</Copyright>
<VersionPrefix>1.2.2</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<Authors>Firely (info@fire.ly) and contributors</Authors>
<Company>Firely (https://fire.ly)</Company>
<DebugType>portable</DebugType>
<AssemblyName>Fhir.Metrics</AssemblyName>
<OutputType>Library</OutputType>
<PackageId>Fhir.Metrics</PackageId>
<PackageTags>FHIR UCUM Metrics conversion unit units</PackageTags>
<PackageIcon>icon-fhir-32.png</PackageIcon>
<PackageReleaseNotes>See https://github.com/FirelyTeam/Fhir.Metrics/releases</PackageReleaseNotes>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
<PackageReadmeFile>\README.md</PackageReadmeFile>
<TargetFramework>netstandard2.0</TargetFramework>
<RepositoryUrl>https://github.com/FirelyTeam/Fhir.Metrics</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\icon-fhir-32.png" Pack="true" PackagePath=""/>
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Data\*.xml" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
<!-- Compiler settings -->
<PropertyGroup>
<LangVersion>11.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<SignAssembly>True</SignAssembly>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>..\..\FhirMetrics.publickey</AssemblyOriginatorKeyFile>
<IncludeSymbols>True</IncludeSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<NoWarn>1591</NoWarn>
<!-- Missing XML comments -->
</PropertyGroup>


<ItemGroup>
<EmbeddedResource Include="Data\*.xml" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

</Project>
Loading

0 comments on commit cb8c6f2

Please sign in to comment.