Skip to content

Commit

Permalink
Resolved archive overwrite and hash calculation issues on build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelvds committed Nov 13, 2023
1 parent ce5a702 commit eecd50d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions azure-pipelines/templates/stages/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ stages:
./src/**/fiskaltrust.Launcher.exe
./src/**/fiskaltrust.LauncherUpdater
./src/**/fiskaltrust.LauncherUpdater.exe
displayName: 'Code Signing'
- publish: $(Build.ArtifactStagingDirectory)/drop-$(target)
artifact: drop-$(target)
Expand All @@ -71,19 +70,24 @@ stages:
Move-Item -Path $(Build.ArtifactStagingDirectory)/drop-$(target)/${{ project }}* -Destination $(Build.ArtifactStagingDirectory)/raw-$(target)/
$version = (Select-Xml -Path ./Directory.Build.props -XPath 'Project/PropertyGroup/Version').Node.InnerText
if("$(vmImage)" -eq "windows-latest") {
Compress-Archive -Path $(Build.ArtifactStagingDirectory)/raw-$(target)/* -DestinationPath $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.zip
Compress-Archive -Path $(Build.ArtifactStagingDirectory)/raw-$(target)/* -DestinationPath $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.zip -Force
} else {
tar -czf $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.tar.gz -C $(Build.ArtifactStagingDirectory)/raw-$(target) .
}
# Hash calculation
if("$(vmImage)" -eq "windows-latest") {
$hash = Get-FileHash $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.zip -Algorithm SHA256
} else {
$hash = bash -c "sha256sum $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.tar.gz"
$hashResult = bash -c "sha256sum $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.tar.gz"
$hash = @($hashResult -split ' ')[0].Trim()
}
if ($null -ne $hash) {
$hashbytes = $hash -split '([A-F0-9]{2})' | Where-Object { $_ } | ForEach-Object { [Convert]::ToByte($_, 16) }
$hashstring = [Convert]::ToBase64String($hashbytes)
Set-Content -Path $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.zip.hash -Value $hashstring
} else {
Write-Error "Hash calculation failed."
}
$hashbytes = $hash.Hash -split '([A-F0-9]{2})' | ForEach-Object { if ($_) { [System.Convert]::ToByte($_, 16) } }
$hashstring = [System.Convert]::ToBase64String($hashbytes)
Set-Content -Path $(Build.ArtifactStagingDirectory)/package-$(target)/fiskaltrust.Launcher-$version.zip.hash -Value $hashstring
displayName: "Package ${{ project }}"
- publish: $(Build.ArtifactStagingDirectory)/package-$(target)
Expand Down

0 comments on commit eecd50d

Please sign in to comment.