-
Notifications
You must be signed in to change notification settings - Fork 3
150 lines (134 loc) · 7.09 KB
/
Copy pathManualRelease.yml
File metadata and controls
150 lines (134 loc) · 7.09 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
name: "Manual Release"
on:
workflow_dispatch:
inputs:
buildConfig:
description: "Build configuration"
required: true
default: "Release"
type: choice
options:
- "Release"
- "Debug"
releaseTypeTag: # Use -alpha, -beta, or -rc for pre-release. An empty string for stable.
description: "Release type tag"
required: true
default: "beta"
type: choice
options:
- "alpha"
- "beta"
- "RC"
- ""
runLinters:
description: "Run Linters"
required: false
default: false
type: boolean
unitTests:
description: "Run Unit Tests"
required: false
default: false
type: boolean
publish:
description: "Publish to NuGet"
required: true
default: true
type: boolean
jobs:
Build:
name: "Build, Test, and Publish Project"
runs-on: "windows-latest"
defaults:
run:
shell: "pwsh"
strategy:
matrix:
BUILD_PLATFORM: [x86, x64]
env:
BUILD_PLATFORM: ${{matrix.BUILD_PLATFORM}}
SOLUTION: ProcessMemory.sln
CSPROJECT: src/ProcessMemory/ProcessMemory.csproj
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{github.ref}}
- name: Read and process version.txt
id: Get-Version
run: |
$baseVersion = (Get-Content "version.txt" -Raw).Split('.')
$versionBuild = (${{vars.BUILD_NUMBER}} + 1)
"VersionMajor=$($baseVersion[0])" >> $env:GITHUB_OUTPUT
"VersionMinor=$($baseVersion[1])" >> $env:GITHUB_OUTPUT
"VersionPatch=$($baseVersion[2])" >> $env:GITHUB_OUTPUT
"VersionBuild=$versionBuild" >> $env:GITHUB_OUTPUT
"VersionPreRelease=${{inputs.releaseTypeTag}}" >> $env:GITHUB_OUTPUT
"VersionCommitHash=$(("${{github.sha}}".substring(0, 7)))" >> $env:GITHUB_OUTPUT
- name: Get SemVer
uses: Squirrelies/CI-CD/GetSemVerString@main
id: Get-SemVer
with:
versionMajor: ${{steps.Get-Version.outputs.VersionMajor}}
versionMinor: ${{steps.Get-Version.outputs.VersionMinor}}
versionPatch: ${{steps.Get-Version.outputs.VersionPatch}}
preRelease: ${{steps.Get-Version.outputs.VersionPreRelease}}
versionBuild: ${{steps.Get-Version.outputs.VersionBuild}}
commitHash: ${{steps.Get-Version.outputs.VersionCommitHash}}
- name: Set versioning environment variable
run: |
echo 'VERSION=${{steps.Get-SemVer.outputs.Version}}' >> $env:GITHUB_ENV
echo 'FILEVERSION=${{steps.Get-Version.outputs.VersionMajor}}.${{steps.Get-Version.outputs.VersionMinor}}.${{steps.Get-Version.outputs.VersionPatch}}.${{steps.Get-Version.outputs.VersionBuild}}' >> $env:GITHUB_ENV
echo 'ASSEMBLYVERSION=${{steps.Get-Version.outputs.VersionMajor}}.${{steps.Get-Version.outputs.VersionMinor}}.0.0' >> $env:GITHUB_ENV
- name: Build Native Library
uses: Squirrelies/CI-CD/BuildMSYS2CMakeVCPkgProject@main
id: build-native-library
env:
RC_VERSION: ${{steps.Get-SemVer.outputs.Version}}
RC_VERSION_MAJOR: ${{steps.Get-Version.outputs.VersionMajor}}
RC_VERSION_MINOR: ${{steps.Get-Version.outputs.VersionMinor}}
RC_VERSION_PATCH: ${{steps.Get-Version.outputs.VersionPatch}}
RC_VERSION_BUILD: ${{steps.Get-Version.outputs.VersionBuild}}
RC_VERSION_PRERELEASE_TAG: ${{steps.Get-Version.outputs.VersionPreRelease}}
RC_VERSION_BUILD_HASH: ${{steps.Get-Version.outputs.VersionCommitHash}}
with:
root-path: ./src/ProcessMemoryNative
msys2-msystem: ${{ matrix.BUILD_PLATFORM == 'x64' && 'clang64' || 'mingw32' }}
msys2-packages: ${{ matrix.BUILD_PLATFORM == 'x64' && 'base-devel mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-cmake mingw-w64-x86_64-clang-tools-extra' || 'base-devel mingw-w64-i686-toolchain mingw-w64-i686-cmake mingw-w64-i686-clang mingw-w64-i686-lld mingw-w64-i686-clang-tools-extra mingw-w64-i686-libc++ mingw-w64-i686-headers-git' }}
#vcpkg-root: C:/VCPkg
preset-configuration: ${{inputs.buildConfig}}
preset-configuration-tidy: ${{ inputs.runLinters == true && format('{0}-Tidy', inputs.buildConfig) || ''}}
run-unit-tests: ${{inputs.unitTests}}
additional-cmake-args: -DARCH=${{matrix.BUILD_PLATFORM}} -DRC_VERSION=${{steps.Get-SemVer.outputs.Version}} -DRC_VERSION_MAJOR=${{steps.Get-Version.outputs.VersionMajor}} -DRC_VERSION_MINOR=${{steps.Get-Version.outputs.VersionMinor}} -DRC_VERSION_PATCH=${{steps.Get-Version.outputs.VersionPatch}} -DRC_VERSION_BUILD=${{steps.Get-Version.outputs.VersionBuild}} -DRC_VERSION_PRERELEASE_TAG=${{steps.Get-Version.outputs.VersionPreRelease}} -DRC_VERSION_BUILD_HASH=${{steps.Get-Version.outputs.VersionCommitHash}}
- name: Setup NuGet
uses: NuGet/setup-nuget@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-quality: "ga"
- name: Restore NuGet Packages
run: dotnet restore $env:SOLUTION --verbosity normal
- name: Build .NET Project
run: dotnet build $env:SOLUTION /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=$env:VERSION;FILEVERSION=$env:FILEVERSION;ASSEMBLYVERSION=$env:ASSEMBLYVERSION" --no-restore --verbosity normal
- name: Run .NET Project Unit Tests
if: ${{ !cancelled() && inputs.unitTests == 'true' }}
run: dotnet test /p:"Configuration=${{inputs.buildConfig}};Platform=$env:BUILD_PLATFORM;VERSION=$env:VERSION;FILEVERSION=$env:FILEVERSION;ASSEMBLYVERSION=$env:ASSEMBLYVERSION" --no-restore --no-build --verbosity normal
- name: Publish NuGet Package
if: ${{ !cancelled() && inputs.publish == 'true' }}
run: nuget push **\*.nupkg -Source "https://api.nuget.org/v3/index.json" -ApiKey "${{secrets.NUGET_API_KEY}}" -SkipDuplicate
- name: Update build number variable
if: ${{ !cancelled() && inputs.publish == 'true' }} # Only update the build number if the NuGet package was published
env:
GH_TOKEN: ${{ secrets.GH_VARIABLE_RW_TOKEN }}
run: gh variable set BUILD_NUMBER -b${{ steps.Get-Version.outputs.VersionBuild }}
- name: Upload publish artifacts
uses: actions/upload-artifact@v4
with:
name: ProcessMemory${{ env.BUILD_PLATFORM == 'x64' && '64' || '32'}}_v${{env.VERSION}}
path: |
src/ProcessMemory/bin/${{env.BUILD_PLATFORM}}/${{inputs.buildConfig}}/netstandard2.1/ProcessMemory${{ env.BUILD_PLATFORM == 'x64' && '64' || '32'}}.dll
src/ProcessMemory/bin/${{env.BUILD_PLATFORM}}/${{inputs.buildConfig}}/netstandard2.1/ProcessMemory${{ env.BUILD_PLATFORM == 'x64' && '64' || '32'}}.pdb
src/ProcessMemoryNative/build/ProcessMemory.Native.${{ env.BUILD_PLATFORM == 'x64' && '64' || '32'}}.dll
src/ProcessMemoryNative/build/ProcessMemory.Native.${{ env.BUILD_PLATFORM == 'x64' && '64' || '32'}}.pdb