Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish CI builds to their own channel #37

Merged
merged 1 commit into from
Oct 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ A financial money management library and applications that utilize it.
[![Install](https://img.shields.io/badge/prerelease-win--x64-green)](https://moneymanreleases.blob.core.windows.net/releases/prerelease/win-x64/Nerdbank.MoneyMan.Setup.exe)
[![Install](https://img.shields.io/badge/prerelease-win--arm64-green)](https://moneymanreleases.blob.core.windows.net/releases/prerelease/win-arm64/Nerdbank.MoneyMan.Setup.exe)

[![Install](https://img.shields.io/badge/CI-win--x64-green)](https://moneymanreleases.blob.core.windows.net/releases/main-CI/win-x64/Nerdbank.MoneyMan.Setup.exe)
[![Install](https://img.shields.io/badge/CI-win--arm64-green)](https://moneymanreleases.blob.core.windows.net/releases/main-CI/win-arm64/Nerdbank.MoneyMan.Setup.exe)

[![Join the chat at https://gitter.im/MoneyManagement/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/MoneyManagement/Lobby?utm_source=badge&utm_medium=badge&utm_content=badge)

[![Azure Pipelines status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/AArnott.MoneyMan?branchName=main)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=29&branchName=main)
Expand Down
67 changes: 1 addition & 66 deletions azure-pipelines/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,7 @@ resources:
- auto-release

stages:
- stage: releasify
displayName: squirrel releasify
jobs:
- job:
pool: Hosted Windows 2019 with VS2019
variables:
SquirrelVersion: 2.0.2-netcore.3
steps:
- checkout: self # we need this for nuget.config so that `nuget install` will work
clean: true
- powershell: Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)"
displayName: Set pipeline name
- download: CI
artifact: Variables-Windows
displayName: Download pipeline variables
- powershell: $(Pipeline.Workspace)/CI/Variables-Windows/_pipelines.ps1
displayName: Applying pipeline variables
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.x
inputs:
versionSpec: 5.x
- download: CI
artifact: deployables-Windows
displayName: Download Squirrel input packages
patterns: 'deployables-Windows/SquirrelInputs/Nerdbank_MoneyMan_*.$(NUGETPACKAGEVERSION).nupkg'
- powershell: |
Write-Host "Installing Squirrel"
nuget install Squirrel.Windows -Version $(SquirrelVersion) -OutputDirectory $(Agent.TempDirectory)\Squirrel -PackageSaveMode nuspec -ExcludeVersion -NonInteractive -Verbosity Quiet
$SquirrelTools = "$(Agent.TempDirectory)\Squirrel\squirrel.windows\tools"

if ("$(NUGETPACKAGEVERSION)".Contains('-')) {
$channel = "prerelease"
} else {
$channel = "release"
}

"win-x64","win-arm64" |% {
$localRidPath = "$(Build.StagingDirectory)\release_blobs\$channel\$_"
Write-Host "Downloading prior release for $_"
& "$SquirrelTools\SyncReleases" -r $localRidPath -u https://moneymanreleases.blob.core.windows.net/releases/$channel/$_

Write-Host "Building new release package for $_"
$input = "$(Pipeline.Workspace)/CI/deployables-Windows/SquirrelInputs/Nerdbank_MoneyMan_$_.$(NUGETPACKAGEVERSION).nupkg"
& "$SquirrelTools\Squirrel" -r $localRidPath --no-msi --releasify $input
ren $localRidPath\Setup.exe $localRidPath\Nerdbank.MoneyMan.Setup.exe -Force

# We only want to upload files to blob storage that were not already there or that we intend to overwrite.
# We do this by deleting files that are not new from this pipeline.
# Note the -Exclude list are the files we KEEP and upload.
del $localRidPath\* -Exclude RELEASES,Nerdbank.MoneyMan.Setup.exe,Nerdbank_MoneyMan_$_-$(NUGETPACKAGEVERSION)-*.nupkg
}
displayName: Build squirrel packages
- publish: $(Build.StagingDirectory)/release_blobs
artifact: squirrelInstaller
displayName: Publishing installer as a pipeline artifact

- task: AzureFileCopy@4
displayName: Publishing release
inputs:
SourcePath: $(Build.StagingDirectory)\release_blobs\*
azureSubscription: Azure Free Trial(c5eda4ed-4681-4034-8835-65d67e7d4b7c)
Destination: AzureBlob
storage: moneymanreleases
ContainerName: releases
AdditionalArgumentsForBlobCopy: '--overwrite true --recursive'

- template: release_squirrel.yml
- stage: GitHubRelease
displayName: GitHub Release
jobs:
Expand Down
16 changes: 16 additions & 0 deletions azure-pipelines/release_CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trigger: none # We only want to trigger manually or based on resources
pr: none

resources:
pipelines:
- pipeline: CI
source: MoneyMan
trigger:
branches:
include:
- main

stages:
- template: release_squirrel.yml
parameters:
cibranch: $(resources.pipeline.CI.sourceBranch)
80 changes: 80 additions & 0 deletions azure-pipelines/release_squirrel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
parameters:
cibranch:

stages:
- stage: releasify
displayName: squirrel releasify
jobs:
- job:
displayName: squirrel releasify
pool: Hosted Windows 2019 with VS2019
variables:
SquirrelVersion: 2.0.2-netcore.3
steps:
- checkout: self # we need this for nuget.config so that `nuget install` will work
clean: true
- powershell: Write-Host "##vso[build.updatebuildnumber]$(resources.pipeline.CI.runName)"
displayName: Set pipeline name
- download: CI
artifact: Variables-Windows
displayName: Download pipeline variables
- powershell: $(Pipeline.Workspace)/CI/Variables-Windows/_pipelines.ps1
displayName: Applying pipeline variables
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.x
inputs:
versionSpec: 5.x
- download: CI
artifact: deployables-Windows
displayName: Download Squirrel input packages
patterns: 'deployables-Windows/SquirrelInputs/Nerdbank_MoneyMan_*.$(NUGETPACKAGEVERSION).nupkg'
- powershell: |
Write-Host "Installing Squirrel"
nuget install Squirrel.Windows -Version $(SquirrelVersion) -OutputDirectory $(Agent.TempDirectory)\Squirrel -PackageSaveMode nuspec -ExcludeVersion -NonInteractive -Verbosity Quiet
$SquirrelTools = "$(Agent.TempDirectory)\Squirrel\squirrel.windows\tools"

if ('${{ parameters.cibranch }}' -match '^refs/heads/(.+)$') {
$channel = "$($Matches[1])-CI"
} else {
if ("$(NUGETPACKAGEVERSION)".Contains('-')) {
$channel = "prerelease"
} else {
$channel = "release"
}
}

"win-x64","win-arm64" |% {
$localRidPath = "$(Build.StagingDirectory)\release_blobs\$channel\$_"
Write-Host "Downloading prior release for $_"
& "$SquirrelTools\SyncReleases" -r $localRidPath -u https://moneymanreleases.blob.core.windows.net/releases/$channel/$_

Write-Host "Building new release package for $_"
$input = "$(Pipeline.Workspace)/CI/deployables-Windows/SquirrelInputs/Nerdbank_MoneyMan_$_.$(NUGETPACKAGEVERSION).nupkg"

Write-Host "Seed channel name '$channel' into the package"
$channelMetadataDirectory = "$(Agent.TempDirectory)\channelmetadata\lib\net45"
New-Item -Type Directory -Path $channelMetadataDirectory -Force | Out-Null
Set-Content -Path $channelMetadataDirectory\channelname.txt -Value $channel
7z a $input $(Agent.TempDirectory)\channelmetadata\lib -r

& "$SquirrelTools\Squirrel" -r $localRidPath --no-msi --releasify $input
ren $localRidPath\Setup.exe $localRidPath\Nerdbank.MoneyMan.Setup.exe -Force

# We only want to upload files to blob storage that were not already there or that we intend to overwrite.
# We do this by deleting files that are not new from this pipeline.
# Note the -Exclude list are the files we KEEP and upload.
del $localRidPath\* -Exclude RELEASES,Nerdbank.MoneyMan.Setup.exe,Nerdbank_MoneyMan_$_-$(NUGETPACKAGEVERSION)-*.nupkg
}
displayName: Build squirrel packages
- publish: $(Build.StagingDirectory)/release_blobs
artifact: squirrelInstaller
displayName: Publishing installer as a pipeline artifact
- task: AzureFileCopy@4
displayName: Publishing release
inputs:
SourcePath: $(Build.StagingDirectory)\release_blobs\*
azureSubscription: Azure Free Trial(c5eda4ed-4681-4034-8835-65d67e7d4b7c)
Destination: AzureBlob
storage: moneymanreleases
ContainerName: releases
AdditionalArgumentsForBlobCopy: '--overwrite true --recursive'
6 changes: 6 additions & 0 deletions src/MoneyMan.WPF/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public static void Main()
internal static UpdateManager CreateUpdateManager()
{
string channel = ThisAssembly.IsPrerelease ? "prerelease" : "release";
string channelOverrideFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly()!.Location)!, "channelname.txt");
if (File.Exists(channelOverrideFilePath))
{
channel = File.ReadAllText(channelOverrideFilePath).Trim();
}

string subchannel = RuntimeInformation.ProcessArchitecture switch
{
Architecture.Arm64 => "win-arm64",
Expand Down