Skip to content

Commit 9c227db

Browse files
committed
Update release.yml
1 parent c1c861d commit 9c227db

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,65 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v4
1515

16+
- name: Get tag name and version
17+
id: tag
18+
run: |
19+
$tagName = $env:GITHUB_REF -replace 'refs/tags/', ''
20+
$version = $tagName -replace '^v', ''
21+
if ($version -notmatch '^\d+\.\d+(\.\d+)?(\.\d+)?$') {
22+
$version = "$version.0.0"
23+
}
24+
if (($version.Split('.').Count) -eq 2) {
25+
$version = "$version.0.0"
26+
} elseif (($version.Split('.').Count) -eq 3) {
27+
$version = "$version.0"
28+
}
29+
echo "tag_name=$tagName" >> $env:GITHUB_OUTPUT
30+
echo "release_name=$tagName" >> $env:GITHUB_OUTPUT
31+
echo "version=$version" >> $env:GITHUB_OUTPUT
32+
echo "Version will be set to: $version"
33+
shell: pwsh
34+
35+
- name: Update version in app.manifest
36+
run: |
37+
$manifestPath = "SourceServerManager/app.manifest"
38+
$version = "${{ steps.tag.outputs.version }}"
39+
$content = Get-Content $manifestPath -Raw
40+
$content = $content -replace 'version="[\d\.]+"', "version=`"$version`""
41+
Set-Content $manifestPath -Value $content -NoNewline
42+
echo "Updated app.manifest version to: $version"
43+
shell: pwsh
44+
45+
- name: Update version in project file
46+
run: |
47+
$projectPath = "SourceServerManager/SourceServerManager.csproj"
48+
$version = "${{ steps.tag.outputs.version }}"
49+
[xml]$project = Get-Content $projectPath
50+
51+
# Find or create the first PropertyGroup
52+
$propertyGroup = $project.Project.PropertyGroup[0]
53+
if ($null -eq $propertyGroup) {
54+
$propertyGroup = $project.CreateElement("PropertyGroup")
55+
$project.Project.AppendChild($propertyGroup) | Out-Null
56+
}
57+
58+
# Add or update version properties
59+
$versionProperties = @('Version', 'AssemblyVersion', 'FileVersion', 'AssemblyFileVersion')
60+
foreach ($prop in $versionProperties) {
61+
$existingProp = $propertyGroup.SelectSingleNode($prop)
62+
if ($null -eq $existingProp) {
63+
$newProp = $project.CreateElement($prop)
64+
$newProp.InnerText = $version
65+
$propertyGroup.AppendChild($newProp) | Out-Null
66+
} else {
67+
$existingProp.InnerText = $version
68+
}
69+
}
70+
71+
$project.Save($projectPath)
72+
echo "Updated project file version to: $version"
73+
shell: pwsh
74+
1675
- name: Setup .NET
1776
uses: actions/setup-dotnet@v4
1877
with:
@@ -35,14 +94,6 @@ jobs:
3594
cd SourceServerManager/Installer
3695
makensis Installer.nsi
3796
38-
- name: Get tag name
39-
id: tag
40-
run: |
41-
$tagName = $env:GITHUB_REF -replace 'refs/tags/', ''
42-
echo "tag_name=$tagName" >> $env:GITHUB_OUTPUT
43-
echo "release_name=$tagName" >> $env:GITHUB_OUTPUT
44-
shell: pwsh
45-
4697
- name: Create Release
4798
id: create_release
4899
uses: actions/create-release@v1

0 commit comments

Comments
 (0)