Release workflow: fix PowerShell shenanigans (#214) #11
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: Release | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-*' | |
jobs: | |
build-and-publish: | |
name: Build and Publish | |
runs-on: windows-2022 | |
timeout-minutes: 15 | |
permissions: | |
contents: | |
write # Create release | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: ./.github/actions/setup-swift | |
- name: Compute Version | |
id: version | |
shell: pwsh | |
run: | | |
$TagName = "${{ github.ref_name }}" | |
if ($TagName.StartsWith("v")) { $SemVer = $TagName.Substring(1) } | |
else { | |
$CommitHash = "${{ github.sha }}".Substring(0, 7) | |
$SemVer = "0.0.0-$CommitHash" | |
} | |
echo "::set-output name=semver::$SemVer" | |
- name: CMake Configure | |
working-directory: Generator | |
shell: pwsh | |
run: cmake --preset release | |
- name: CMake Build | |
working-directory: Generator | |
shell: pwsh | |
run: cmake --build --preset release | |
- name: Create NuGet Package | |
working-directory: Generator | |
shell: pwsh | |
run: | | |
$OutputPath = "${{ github.workspace }}\SwiftWinRT.nupkg" | |
& .\Create-NuGetPackage.ps1 ` | |
-NativeExe "build\release\Sources\SwiftWinRT\SwiftWinRT.exe" ` | |
-Version "${{ steps.version.outputs.semver }}" ` | |
-OutputPath $OutputPath | |
(Get-FileHash $OutputPath).Hash | Out-File -FilePath "$OutputPath.sha256" | |
- name: Create GitHub Release | |
if: github.event_name == 'push' | |
shell: pwsh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Create Release | |
$TagName = "${{ github.ref_name }}" | |
$SemVer = "${{ steps.version.outputs.semver }}" | |
$RepositoryUrl = "${{ github.repository }}" | |
$ExtraArgs = @() | |
if ($SemVer.StartsWith("0.") -or $SemVer.Contains("-")) { $ExtraArgs += "--prerelease" } | |
& gh release create $TagName --repo $RepositoryUrl --title $SemVer --generate-notes @ExtraArgs | |
& gh release upload $TagName SwiftWinRT.nupkg --repo $RepositoryUrl | |
& gh release upload $TagName SwiftWinRT.nupkg.sha256 --repo $RepositoryUrl |