|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Build, Test & Publish to NuGet |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v5 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup .NET |
| 20 | + uses: actions/setup-dotnet@v5 |
| 21 | + with: |
| 22 | + dotnet-version: | |
| 23 | + 10.0.x |
| 24 | +
|
| 25 | + - name: Restore |
| 26 | + run: dotnet restore Blazing.Json.Queryable.slnx |
| 27 | + |
| 28 | + - name: Build |
| 29 | + run: dotnet build Blazing.Json.Queryable.slnx --no-restore --configuration Release -p:GeneratePackageOnBuild=false |
| 30 | + |
| 31 | + - name: Test |
| 32 | + run: | |
| 33 | + dotnet test tests/Blazing.Json.Queryable.Tests/Blazing.Json.Queryable.Tests.csproj \ |
| 34 | + --no-build --no-restore \ |
| 35 | + --configuration Release |
| 36 | +
|
| 37 | + - name: Extract version from project file |
| 38 | + id: version |
| 39 | + run: | |
| 40 | + VERSION=$(grep -m1 '<Version>' src/Blazing.Json.Queryable/Blazing.Json.Queryable.csproj \ |
| 41 | + | sed 's/.*<Version>//;s/<\/Version>.*//' \ |
| 42 | + | tr -d '[:space:]') |
| 43 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 44 | + echo "tag=v$VERSION" >> $GITHUB_OUTPUT |
| 45 | + echo "Resolved version: $VERSION" |
| 46 | +
|
| 47 | + - name: Check if this version was already released |
| 48 | + id: tag_check |
| 49 | + run: | |
| 50 | + if git ls-remote --tags origin "refs/tags/v${{ steps.version.outputs.version }}" | grep -q .; then |
| 51 | + echo "exists=true" >> $GITHUB_OUTPUT |
| 52 | + else |
| 53 | + echo "exists=false" >> $GITHUB_OUTPUT |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Pack NuGet package |
| 57 | + if: steps.tag_check.outputs.exists == 'false' |
| 58 | + run: | |
| 59 | + dotnet pack src/Blazing.Json.Queryable/Blazing.Json.Queryable.csproj \ |
| 60 | + --no-build --no-restore --configuration Release --output ./artifacts |
| 61 | +
|
| 62 | + - name: Create GitHub Release |
| 63 | + if: steps.tag_check.outputs.exists == 'false' |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + run: | |
| 67 | + gh release create "${{ steps.version.outputs.tag }}" \ |
| 68 | + --title "Release ${{ steps.version.outputs.tag }}" \ |
| 69 | + --generate-notes \ |
| 70 | + ./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.nupkg \ |
| 71 | + ./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.snupkg |
| 72 | +
|
| 73 | + - name: Push Blazing.Json.Queryable to NuGet.org |
| 74 | + if: steps.tag_check.outputs.exists == 'false' |
| 75 | + run: | |
| 76 | + dotnet nuget push \ |
| 77 | + "./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.nupkg" \ |
| 78 | + --api-key ${{ secrets.NUGET_API_KEY }} \ |
| 79 | + --source https://api.nuget.org/v3/index.json \ |
| 80 | + --skip-duplicate |
| 81 | +
|
| 82 | + - name: Push Blazing.Json.Queryable symbols to NuGet.org |
| 83 | + if: steps.tag_check.outputs.exists == 'false' |
| 84 | + run: | |
| 85 | + dotnet nuget push \ |
| 86 | + "./artifacts/Blazing.Json.Queryable.${{ steps.version.outputs.version }}.snupkg" \ |
| 87 | + --api-key ${{ secrets.NUGET_API_KEY }} \ |
| 88 | + --source https://api.nuget.org/v3/index.json \ |
| 89 | + --skip-duplicate |
0 commit comments