Build and package for release #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and package for release | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
environment: | |
description: 'Environment to deploy' | |
required: false | |
default: 'staging' | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore src\CanIUse\Community.PowerToys.Run.Plugin.CanIUse\Community.PowerToys.Run.Plugin.CanIUse.csproj | |
- name: Create temporary solution for building | |
run: dotnet new sln -n "BuildTemporary" | |
- name: Add project to temporary solution | |
run: dotnet sln "BuildTemporary.sln" add src\CanIUse\Community.PowerToys.Run.Plugin.CanIUse\Community.PowerToys.Run.Plugin.CanIUse.csproj | |
- name: Build project | |
run: dotnet build "BuildTemporary.sln" --configuration Release --output ./build_output/CanIUse | |
- name: Create ZIP of build output | |
shell: pwsh # Use PowerShell shell | |
run: | | |
$sourcePath = ".\build_output" | |
$zipPath = "CanIUse.zip" | |
# Get all files, including those in subdirectories, and filter out the unwanted files | |
Get-ChildItem $sourcePath -File -Recurse | Where-Object { | |
$_.Name -notin @("Wox.Plugin.dll", "Wox.Infrastructure.dll", "PowerToys.Common.UI.dll", "PowerToys.ManagedCommon.dll", "PowerToys.Settings.UI.Lib.dll") | |
} | ForEach-Object { | |
# Get the relative path of the file to preserve folder structure | |
$relativePath = $_.FullName.Substring($sourcePath.Length + 1) | |
# Use -Update with Compress-Archive to preserve folder structure | |
Compress-Archive -Path $_.FullName -DestinationPath $zipPath -Update -EntryName $relativePath | |
} | |
- name: Upload project artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Package | |
path: CanIUse.zip |