From f6880a2b7999adff8c0f1523efaa3d6b901cd5ba Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 27 Nov 2024 11:29:42 +0100 Subject: [PATCH] feat(install): upload to CDN --- .github/workflows/msi.yml | 2 +- packages/msi/build.ps1 | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/msi.yml b/.github/workflows/msi.yml index 86bde2a9..aad84ebc 100644 --- a/.github/workflows/msi.yml +++ b/.github/workflows/msi.yml @@ -26,7 +26,7 @@ jobs: AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} run: | $version = $env:GITHUB_REF.TrimStart("refs/tags/v") - ./build.ps1 -Architecture ${{ matrix.arch }} -Version $version -Download -Sign + ./build.ps1 -Architecture ${{ matrix.arch }} -Version $version -Download -Sign -Upload - name: Upload artifacts 🆙 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea with: diff --git a/packages/msi/build.ps1 b/packages/msi/build.ps1 index f0bee419..ffdf799e 100644 --- a/packages/msi/build.ps1 +++ b/packages/msi/build.ps1 @@ -10,7 +10,8 @@ Param [string] $SDKVersion = "10.0.22621.0", [switch]$Download, - [switch]$Sign + [switch]$Sign, + [switch]$Upload ) $PSDefaultParameterValues['Out-File:Encoding'] = 'UTF8' @@ -35,7 +36,8 @@ if ($Download) { $env:VERSION = $Version # create MSI -$installer = "./out/install-$Architecture.msi" +$fileName = "install-$Architecture.msi" +$installer = "./out/$fileName" wix build -arch $Architecture -out $installer .\oh-my-posh.wxs if ($Sign) { @@ -55,3 +57,16 @@ if ($Sign) { # get hash $zipHash = Get-FileHash $installer -Algorithm SHA256 $zipHash.Hash | Out-File -Encoding 'UTF8' "$installer.sha256" + +if (-not $Upload) { + exit +} + +az storage blob upload --container-name "v$Version" --file $installer --name $fileName --connection-string $env.CDN_CONNECTIONSTRING +az storage blob upload --container-name 'latest' --file $installer --name $fileName --overwrite true --connection-string $env.CDN_CONNECTIONSTRING + +# create version file +$versionFile = "version.txt" +New-Item -Path $versionFile -ItemType File -Value "v$Version" +az storage blob upload --container-name 'latest' --file $versionFile --name $versionFile --overwrite true --connection-string $env.CDN_CONNECTIONSTRING +