-
Notifications
You must be signed in to change notification settings - Fork 0
150 lines (128 loc) · 5.2 KB
/
Copy pathrelease.yml
File metadata and controls
150 lines (128 loc) · 5.2 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
# GitHub Actions workflow for building and releasing a DLL
name: Build and Release DLL
on:
push:
branches:
- 'stable' # Trigger on push to any branch
workflow_dispatch:
permissions:
contents: write # Grant write permissions to contents
env:
SLN_NAME: TLibrary.sln # Solution file name
DLL_NAME: TLibrary.dll # DLL file name
DLL_PATH: ./TLibrary/bin/Release/net48/TLibrary.dll # Path to the main DLL
COMMIT_EXTRA_DESC: ""
jobs:
# Job 1.
build:
runs-on: windows-latest # Use the latest Windows runner
steps:
# Step 1: Checkout the code
- name: Checkout Code
uses: actions/checkout@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
}
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
# Step 9: Copy the original ZIP and insert the built DLL
- name: Modify ZIP with Built DLL
run: |
$zipFilePath = "./assets./libraries.zip"
$dllPath = "${{ env.DLL_PATH }}"
$outputZipFilePath = "./TLibrary/bin/Release/net48/libraries.zip"
# Extract original ZIP contents (if needed)
Write-Output "Extracting ZIP file: $zipFilePath"
Expand-Archive -Path $zipFilePath -DestinationPath "./TLibrary/bin/Release/net48/extracted-folder"
# Copy the newly built DLL into the extracted folder
Write-Output "Copying DLL into extracted folder"
Copy-Item $dllPath -Destination "./TLibrary/bin/Release/net48/extracted-folder/TLibrary.dll"
# Recreate the ZIP with the DLL included
Write-Output "Creating modified ZIP file"
Compress-Archive -Path "./TLibrary/bin/Release/net48/extracted-folder/*" -DestinationPath $outputZipFilePath
# Step 10: Create GitHub Release and Upload Assets
- name: Create GitHub Release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228
with:
tag_name: ${{ env.DLL_VERSION }} # Use the extracted 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 }}
./TLibrary/bin/Release/net48/libraries.zip