Browse Source

Update chocolatey spec file and publish nupkg in github releases (#1826)

blotus 2 years ago
parent
commit
03c9216026
4 changed files with 24 additions and 5 deletions
  1. 1 1
      .gitignore
  2. 18 1
      azure-pipelines.yml
  3. 1 1
      make_chocolatey.ps1
  4. 4 2
      windows/Chocolatey/crowdsec/crowdsec.nuspec

+ 1 - 1
.gitignore

@@ -38,5 +38,5 @@ crowdsec-v*
 pkg/cwhub/hubdir/.index.json
 msi
 *.msi
-*.nukpg
+**/*.nupkg
 *.tgz

+ 18 - 1
azure-pipelines.yml

@@ -47,7 +47,7 @@ stages:
               SecretsFilter: 'CodeSigningUser,CodeSigningPassword'
               RunAsPreJob: false
 
-          - task: DownloadSEcureFile@1
+          - task: DownloadSecureFile@1
             inputs:
               secureFile: appsettings.json
 
@@ -68,6 +68,15 @@ stages:
             displayName: "Build Crowdsec MSI"
             name: BuildMSI
 
+          - pwsh: |
+              $build_version=(git describe --tags (git rev-list --tags --max-count=1)).Substring(1)
+              if ($build_version.Contains("-")) 
+              {
+                $build_version = $build_version.Substring(0, $build_version.IndexOf("-"))
+              }
+              .\make_chocolatey.ps1 -version $build_version
+            displayName: "Build Chocolatey nupkg"
+
           - pwsh: |
               SignClient.exe Sign --name "crowdsec-msi" `
               --input "*.msi" --config (Join-Path -Path $(Agent.TempDirectory) -ChildPath "appsettings.json") `
@@ -80,6 +89,13 @@ stages:
               ArtifactName: 'crowdsec.msi'
               publishLocation: 'Container'
             displayName: "Upload MSI artifact"
+          
+          - task: PublishBuildArtifacts@1
+            inputs:
+              PathtoPublish: '$(Build.Repository.LocalPath)\\windows\\Chocolatey\\crowdsec\\crowdsec.$(BuildMSI.BuildVersion).nupkg'
+              ArtifactName: 'crowdsec.nupkg'
+              publishLocation: 'Container'
+            displayName: "Upload nupkg artifact"
   - stage: Publish
     dependsOn: Build
     jobs:
@@ -106,4 +122,5 @@ stages:
                     #the .. is an ugly hack, but I can't find the var that gives D:\a\1 ...
                     assets: |
                       $(Build.ArtifactStagingDirectory)\..\crowdsec.msi/*.msi
+                      $(Build.ArtifactStagingDirectory)\..\crowdsec.nupkg/*.nupkg
                   condition: ne(variables['GetLatestPrelease.LatestPreRelease'], '')

+ 1 - 1
make_chocolatey.ps1

@@ -15,4 +15,4 @@ if ($version.Contains("-"))
 Set-Location .\windows\Chocolatey\crowdsec
 Copy-Item ..\..\..\crowdsec_$version.msi tools\crowdsec.msi
 
-choco pack
+choco pack --version $version

+ 4 - 2
windows/Chocolatey/crowdsec/crowdsec.nuspec

@@ -3,7 +3,8 @@
 <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
   <metadata>
     <id>crowdsec</id>
-    <version>1.3.3</version>
+    <!-- The version is set by the version argument of choco pack, so we just specify a dummy version here -->
+    <version>0.0.1</version>
     <packageSourceUrl>https://github.com/crowdsecurity/crowdsec</packageSourceUrl>
     <owners>CrowdSecurity</owners>
     <!-- ============================== -->
@@ -13,11 +14,12 @@
     <authors>CrowdSecurity</authors>
     <projectUrl>https://crowdsec.net/</projectUrl>
     <copyright>CrowdSec, 2022</copyright>
-    <licenseUrl>https://github.com/crowdsecurity/crowdsec/blob/main/LICENSE</licenseUrl>
+    <licenseUrl>https://github.com/crowdsecurity/crowdsec/blob/master/LICENSE</licenseUrl>
     <requireLicenseAcceptance>true</requireLicenseAcceptance>
     <projectSourceUrl>https://github.com/crowdsecurity/crowdsec</projectSourceUrl>
     <docsUrl>https://docs.crowdsec.net</docsUrl>
     <bugTrackerUrl>https://github.com/crowdsecurity/crowdsec/issues</bugTrackerUrl>
+    <iconUrl>https://cdn.jsdelivr.net/gh/crowdsecurity/crowdsec-docs@c7b90095cca0007652f22c5c6d945c3416df4693/crowdsec-docs/static/img/crowdsec_no_txt.png</iconUrl>
     <tags>crowdsec crowdsecurity security ips ids</tags>
     <summary>CrowdSec IDS</summary>
     <description>