2022-05-17 10:14:59 +00:00
|
|
|
trigger:
|
|
|
|
tags:
|
|
|
|
include:
|
|
|
|
- "v*"
|
2022-07-26 14:40:16 +00:00
|
|
|
exclude:
|
|
|
|
- "v*freebsd"
|
2022-05-17 10:14:59 +00:00
|
|
|
branches:
|
|
|
|
exclude:
|
|
|
|
- "*"
|
|
|
|
pr: none
|
|
|
|
|
|
|
|
pool:
|
|
|
|
vmImage: windows-latest
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- stage: Build
|
|
|
|
jobs:
|
|
|
|
- job:
|
|
|
|
displayName: "Build"
|
|
|
|
steps:
|
|
|
|
- task: DotNetCoreCLI@2
|
|
|
|
displayName: "Install SignClient"
|
|
|
|
inputs:
|
|
|
|
command: 'custom'
|
|
|
|
custom: 'tool'
|
|
|
|
arguments: 'install --global SignClient --version 1.3.155'
|
|
|
|
- task: GoTool@0
|
2022-08-26 11:31:49 +00:00
|
|
|
displayName: "Install Go 1.19"
|
2022-05-17 10:14:59 +00:00
|
|
|
inputs:
|
2022-08-26 11:31:49 +00:00
|
|
|
version: '1.19'
|
2022-05-17 10:14:59 +00:00
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
choco install -y jq
|
|
|
|
choco install -y make
|
|
|
|
displayName: "Install builds deps"
|
|
|
|
- task: PowerShell@2
|
|
|
|
inputs:
|
|
|
|
targetType: 'inline'
|
|
|
|
pwsh: true
|
|
|
|
#we are not calling make windows_installer because we want to sign the binaries before they are added to the MSI
|
|
|
|
script: |
|
|
|
|
make build
|
|
|
|
- task: AzureKeyVault@2
|
|
|
|
inputs:
|
|
|
|
azureSubscription: 'Azure subscription 1(8a93ab40-7e99-445e-ad47-0f6a3e2ef546)'
|
|
|
|
KeyVaultName: 'CodeSigningSecrets'
|
|
|
|
SecretsFilter: 'CodeSigningUser,CodeSigningPassword'
|
|
|
|
RunAsPreJob: false
|
|
|
|
|
2022-10-20 09:12:54 +00:00
|
|
|
- task: DownloadSecureFile@1
|
2022-05-17 10:14:59 +00:00
|
|
|
inputs:
|
|
|
|
secureFile: appsettings.json
|
|
|
|
|
|
|
|
- pwsh: |
|
|
|
|
SignClient.exe Sign --name "crowdsec-binaries" `
|
|
|
|
--input "**/*.exe" --config (Join-Path -Path $(Agent.TempDirectory) -ChildPath "appsettings.json") `
|
|
|
|
--user $(CodeSigningUser) --secret '$(CodeSigningPassword)'
|
|
|
|
displayName: "Sign Crowdsec binaries + plugins"
|
|
|
|
- pwsh: |
|
2023-02-09 12:15:36 +00:00
|
|
|
$build_version=$env:BUILD_SOURCEBRANCHNAME
|
2023-02-09 13:27:11 +00:00
|
|
|
if ($build_version.StartsWith("v"))
|
|
|
|
{
|
|
|
|
$build_version = $build_version.Substring(1)
|
|
|
|
}
|
2022-06-23 13:09:29 +00:00
|
|
|
if ($build_version.Contains("-"))
|
|
|
|
{
|
|
|
|
$build_version = $build_version.Substring(0, $build_version.IndexOf("-"))
|
|
|
|
}
|
2022-05-17 10:14:59 +00:00
|
|
|
Write-Host "##vso[task.setvariable variable=BuildVersion;isOutput=true]$build_version"
|
2023-02-09 12:15:36 +00:00
|
|
|
displayName: GetCrowdsecVersion
|
|
|
|
name: GetCrowdsecVersion
|
|
|
|
- pwsh: |
|
|
|
|
.\make_installer.ps1 -version '$(GetCrowdsecVersion.BuildVersion)'
|
2022-05-17 10:14:59 +00:00
|
|
|
displayName: "Build Crowdsec MSI"
|
|
|
|
name: BuildMSI
|
|
|
|
|
2022-10-20 09:12:54 +00:00
|
|
|
- pwsh: |
|
2023-02-09 12:15:36 +00:00
|
|
|
.\make_chocolatey.ps1 -version '$(GetCrowdsecVersion.BuildVersion)'
|
2022-10-20 09:12:54 +00:00
|
|
|
displayName: "Build Chocolatey nupkg"
|
|
|
|
|
2022-05-17 10:14:59 +00:00
|
|
|
- pwsh: |
|
|
|
|
SignClient.exe Sign --name "crowdsec-msi" `
|
|
|
|
--input "*.msi" --config (Join-Path -Path $(Agent.TempDirectory) -ChildPath "appsettings.json") `
|
|
|
|
--user $(CodeSigningUser) --secret '$(CodeSigningPassword)'
|
|
|
|
displayName: "Sign Crowdsec MSI"
|
|
|
|
|
|
|
|
- task: PublishBuildArtifacts@1
|
|
|
|
inputs:
|
2023-02-09 12:15:36 +00:00
|
|
|
PathtoPublish: '$(Build.Repository.LocalPath)\\crowdsec_$(GetCrowdsecVersion.BuildVersion).msi'
|
2022-05-17 10:14:59 +00:00
|
|
|
ArtifactName: 'crowdsec.msi'
|
|
|
|
publishLocation: 'Container'
|
|
|
|
displayName: "Upload MSI artifact"
|
2022-10-20 09:12:54 +00:00
|
|
|
|
|
|
|
- task: PublishBuildArtifacts@1
|
|
|
|
inputs:
|
2023-02-09 12:15:36 +00:00
|
|
|
PathtoPublish: '$(Build.Repository.LocalPath)\\windows\\Chocolatey\\crowdsec\\crowdsec.$(GetCrowdsecVersion.BuildVersion).nupkg'
|
2022-10-20 09:12:54 +00:00
|
|
|
ArtifactName: 'crowdsec.nupkg'
|
|
|
|
publishLocation: 'Container'
|
|
|
|
displayName: "Upload nupkg artifact"
|
2022-05-17 10:14:59 +00:00
|
|
|
- stage: Publish
|
|
|
|
dependsOn: Build
|
|
|
|
jobs:
|
|
|
|
- deployment: "Publish"
|
|
|
|
displayName: "Publish to GitHub"
|
|
|
|
environment: github
|
|
|
|
strategy:
|
|
|
|
runOnce:
|
|
|
|
deploy:
|
|
|
|
steps:
|
|
|
|
- bash: |
|
|
|
|
tag=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/crowdsecurity/crowdsec/releases | jq -r '. | map(select(.prerelease==true)) | sort_by(.created_at) | reverse | .[0].tag_name')
|
|
|
|
echo "##vso[task.setvariable variable=LatestPreRelease;isOutput=true]$tag"
|
|
|
|
name: GetLatestPrelease
|
|
|
|
- task: GitHubRelease@1
|
|
|
|
inputs:
|
|
|
|
gitHubConnection: "github.com_blotus"
|
|
|
|
repositoryName: '$(Build.Repository.Name)'
|
|
|
|
action: 'edit'
|
|
|
|
tag: '$(GetLatestPrelease.LatestPreRelease)'
|
|
|
|
assetUploadMode: 'replace'
|
|
|
|
addChangeLog: false
|
|
|
|
isPreRelease: true #we force prerelease because the pipeline is invoked on tag creation, which happens when we do a prerelease
|
|
|
|
#the .. is an ugly hack, but I can't find the var that gives D:\a\1 ...
|
|
|
|
assets: |
|
2022-06-23 13:34:19 +00:00
|
|
|
$(Build.ArtifactStagingDirectory)\..\crowdsec.msi/*.msi
|
2022-10-20 09:12:54 +00:00
|
|
|
$(Build.ArtifactStagingDirectory)\..\crowdsec.nupkg/*.nupkg
|
2022-05-17 10:14:59 +00:00
|
|
|
condition: ne(variables['GetLatestPrelease.LatestPreRelease'], '')
|