|
13 | 13 | - name: Checkout code |
14 | 14 | uses: actions/checkout@v4 |
15 | 15 |
|
| 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 | + |
16 | 75 | - name: Setup .NET |
17 | 76 | uses: actions/setup-dotnet@v4 |
18 | 77 | with: |
|
35 | 94 | cd SourceServerManager/Installer |
36 | 95 | makensis Installer.nsi |
37 | 96 | |
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 | | - |
46 | 97 | - name: Create Release |
47 | 98 | id: create_release |
48 | 99 | uses: actions/create-release@v1 |
|
0 commit comments