|
9 | 9 |
|
10 | 10 | jobs: |
11 | 11 | build-and-publish: |
12 | | - runs-on: windows-latest |
| 12 | + runs-on: ubuntu-latest # Use a Linux runner |
13 | 13 |
|
14 | 14 | steps: |
15 | 15 | - name: Checkout code |
@@ -43,48 +43,46 @@ jobs: |
43 | 43 |
|
44 | 44 | - name: Get Next Version and Create Tag |
45 | 45 | id: get_version |
46 | | - shell: pwsh |
| 46 | + shell: bash # Use bash for git commands |
47 | 47 | run: | |
48 | 48 | # 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 |
51 | 51 | # If no tags exist, start with 3.4.0 |
52 | | - $nextVersion = "3.4.0" |
53 | | - } else { |
| 52 | + nextVersion="3.4.0" |
| 53 | + else |
54 | 54 | # 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 |
59 | 68 |
|
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 | | - |
70 | 69 | # Create and push the tag |
71 | 70 | git tag "v$nextVersion" |
72 | 71 | git push origin "v$nextVersion" |
73 | 72 |
|
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" |
76 | 74 |
|
77 | 75 | - name: Get Release Notes (from releasenotes.md) |
78 | 76 | id: get_release_notes |
79 | | - shell: pwsh |
| 77 | + shell: bash |
80 | 78 | 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" |
85 | 83 |
|
86 | 84 | - 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. |
88 | 86 |
|
89 | 87 | - name: Push NuGet package to NuGet.org |
90 | 88 | run: dotnet nuget push "*.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |
|
0 commit comments