|
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | permissions: |
13 | 13 | contents: write |
| 14 | + packages: write |
14 | 15 |
|
15 | 16 | steps: |
16 | 17 | - name: Checkout code |
|
53 | 54 | echo "label=Release" >> $GITHUB_OUTPUT |
54 | 55 | elif [[ "${GITHUB_REF}" == refs/heads/release/* || "${GITHUB_REF}" == refs/heads/hotfix/* ]]; then |
55 | 56 | echo "channel=rc" >> $GITHUB_OUTPUT |
56 | | - echo "prerelease=false" >> $GITHUB_OUTPUT |
| 57 | + echo "prerelease=true" >> $GITHUB_OUTPUT |
57 | 58 | echo "draft=true" >> $GITHUB_OUTPUT |
58 | 59 | echo "label=RC" >> $GITHUB_OUTPUT |
59 | 60 | elif [ "${GITHUB_REF}" = "refs/heads/develop" ]; then |
|
80 | 81 | echo "::error::Releases are only supported from master, develop, feature/*, release/*, and hotfix/* branches." |
81 | 82 | exit 1 |
82 | 83 |
|
| 84 | + - name: Validate NuGet version channel |
| 85 | + if: steps.release_channel.outputs.channel != 'none' |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + if [ "${GITHUB_REF}" = "refs/heads/master" ]; then |
| 89 | + if [[ "${VERSION}" == *-* ]]; then |
| 90 | + echo "::error::Master releases must produce a stable NuGet version, but GitVersion returned '${VERSION}'." |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | +
|
| 94 | + exit 0 |
| 95 | + fi |
| 96 | +
|
| 97 | + if [[ "${VERSION}" != *-* ]]; then |
| 98 | + echo "::error::Non-master releases must produce a prerelease NuGet version, but GitVersion returned '${VERSION}'." |
| 99 | + exit 1 |
| 100 | + fi |
| 101 | +
|
83 | 102 | - name: Restore dependencies |
84 | 103 | run: dotnet restore --artifacts-path=/tmp/artifacts/blazor-hashrouting |
85 | 104 |
|
@@ -191,17 +210,26 @@ jobs: |
191 | 210 | "${release_args[@]}" |
192 | 211 | fi |
193 | 212 |
|
194 | | - - name: Push package to NuGet |
| 213 | + - name: Push package to GitHub Packages |
195 | 214 | if: steps.release_channel.outputs.channel != 'none' |
196 | 215 | shell: bash |
| 216 | + run: | |
| 217 | + dotnet nuget push "/tmp/artifacts/blazor-hashrouting/package/release/Blazor.HashRouting.${VERSION}.nupkg" \ |
| 218 | + --api-key "${{ secrets.GITHUB_TOKEN }}" \ |
| 219 | + --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \ |
| 220 | + --skip-duplicate |
| 221 | +
|
| 222 | + - name: Push package to NuGet |
| 223 | + if: steps.release_channel.outputs.channel == 'stable' |
| 224 | + shell: bash |
197 | 225 | run: | |
198 | 226 | dotnet nuget push "/tmp/artifacts/blazor-hashrouting/package/release/Blazor.HashRouting.${VERSION}.nupkg" \ |
199 | 227 | --api-key "${{ secrets.NUGET_API_KEY }}" \ |
200 | 228 | --source "https://api.nuget.org/v3/index.json" \ |
201 | 229 | --skip-duplicate |
202 | 230 |
|
203 | 231 | - name: Push symbols to NuGet |
204 | | - if: steps.release_channel.outputs.channel != 'none' |
| 232 | + if: steps.release_channel.outputs.channel == 'stable' |
205 | 233 | shell: bash |
206 | 234 | run: | |
207 | 235 | dotnet nuget push "/tmp/artifacts/blazor-hashrouting/package/release/Blazor.HashRouting.${VERSION}.snupkg" \ |
|
0 commit comments