-
Notifications
You must be signed in to change notification settings - Fork 2
110 lines (90 loc) · 3.66 KB
/
MSBuild.yml
File metadata and controls
110 lines (90 loc) · 3.66 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
name: MSBuild
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
env:
SOLUTION_FILE_PATH: .\VC
BUILD_CONFIGURATION: Release
permissions:
contents: write
jobs:
build:
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Compute version
id: ver
shell: pwsh
run: |
$isRelease = ('${{ github.event_name }}' -eq 'push' -and '${{ github.ref }}' -eq 'refs/heads/master') -or `
'${{ github.event_name }}' -eq 'workflow_dispatch'
$tmp = Get-Content -Path 'Version/resource_version2.tmp' -Raw
$major = [regex]::Match($tmp, 'VERSION_MAJOR\s+(\d+)').Groups[1].Value
$minor = [regex]::Match($tmp, 'VERSION_MINOR\s+(\d+)').Groups[1].Value
$y = '${{ github.run_number }}'
$sha = '${{ github.sha }}'.Substring(0, 8)
$version = "$major.$minor.$y"
$tag = "v$version"
Write-Host "Computed version: $version (release=$isRelease, sha=$sha)"
"version=$version" >> $env:GITHUB_OUTPUT
"tag=$tag" >> $env:GITHUB_OUTPUT
"sha=$sha" >> $env:GITHUB_OUTPUT
"is_release=$($isRelease.ToString().ToLower())" >> $env:GITHUB_OUTPUT
# On release runs, bake y into the template so the DLL's file version matches the tag.
if ($isRelease) {
$tmp = $tmp -replace '(VERSION_REVISION\s+)\d+', "`${1}$y"
[IO.File]::WriteAllText(
(Resolve-Path 'Version/resource_version2.tmp'),
$tmp,
(New-Object System.Text.UTF8Encoding $false))
}
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v3
- name: Build
working-directory: ${{ github.workspace }}
run: msbuild /m /p:Configuration=${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_FILE_PATH }}
- name: Bundle build output
shell: pwsh
run: |
$name = if ('${{ steps.ver.outputs.is_release }}' -eq 'true') {
"Addictol-${{ steps.ver.outputs.version }}"
} else {
"addictol-${{ steps.ver.outputs.sha }}"
}
New-Item -ItemType Directory -Path "$name\f4se\plugins" -Force | Out-Null
New-Item -ItemType Directory -Path "$name\scripts" -Force | Out-Null
Get-ChildItem -Recurse -Path '.\.Build\F4SE\Plugins' `
-Include 'Addictol.dll','Addictol.pdb','Addictol.toml','Addictol_FacegenExceptions.ini','Addictol_SNCT.ini' |
ForEach-Object { Copy-Item -Path $_.FullName -Destination "$name\f4se\plugins\$($_.Name)" -Force }
if (Test-Path '.\.Build\Scripts') {
Copy-Item -Path '.\.Build\Scripts\*' -Destination "$name\scripts" -Recurse -Force
}
"BUNDLE_NAME=$name" >> $env:GITHUB_ENV
- name: Upload PR / non-release artifact
if: steps.ver.outputs.is_release != 'true'
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUNDLE_NAME }}
path: ${{ env.BUNDLE_NAME }}
- name: Zip release artifact
if: steps.ver.outputs.is_release == 'true'
shell: pwsh
run: Compress-Archive -Path "$env:BUNDLE_NAME\*" -DestinationPath "$env:BUNDLE_NAME.zip" -Force
- name: Create GitHub Release
if: steps.ver.outputs.is_release == 'true'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.ver.outputs.tag }}
name: ${{ steps.ver.outputs.tag }}
body: |
Built from ${{ github.sha }}.
Internal version: `${{ steps.ver.outputs.version }}`
generate_release_notes: true
prerelease: true
fail_on_unmatched_files: true
files: ${{ env.BUNDLE_NAME }}.zip