Skip to content

Commit

Permalink
Add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Oren Novotny committed Sep 18, 2018
1 parent bd96ff8 commit f8e37b1
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions MiFare.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ VisualStudioVersion = 15.0.28107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9EED52A0-0239-4D3D-961A-C7823743936D}"
ProjectSection(SolutionItems) = preProject
azure-pipelines.yml = azure-pipelines.yml
readme.md = readme.md
version.json = version.json
EndProjectSection
Expand Down
56 changes: 56 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
trigger:
- master
- rel/*

pool:
vmImage: vs2017-win2016

variables:
BuildConfiguration: Release

steps:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . nbgv
displayName: Install NBGV tool
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))

- script: nbgv cloud
displayName: Set Version
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false))

- task: MSBuild@1
inputs:
solution: .\MiFare.sln
configuration: $(BuildConfiguration)
msbuildArguments: /restore
maximumCpuCount: true
displayName: Build Solution

- task: MSBuild@1
inputs:
solution: .\src\MiFare\MiFare.csproj
configuration: $(BuildConfiguration)
msbuildArguments: /t:Pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)\Packages
maximumCpuCount: true
displayName: Pack MiFare

- task: PowerShell@2
displayName: Authenticode Sign artifacts
inputs:
filePath: scripts/Sign-Package.ps1
env:
SignClientUser: $(SignClientUser)
SignClientSecret: $(SignClientSecret)
ArtifactDirectory: $(Build.ArtifactStagingDirectory)\Packages
condition: and(succeeded(), not(eq(variables['build.reason'], 'PullRequest')), not(eq(variables['SignClientSecret'], '')), not(eq(variables['SignClientUser'], '')))

- task: PublishBuildArtifacts@1
displayName: Publish Package Artifacts
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)\Packages
artifactType: container
artifactName: Packages
condition: eq(variables['system.pullrequest.isfork'], false)
24 changes: 24 additions & 0 deletions scripts/Sign-Package.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$currentDirectory = split-path $MyInvocation.MyCommand.Definition

# See if we have the ClientSecret available
if([string]::IsNullOrEmpty($env:SignClientSecret)){
Write-Host "Client Secret not found, not signing packages"
return;
}

# Setup Variables we need to pass into the sign client tool
dotnet tool install --tool-path . SignClient

$appSettings = "$currentDirectory\appsettings.json"

$nupgks = ls $Env:ArtifactDirectory\*.nupkg | Select -ExpandProperty FullName

foreach ($nupkg in $nupgks){
Write-Host "Submitting $nupkg for signing"

.\SignClient 'sign' -c $appSettings -i $nupkg -r $env:SignClientUser -s $env:SignClientSecret -n 'MiFare' -d 'MiFare' -u 'https://github.com/onovotny/MiFare'

Write-Host "Finished signing $nupkg"
}

Write-Host "Sign-package complete"
13 changes: 13 additions & 0 deletions scripts/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"SignClient": {
"AzureAd": {
"AADInstance": "https://login.microsoftonline.com/",
"ClientId": "6632f806-5a64-4bc6-87cf-b622b2ec62d3",
"TenantId": "71048637-3782-41a3-b6b2-6f4ac8a25ae0"
},
"Service": {
"Url": "https://codesign.novotny.org/",
"ResourceId": "https://SignService/0263d4ba-331b-46d1-85e1-bee9898a65a6"
}
}
}

0 comments on commit f8e37b1

Please sign in to comment.