-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (133 loc) · 5.11 KB
/
Copy pathrelease.yml
File metadata and controls
157 lines (133 loc) · 5.11 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Release version (for example 5.0.0 or v5.0.0)"
required: true
prerelease:
description: "Mark the GitHub release as a prerelease"
required: false
default: false
type: boolean
permissions:
contents: write
jobs:
release:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve release metadata
id: meta
shell: pwsh
run: |
[xml]$project = Get-Content 'OpenNotes.csproj'
$projectVersion = $project.Project.PropertyGroup.Version | Select-Object -First 1
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$inputVersion = "${{ inputs.version }}".Trim()
if ([string]::IsNullOrWhiteSpace($inputVersion)) {
throw "workflow_dispatch requires a version input."
}
$version = $inputVersion.TrimStart('v')
$tag = "v$version"
$prerelease = if ("${{ inputs.prerelease }}" -eq "true") { "true" } else { "false" }
}
else {
$tag = "${{ github.ref_name }}"
$version = $tag.TrimStart('v')
$prerelease = "false"
}
$assemblyVersion = if ($version -match '^\d+\.\d+\.\d+$') {
"$version.0"
}
elseif ($version -match '^\d+\.\d+\.\d+\.\d+$') {
$version
}
else {
throw "Version '$version' must look like x.y.z or x.y.z.w."
}
$portableName = "OpenNotes-Portable-win-x64-$version.zip"
$installerName = "OpenNotes-Setup-$version.exe"
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
"assembly_version=$assemblyVersion" >> $env:GITHUB_OUTPUT
"portable_name=$portableName" >> $env:GITHUB_OUTPUT
"installer_name=$installerName" >> $env:GITHUB_OUTPUT
"prerelease=$prerelease" >> $env:GITHUB_OUTPUT
"project_version=$projectVersion" >> $env:GITHUB_OUTPUT
- name: Create release tag for manual runs
if: github.event_name == 'workflow_dispatch'
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
if (git rev-parse "${{ steps.meta.outputs.tag }}" 2>$null) {
throw "Tag ${{ steps.meta.outputs.tag }} already exists."
}
git tag "${{ steps.meta.outputs.tag }}"
git push origin "${{ steps.meta.outputs.tag }}"
- name: Setup .NET 8
uses: actions/setup-dotnet@v5
with:
dotnet-version: "8.0.x"
- name: Install Inno Setup
shell: pwsh
run: choco install innosetup --no-progress -y
- name: Restore
run: dotnet restore .\OpenNotes.csproj
- name: Publish app
shell: pwsh
run: >
dotnet publish .\OpenNotes.csproj
-c Release
-r win-x64
--self-contained true
-o publish
-p:Version=${{ steps.meta.outputs.version }}
-p:InformationalVersion=${{ steps.meta.outputs.version }}
-p:AssemblyVersion=${{ steps.meta.outputs.assembly_version }}
-p:FileVersion=${{ steps.meta.outputs.assembly_version }}
- name: Build installer
shell: pwsh
run: >
& "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe" .\installer.iss
/DMyAppVersion=${{ steps.meta.outputs.version }}
/DMyAppOutputBaseFilename=OpenNotes-Setup-${{ steps.meta.outputs.version }}
- name: Package portable build
shell: pwsh
run: Compress-Archive -Path .\publish\* -DestinationPath ".\${{ steps.meta.outputs.portable_name }}" -Force
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.installer_name }}
path: .\installer_output\${{ steps.meta.outputs.installer_name }}
- name: Upload portable artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.portable_name }}
path: .\${{ steps.meta.outputs.portable_name }}
- name: Publish GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.meta.outputs.tag }}
name: OpenNotes ${{ steps.meta.outputs.version }}
prerelease: ${{ steps.meta.outputs.prerelease }}
generate_release_notes: true
files: |
.\installer_output\${{ steps.meta.outputs.installer_name }}
.\${{ steps.meta.outputs.portable_name }}
- name: Summarize downloads
shell: pwsh
run: |
@"
## Release outputs
- Installer artifact: `${{ steps.meta.outputs.installer_name }}`
- Portable artifact: `${{ steps.meta.outputs.portable_name }}`
- Release tag: `${{ steps.meta.outputs.tag }}`
"@ >> $env:GITHUB_STEP_SUMMARY