-
Notifications
You must be signed in to change notification settings - Fork 521
78 lines (68 loc) · 2.71 KB
/
ci.yml
File metadata and controls
78 lines (68 loc) · 2.71 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
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: write
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Compute version and tag
id: version
shell: pwsh
run: |
# Check if HEAD already has a version tag
$existingTag = git tag --points-at HEAD | Where-Object { $_ -match '^v\d+\.\d+\.\d+$' } | Select-Object -First 1
if ($existingTag) {
$version = $existingTag -replace '^v', ''
} else {
$latest = git describe --tags --match "v*" --abbrev=0
if ($latest -match '^v(\d+\.\d+)\.(\d+)$') {
$version = "$($Matches[1]).$([int]$Matches[2] + 1)"
} else { throw "No valid version tag found" }
if ("${{ github.event_name }}" -eq "push" -and "${{ github.ref }}" -eq "refs/heads/master") {
Write-Host "Tag commit: v$version"
git tag "v$version"
git push origin "v$version"
}
}
if ("${{ github.event_name }}" -eq "pull_request") {
$sha = "${{ github.event.pull_request.head.sha }}".Substring(0, 8)
$fullVersion = "$version+$sha"
} else {
$fullVersion = $version
}
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "fullVersion=$fullVersion" >> $env:GITHUB_OUTPUT
Write-Host "Build version: $version, full: $fullVersion"
- name: Patch assembly version
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
$fullVersion = "${{ steps.version.outputs.fullVersion }}"
$file = "Rapr/Properties/AssemblyInfo.cs"
$content = Get-Content $file -Raw
$content = $content -replace 'AssemblyVersion\(".*?"\)', "AssemblyVersion(`"$version`")"
$content = $content -replace 'AssemblyFileVersion\(".*?"\)', "AssemblyFileVersion(`"$version`")"
$content = $content -replace 'AssemblyInformationalVersion\(".*?"\)', "AssemblyInformationalVersion(`"$fullVersion`")"
Set-Content $file $content
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup NuGet
uses: nuget/setup-nuget@v2
- name: Restore NuGet packages
run: nuget restore Rapr.sln
- name: Build
run: msbuild Rapr.sln /p:Configuration=Release /p:Platform="Any CPU" /v:minimal
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: DriverStoreExplorer-v${{ steps.version.outputs.fullVersion }}-unsigned
path: Rapr/bin/Release/