-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (128 loc) · 5.59 KB
/
Copy pathrelease.yml
File metadata and controls
151 lines (128 loc) · 5.59 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
# GitHub Actions workflow for building and releasing a DLL
name: Build and Release DLL
on:
push:
branches:
- 'stable' # Trigger on push to any branch
permissions:
contents: write # Grant write permissions to contents
env:
SLN_NAME: TSkinManager.sln # Solution file name
DLL_NAME: TSkinManager.dll # DLL file name
LIBRARY_PATH: ./TSkinManager/bin/Release/net48/TLibrary.dll # Path to the library DLL
DLL_PATH: ./TSkinManager/bin/Release/net48/TSkinManager.dll # Path to the main DLL
COMMIT_EXTRA_DESC: |
Libraries can be found [here](https://github.com/TavstalDev/TLibrary/releases/tag/VERSION_PLACEHOLDER).
jobs:
# Job 1.
build:
runs-on: windows-latest # Use the latest Windows runner
steps:
# Step 1: Checkout the code
- name: Checkout Code
uses: actions/checkou@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0
# Step 2: Setup MSBuild for building .NET Framework
- name: Setup MSBuild
uses: microsoft/setup-msbuild@30375c66a4eea26614e0d39710365f22f8b0af57
# Step 3: Setup NuGet
- name: Setup NuGet
uses: nuget/setup-nuget@fd55a6f3b34392fa83fde1454582407d8c714123
with:
nuget-version: latest # Use the latest version of NuGet
# Step 4: Restore dependencies using NuGet
- name: Restore Dependencies
run: nuget restore ${{ env.SLN_NAME }}
# Step 5: Build the solution using MSBuild
- name: Build Solution
run: msbuild ${{ env.SLN_NAME }} /p:Configuration=Release
# Step 6: Extract DLL Version
- name: Extract DLL Version
id: extract_version
run: |
if (Test-Path $env:DLL_PATH) {
Write-Output "DLL found: $env:DLL_PATH"
$version = (Get-Item $env:DLL_PATH).VersionInfo.ProductVersion
if ($version) {
Write-Output "Extracted version: $version"
Write-Output "Setting DLL_VERSION=$version in GITHUB_ENV"
Add-Content -Path $env:GITHUB_ENV -Value "DLL_VERSION=$version"
} else {
Write-Output "FileVersion not found in the DLL metadata."
exit 1
}
} else {
Write-Output "DLL not found at path: $env:DLL_PATH"
exit 1
}
if (Test-Path $env:LIBRARY_PATH) {
Write-Output "Library DLL found: $env:LIBRARY_PATH"
$libraryVersion = (Get-Item $env:LIBRARY_PATH).VersionInfo.ProductVersion
if ($libraryVersion) {
Write-Output "Extracted library version: $libraryVersion"
Write-Output "Setting LIBRARY_VERSION=$libraryVersion in GITHUB_ENV"
$commitDesc = $env:COMMIT_EXTRA_DESC
Write-Output "Debug 1: $commitDesc"
# Replace the placeholder safely using native PowerShell
$updatedCommitDesc = $commitDesc -replace "VERSION_PLACEHOLDER", $libraryVersion
Write-Output "Debug 2: $updatedCommitDesc"
Write-Output "Debug 3: $commitDesc"
Add-Content -Path $env:GITHUB_ENV -Value "COMMIT_EXTRA_DESC=$updatedCommitDesc"
}
}
shell: powershell
# Step 7: Get the latest tag
- name: Get latest tag
id: get_latest_tag
run: |
try {
git fetch --tags
$latest_tag = git tag -l | sort -V | tail -n 1
if (-not $latest_tag) {
$latest_tag = "none"
}
} catch {
$latest_tag = "none"
}
Write-Output "Latest tag: $latest_tag"
Add-Content -Path $env:GITHUB_ENV -Value "LATEST_TAG=$latest_tag"
# Force the step to exit with a success status (0)
exit 0
shell: powershell
# Step 8: Get commit logs since the latest tag
- name: Get commit logs since the latest tag
id: get_commits
run: |
# Fetch all history
git fetch --unshallow
$repo = $env:GITHUB_REPOSITORY
if ($env:LATEST_TAG -eq "none") {
Write-Output "No previous tag found, listing all commits."
$commits = git log HEAD --pretty=format:"- [%h](https://github.com/$repo/commit/%h) - %s"
} else {
Write-Output "Getting commits since tag: $env:LATEST_TAG"
$commits = @()
git log "$env:LATEST_TAG..HEAD" --pretty=format:"- [%h](https://github.com/$repo/commit/%h) - %s" | ForEach-Object { $commits += "$_" }
}
Write-Output "Full commit log:"
Write-Output $commits
$delimiter = [guid]::NewGuid().ToString("N")
$localCommit = $commits -join "`n"
Add-Content -Path $env:GITHUB_ENV -Value "COMMITS<<$delimiter"
Add-Content -Path $env:GITHUB_ENV -Value $localCommit
Add-Content -Path $env:GITHUB_ENV -Value $delimiter
exit 0
shell: powershell
# Step 9: Create and upload GitHub release
- name: Create GitHub Release and Upload Asset
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b
with:
tag_name: ${{ env.DLL_VERSION }}
name: Build ${{ env.DLL_VERSION }}
draft: false
prerelease: true
body: |
## Changelog
${{ env.COMMIT_EXTRA_DESC }}
Changes pushed to branch `${{ github.ref_name }}`
${{ env.COMMITS }}
files: ${{ env.DLL_PATH }}