Merge branch '2.x' of https://github.com/Sidekick-Poe/Sidekick into 2.x #14
Workflow file for this run
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: WPF Release | |
on: | |
push: | |
tags: [v*] | |
jobs: | |
wpf-release: | |
runs-on: windows-latest | |
steps: | |
- name: Git - Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: GitVersion - Install | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: '5.x' | |
- name: GitVersion - Execute | |
id: gitversion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
useConfigFile: true | |
additionalArguments: '/updateprojectfiles' | |
- name: Environment - Build Number | |
uses: myci-actions/export-env-var@1 | |
with: | |
name: BUILD_NUMBER | |
value: ${{ steps.gitversion.outputs.fullSemVer }} | |
- name: Environment - Github Token | |
uses: myci-actions/export-env-var@1 | |
with: | |
name: GITHUB_TOKEN | |
value: ${{ github.token }} | |
- name: Copy files | |
shell: pwsh | |
run: | | |
Push-Location "src/Sidekick.Wpf" | |
try { | |
Copy-Item -Path "../Sidekick.Common.Blazor/wwwroot/*" -Destination "./wwwroot" -Recurse | |
} finally { | |
Pop-Location | |
} | |
- name: .NET 7 - Setup | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 7.x | |
- name: .NET - Restore | |
run: dotnet restore | |
- name: .NET - Build | |
run: dotnet build --no-restore | |
- name: .NET - Tests | |
run: dotnet test --no-build --verbosity normal | |
- name: Setup Git | |
run: | | |
git config --global url."https://user:${{ secrets.GITHUB_TOKEN }}@github".insteadOf https://github | |
git config --global user.name github-actions | |
git config --global user.email [email protected] | |
- name: Setup SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DEPLOY_RELEASE_KEY }} | |
- name: Run release script | |
shell: pwsh | |
run: | | |
$applicationName = "Sidekick" | |
Write-Output "Application name: $applicationName" | |
$projectDirectory = "src/Sidekick.Wpf" | |
Write-Output "Project directory: $projectDirectory" | |
$publishDirectory = "$projectDirectory/bin/publish" | |
Write-Output "Publish directory: $publishDirectory" | |
$version = "${{ steps.gitversion.outputs.majorMinorPatch }}.${{ steps.gitversion.outputs.buildMetaData }}" | |
Write-Output "Version: $version" | |
$deployRepository = "[email protected]:Sidekick-Poe/Sidekick-Release.git" | |
Write-Output "Deploy repository: $deployRepository" | |
Write-Output "Working directory: $pwd" | |
# Find MSBuild. | |
$msBuildPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` | |
-latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe ` | |
-prerelease | select-object -first 1 | |
Write-Output "MSBuild path: $((Get-Command $msBuildPath).Path)" | |
Set-StrictMode -version 2.0 | |
$ErrorActionPreference = "Stop" | |
# Publish the application. | |
Push-Location $projectDirectory | |
try { | |
Write-Output "Publishing:" | |
& $msBuildPath /target:publish /p:PublishProfile=ClickOnceRelease /p:ApplicationVersion=$version /p:Configuration=Release /p:PublishDir=bin/publish /p:PublishUrl=bin/publish | |
} | |
finally { | |
Pop-Location | |
} | |
# Clone `gh-pages` branch. | |
git clone $deployRepository -b gh-pages --single-branch "dist" | |
Push-Location "dist" | |
try { | |
Write-Output "Removing previous files..." | |
if (Test-Path "Application Files") { | |
Remove-Item -Path "Application Files" -Recurse | |
} | |
if (Test-Path "$applicationName.application") { | |
Remove-Item -Path "$applicationName.application" | |
} | |
Write-Output "Copying new files..." | |
Copy-Item -Path "../$publishDirectory/Application Files","../$publishDirectory/$applicationName.application" -Destination . -Recurse | |
# Stage and commit. | |
# Write-Output "Staging..." | |
git add -A | |
# Write-Output "Committing..." | |
git commit -m "Update to v$version" | |
# Write-Output "Pushing..." | |
git push | |
} finally { | |
Pop-Location | |
} |