-
Notifications
You must be signed in to change notification settings - Fork 2
95 lines (84 loc) · 2.82 KB
/
release-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Release & Publish
on:
workflow_dispatch:
inputs:
git_ref:
description: 'Git ref'
type: string
required: false
default: 'main'
semver:
description: 'Semantic Version (empty defaults to 0.0.0-commit)'
type: string
required: false
default: ''
publish_nuget:
description: 'Publish NuGet package'
type: boolean
required: false
default: false
jobs:
build-and-publish:
name: Build and Publish
runs-on: windows-2022
timeout-minutes: 15
permissions:
contents:
write # Create tag and release
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.git_ref }}
- name: Compute Version
id: context
shell: pwsh
run: |
$SemVer = "${{ github.event.inputs.semver }}"
if ($SemVer -eq "") {
$Commit = & git rev-parse --short=8 | Out-String
$SemVer = "0.0.0-$Commit"
}
if (-not $SemVer -matches "^v\d+\.\d+\.\d+(-\w+)?$") {
throw "Unexpected SemVer format: $SemVer"
}
Write-Output "::set-output name=tag::v$SemVer"
Write-Output "::set-output name=semver::$SemVer"
- uses: ./.github/actions/setup-swift
- 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.context.outputs.semver }}" `
-OutputPath $OutputPath
(Get-FileHash $OutputPath).Hash | Out-File -FilePath "$OutputPath.sha256"
- name: Create Git Tag
shell: pwsh
run: |
& git tag "${{ steps.context.outputs.tag }}"
& git push origin "${{ steps.context.outputs.tag }}"
- name: Create GitHub Release
if: github.event_name == 'push'
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create Release
$SemVer = "${{ steps.context.outputs.semver }}"
$TagName = "${{ steps.context.outputs.tag }}"
$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