Skip to content

Commit 772f1f2

Browse files
authored
Update dotnet-desktop.yml
1 parent 8c1fca8 commit 772f1f2

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

.github/workflows/dotnet-desktop.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
build-and-publish:
12-
runs-on: windows-latest
12+
runs-on: ubuntu-latest # Use a Linux runner
1313

1414
steps:
1515
- name: Checkout code
@@ -43,48 +43,46 @@ jobs:
4343
4444
- name: Get Next Version and Create Tag
4545
id: get_version
46-
shell: pwsh
46+
shell: bash # Use bash for git commands
4747
run: |
4848
# Get the highest existing tag (if any)
49-
$latestTag = git describe --tags --abbrev=0 --match "v*" 2> $null
50-
if (-not $latestTag) {
49+
latestTag=$(git describe --tags --abbrev=0 --match "v*" 2>/dev/null)
50+
if [ -z "$latestTag" ]; then
5151
# If no tags exist, start with 3.4.0
52-
$nextVersion = "3.4.0"
53-
} else {
52+
nextVersion="3.4.0"
53+
else
5454
# If tags exist, increment based on the highest tag
55-
$versionParts = ($latestTag -replace '^v', '').Split('.')
56-
$major = [int]$versionParts[0]
57-
$minor = [int]$versionParts[1]
58-
$patch = [int]$versionParts[2]
55+
versionParts=(${latestTag//[^0-9.]/}) # Extract numbers and dots
56+
IFS='.' read -r -a versionArray <<< "$versionParts"
57+
major=${versionArray[0]}
58+
minor=${versionArray[1]}
59+
patch=${versionArray[2]}
60+
# Increment based on the highest tag.
61+
if (( major < 3 )) || (( major == 3 && minor < 4 )); then
62+
nextVersion="3.4.0" # Force to 3.4.0 if < 3.4.0
63+
else
64+
((minor++))
65+
nextVersion="$major.$minor.0"
66+
fi
67+
fi
5968
60-
# Increment the minor version, reset patch to 0. You can change this logic
61-
# to increment patch, major, etc., as needed.
62-
if ($major -lt 3 -or ($major -eq 3 -and $minor -lt 4)) {
63-
$nextVersion = "3.4.0" # Force 3.4.0 if < 3.4.0
64-
} else {
65-
$minor++
66-
$nextVersion = "$major.$minor.0"
67-
}
68-
}
69-
7069
# Create and push the tag
7170
git tag "v$nextVersion"
7271
git push origin "v$nextVersion"
7372
74-
echo "NUGET_VERSION=$nextVersion" >> $env:GITHUB_OUTPUT
75-
echo "Version is ${{ steps.get_version.outputs.NUGET_VERSION }}"
73+
echo "NUGET_VERSION=$nextVersion" >> "$GITHUB_OUTPUT"
7674
7775
- name: Get Release Notes (from releasenotes.md)
7876
id: get_release_notes
79-
shell: pwsh
77+
shell: bash
8078
run: |
81-
$releaseNotes = Get-Content releasenotes.md -Raw
82-
echo "RELEASE_NOTES<<EOF" >> $env:GITHUB_OUTPUT
83-
echo "$releaseNotes" >> $env:GITHUB_OUTPUT
84-
echo "EOF" >> $env:GITHUB_OUTPUT
79+
releaseNotes=$(cat releasenotes.md)
80+
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_OUTPUT"
81+
echo "$releaseNotes" >> "$GITHUB_OUTPUT"
82+
echo "EOF" >> "$GITHUB_OUTPUT"
8583
8684
- name: Pack NuGet package
87-
run: dotnet pack --configuration Release -o . /p:Version=${{ steps.get_version.outputs.NUGET_VERSION }} /p:PackageReleaseNotes="$([System.Security.SecurityElement]::Escape(${{ steps.get_release_notes.outputs.RELEASE_NOTES }}))"
85+
run: dotnet pack --configuration Release -o . /p:Version=${{ steps.get_version.outputs.NUGET_VERSION }} /p:PackageReleaseNotes="$(echo ${{ steps.get_release_notes.outputs.RELEASE_NOTES }} | sed -e 's/["\$`\\]/\\&/g')" #Escape properly.
8886

8987
- name: Push NuGet package to NuGet.org
9088
run: dotnet nuget push "*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate

0 commit comments

Comments
 (0)