From d643f74e3d97e14dbbe48696d80eb7d155988e60 Mon Sep 17 00:00:00 2001 From: Caelan Sayler Date: Sun, 22 May 2022 19:37:07 +0100 Subject: [PATCH] Test new build structure --- .github/workflows/build.yml | 108 ++++++++----------------- Squirrel.sln | 1 - build.ps1 | 68 ++++++++-------- gon.config.json | 7 +- pack.cmd | 1 - pack.ps1 | 30 ------- src/Squirrel.CommandLine/HelperFile.cs | 3 +- 7 files changed, 72 insertions(+), 146 deletions(-) delete mode 100644 pack.cmd delete mode 100644 pack.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9e7c3cd1..bfcfec8f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,23 +22,18 @@ jobs: run: .\build.ps1 - name: Test run: dotnet test test\Squirrel.Tests.csproj -l "console;verbosity=detailed" - - name: Upload Windows Artifacts + - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: windows-build - path: .\build\* - - name: Bundle Tools - shell: pwsh - run: .\vendor\7za.exe a squirrel-win-x64.zip -tzip -aoa -y -mmt "$env:GITHUB_WORKSPACE\build\publish\*" - - name: Upload Tools - uses: actions/upload-artifact@v3 - with: - name: tools - path: squirrel-win-x64.zip + name: packages + path: .\build\Release\*.nupkg - build-macos: - name: Build OSX + # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development + package-macos: + name: Sign OSX + if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }} runs-on: macos-latest + needs: [ build-windows ] steps: - uses: actions/checkout@v2 with: @@ -47,29 +42,18 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Build SquirrelMac - run: dotnet publish -v minimal --self-contained -c Release -r osx.10.12-x64 ./src/Squirrel.CommandLine.OSX/Squirrel.CommandLine.OSX.csproj -o ./publish - - name: Build UpdateMac - run: dotnet publish -v minimal --self-contained -c Release -r osx.10.12-x64 ./src/Update.OSX/Update.OSX.csproj -o ./publish - - name: Upload MacOS Artifacts - uses: actions/upload-artifact@v3 - with: - name: osx-build - path: ./publish/* - - # https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development - package-macos: - name: Package OSX - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }} - runs-on: macos-latest - needs: [ build-macos ] - steps: - - uses: actions/checkout@v2 - - name: Download MacOS Artifacts + - name: Install NGBV + run: dotnet tool install --tool-path . nbgv + - name: Download Artifacts uses: actions/download-artifact@v3 with: - name: osx-build - path: ./osx-build + name: packages + - name: Extract Artifacts + run: | + ls -la . + ls -la ./squirrel + unzip Clowd.Squirrel*.nupkg -d ./squirrel/ + unzip csq*.nupkg -d ./csq/ - name: Install Apple Certificate env: BUILD_CERTIFICATE_BASE64: ${{ secrets.APPLE_BUILD_CERTIFICATE_BASE64 }} @@ -99,52 +83,26 @@ jobs: - name: Clean up KeyChain if: ${{ always() }} run: security delete-keychain $RUNNER_TEMP/app-signing.keychain-db - - name: Upload Tools - uses: actions/upload-artifact@v3 - with: - name: tools - path: squirrel-osx-x64.zip - - deploy: - name: "Deploy" - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/cs/xplat' }} - needs: [ build-windows, package-macos ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - name: Install NGBV - run: dotnet tool install --tool-path . nbgv - - name: Install NuGet - run: sudo apt install nuget - - name: Download Windows Artifacts - uses: actions/download-artifact@v3 - with: - name: windows-build - path: ./build - - name: Download Tools - uses: actions/download-artifact@v3 - with: - name: tools - - name: Decompress OSX - run: | - unzip ./squirrel-osx-x64.zip -d ./build/publish - mv ./build/publish/7zz ./build/publish/bin/ - - name: Create NuGet Package + - name: Fix Packages run: | export NUGET_VERSION=$(nbgv get-version -f json | python3 -c "import sys, json; print(json.load(sys.stdin)['NuGetPackageVersion'])") echo $NUGET_VERSION - nuget pack ./src/Clowd.Squirrel.nuspec -BasePath ./src -OutputDirectory . -Version $NUGET_VERSION - - name: Upload NuGet Package + unzip signed.zip ./signed + ls -la . + ls -la ./signed + cp ./signed/UpdateMac ./squirrel/tools/ + cp ./signed/UpdateMac ./csq/tools/net6.0/any/ + cp ./signed/7zz ./squirrel/tools/ + cp ./signed/7zz ./csq/tools/net6.0/any/ + rm -rf *.nupkg + zip csq.${NUGET_VERSION}.nupkg ${GITHUB_WORKSPACE}/csq/* + zip Clowd.Squirrel.${NUGET_VERSION}.nupkg ${GITHUB_WORKSPACE}/squirrel/* + ls -la . + - name: Upload Artifacts uses: actions/upload-artifact@v3 with: - name: tools - path: '*.nupkg' + name: signed-packages + path: "*.nupkg" - name: Publish Dev NuGet Package run: | nuget push *.nupkg -ApiKey ${{ secrets.GITHUB_TOKEN }} -Source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -SkipDuplicate \ No newline at end of file diff --git a/Squirrel.sln b/Squirrel.sln index 0d083806..e26d693c 100644 --- a/Squirrel.sln +++ b/Squirrel.sln @@ -18,7 +18,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionLevel", "SolutionLe version.json = version.json .github\workflows\build.yml = .github\workflows\build.yml build.ps1 = build.ps1 - pack.ps1 = pack.ps1 Squirrel.entitlements = Squirrel.entitlements gon.config.json = gon.config.json EndProjectSection diff --git a/build.ps1 b/build.ps1 index 5e4d9681..c466e9c5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,53 +1,55 @@ +# Stop the script if an error occurs +$ProgressPreference = "SilentlyContinue" # progress bar in powershell is slow af +$ErrorActionPreference = "Stop" + # search for msbuild, the loaction of vswhere is guarenteed to be consistent $MSBuildPath = (&"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe) | Out-String -$MSBuildPath = $MSBuildPath.Trim(); +Set-Alias msbuild $MSBuildPath.Trim() +Set-Alias seven "$PSScriptRoot\vendor\7za.exe" # This variable is null in github actions if ($PSScriptRoot -eq $null) { $PSScriptRoot = "." +} else { + Set-Location $PSScriptRoot } -# Stop the script if an error occurs -$ErrorActionPreference = "Stop" -$In = "$PSScriptRoot\build\Release\" -$Out = "$PSScriptRoot\build\publish\" -$Folders = @("$PSScriptRoot\build", "$PSScriptRoot\packages", "$PSScriptRoot\test\bin", "$PSScriptRoot\test\obj") - # Ensure a clean state by removing build/package folders +Write-Host "Cleaning previous build outputs (if any)" -ForegroundColor Magenta +$Folders = @("build", "packages", "test\bin", "test\obj") foreach ($Folder in $Folders) { if (Test-Path $Folder) { Remove-Item -path "$Folder" -Recurse -Force } } -# Build Squirrel C++ with msbuild as dotnet can't -Write-Output "Building Solution" -&"$MSBuildPath" /verbosity:minimal /restore /p:Configuration=Release +Write-Host "Retrieving current version from nbgv" -ForegroundColor Magenta +$gitVerJson = (&nbgv get-version -f json) | ConvertFrom-Json +$version = $gitVerJson.NuGetPackageVersion +$version -# Build single-exe packaged projects -Write-Output "Publishing SingleFile Projects" -New-Item -Path "$Out" -Name "bin" -ItemType "directory" -$BinOut = "$Out\bin" -dotnet publish -v minimal -c Release -r win-x64 --self-contained=true "$PSScriptRoot\src\Squirrel.CommandLine.Windows\Squirrel.CommandLine.Windows.csproj" -o "$Out" -dotnet publish -v minimal -c Release -r win-x86 --self-contained=true "$PSScriptRoot\src\Update.Windows\Update.Windows.csproj" -o "$Out" +# Build solution with msbuild as dotnet can't build C++ +Write-Host "Building Solution" -ForegroundColor Magenta +msbuild /verbosity:minimal /restore /p:Configuration=Release -# Copy over all files we need -Write-Output "Copying files to all the right places" -Copy-Item -Path "$PSScriptRoot\vendor\wix\*" -Destination "$BinOut" -Recurse -Copy-Item "$In\Win32\Setup.exe" -Destination "$BinOut" -Copy-Item "$In\Win32\StubExecutable.exe" -Destination "$BinOut" -Copy-Item "$PSScriptRoot\vendor\rcedit.exe" -Destination "$BinOut" -Copy-Item "$PSScriptRoot\vendor\signtool.exe" -Destination "$BinOut" -Copy-Item -Path "$PSScriptRoot\vendor\7za.exe" -Destination "$BinOut" +# Build single-exe packaged projects and drop into nupkg +Write-Host "Extracting Generated Packages" -ForegroundColor Magenta +Set-Location "$PSScriptRoot\build\Release" +seven x csq*.nupkg -ocsq +seven x Clowd.Squirrel*.nupkg -osquirrel +Remove-Item *.nupkg -# Clean up files we do not need to create a nuget package -Write-Output "Cleaning up intermediate files" -Remove-Item "$Out\*.pdb" -Remove-Item "$BinOut\*.pdb" -Remove-Item "$Out\SquirrelLib.xml" -Remove-Item "$In\..\obj" -Recurse -Remove-Item "$In\Win32" -Recurse -Remove-Item "$In\net6.0-windows" -Recurse +Write-Host "Publishing SingleFile Projects" -ForegroundColor Magenta +$ToolsDir = "csq\tools\net6.0\any" +dotnet publish -v minimal -c Release -r win-x86 --self-contained "$PSScriptRoot\src\Update.Windows\Update.Windows.csproj" -o "$ToolsDir" +dotnet publish -v minimal -c Release -r osx.10.12-x64 --self-contained "$PSScriptRoot\src\Update.OSX\Update.OSX.csproj" -o "$ToolsDir" -Write-Output "Done." +Write-Host "Copying Tools" -ForegroundColor Magenta +New-Item -Path "squirrel" -Name "tools" -ItemType "directory" +Copy-Item -Path "$ToolsDir\*" -Destination "squirrel\tools" -Recurse +Write-Host "Re-assembling Packages" -ForegroundColor Magenta +seven a "csq.$version.nupkg" -tzip "$PSScriptRoot\build\Release\csq\*" +seven a "Clowd.Squirrel.$version.nupkg" -tzip "$PSScriptRoot\build\Release\squirrel\*" + +Write-Host "Done." -ForegroundColor Magenta diff --git a/gon.config.json b/gon.config.json index f4f267c0..f84f6a25 100644 --- a/gon.config.json +++ b/gon.config.json @@ -1,8 +1,7 @@ { "source": [ - "./osx-build/SquirrelMac", - "./osx-build/UpdateMac", - "./vendor/7zz" + "./squirrel/tools/UpdateMac", + "./squirrel/tools/7zz" ], "bundle_id": "com.caesay.squirrel", "sign": { @@ -10,6 +9,6 @@ "entitlements_file": "Squirrel.entitlements" }, "zip": { - "output_path": "squirrel-osx-x64.zip" + "output_path": "signed.zip" } } \ No newline at end of file diff --git a/pack.cmd b/pack.cmd deleted file mode 100644 index b746ae55..00000000 --- a/pack.cmd +++ /dev/null @@ -1 +0,0 @@ -powershell -ExecutionPolicy Bypass -File ./pack.ps1 \ No newline at end of file diff --git a/pack.ps1 b/pack.ps1 deleted file mode 100644 index f53e8860..00000000 --- a/pack.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -using namespace System.IO -using namespace System.Text.RegularExpressions - -Set-Location "$PSScriptRoot" -$ErrorActionPreference = "Stop" - -# get current git version -Write-Host "Retrieving current version from nbgv" -ForegroundColor Magenta -$gitVerJson = (&nbgv get-version -f json) | ConvertFrom-Json -$version = $gitVerJson.NuGetPackageVersion -$public = $gitVerJson.PublicRelease - -# build nuget package -Write-Host "Building nuget package v$version" -ForegroundColor Magenta -& "$PSScriptRoot\vendor\NuGet.exe" pack "$PSScriptRoot\src\Clowd.Squirrel.nuspec" ` --BasePath "$PSScriptRoot\src" ` --OutputDirectory "$PSScriptRoot\build" ` --Version $version - -# build zip for github releases -Write-Host "Creating tools zip" -ForegroundColor Magenta -& "$PSScriptRoot\vendor\7zip\7z.exe" a "$PSScriptRoot\build\SquirrelTools-$version.zip" -tzip -aoa -y -mmt "$PSScriptRoot\build\publish\*" - -if ($public) { - Write-Host "This is a public release. README has been updated." -ForegroundColor Magenta - # update readme examples with latest version - $readmePath = "$PSScriptRoot\README.md" - $newText = [Regex]::Replace([File]::ReadAllText($readmePath), "Clowd\.Squirrel\\.+?\\tools", "clowd.squirrel\$version\tools", [RegexOptions]::Multiline + [RegexOptions]::IgnoreCase) - [File]::WriteAllText($readmePath, $newText) -} \ No newline at end of file diff --git a/src/Squirrel.CommandLine/HelperFile.cs b/src/Squirrel.CommandLine/HelperFile.cs index aa229e00..f57fc647 100644 --- a/src/Squirrel.CommandLine/HelperFile.cs +++ b/src/Squirrel.CommandLine/HelperFile.cs @@ -28,11 +28,10 @@ namespace Squirrel.CommandLine { #if DEBUG AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "publish"); + AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "Release", "squirrel", "tools"); AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor"); - AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "7zip"); AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "wix"); #endif - AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "bin"); AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "wix"); }