|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-publish: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Setup .NET |
| 18 | + uses: actions/setup-dotnet@v4 |
| 19 | + with: |
| 20 | + dotnet-version: '8.0.x' |
| 21 | + |
| 22 | + - name: Extract version from tag |
| 23 | + id: get_version |
| 24 | + run: | |
| 25 | + # Remove 'v' prefix if present (e.g., v1.2.3 -> 1.2.3) |
| 26 | + VERSION=${GITHUB_REF#refs/tags/} |
| 27 | + VERSION=${VERSION#v} |
| 28 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 29 | + echo "Building version: $VERSION" |
| 30 | +
|
| 31 | + - name: Restore dependencies |
| 32 | + run: dotnet restore |
| 33 | + |
| 34 | + - name: Build |
| 35 | + run: dotnet build --configuration=Release --no-restore |
| 36 | + |
| 37 | + - name: Test |
| 38 | + timeout-minutes: 2 |
| 39 | + run: dotnet test --configuration=Release --no-build |
| 40 | + |
| 41 | + - name: Pack Activout.RestClient |
| 42 | + run: | |
| 43 | + dotnet pack Activout.RestClient/Activout.RestClient.csproj \ |
| 44 | + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \ |
| 45 | + --configuration=Release \ |
| 46 | + --no-build \ |
| 47 | + --include-symbols \ |
| 48 | + --include-source \ |
| 49 | + --output ./nupkgs |
| 50 | +
|
| 51 | + - name: Pack Activout.RestClient.Json |
| 52 | + run: | |
| 53 | + dotnet pack Activout.RestClient.Json/Activout.RestClient.Json.csproj \ |
| 54 | + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \ |
| 55 | + --configuration=Release \ |
| 56 | + --no-build \ |
| 57 | + --include-symbols \ |
| 58 | + --include-source \ |
| 59 | + --output ./nupkgs |
| 60 | +
|
| 61 | + - name: Pack Activout.RestClient.Newtonsoft.Json |
| 62 | + run: | |
| 63 | + dotnet pack Activout.RestClient.Newtonsoft.Json/Activout.RestClient.Newtonsoft.Json.csproj \ |
| 64 | + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \ |
| 65 | + --configuration=Release \ |
| 66 | + --no-build \ |
| 67 | + --include-symbols \ |
| 68 | + --include-source \ |
| 69 | + --output ./nupkgs |
| 70 | +
|
| 71 | + - name: Pack Activout.RestClient.Xml |
| 72 | + run: | |
| 73 | + dotnet pack Activout.RestClient.Xml/Activout.RestClient.Xml.csproj \ |
| 74 | + -p:PackageVersion=${{ steps.get_version.outputs.VERSION }} \ |
| 75 | + --configuration=Release \ |
| 76 | + --no-build \ |
| 77 | + --include-symbols \ |
| 78 | + --include-source \ |
| 79 | + --output ./nupkgs |
| 80 | +
|
| 81 | + - name: List generated packages |
| 82 | + run: ls -lh ./nupkgs/ |
| 83 | + |
| 84 | + - name: Upload packages to release |
| 85 | + uses: softprops/action-gh-release@v2 |
| 86 | + with: |
| 87 | + files: ./nupkgs/*.symbols.nupkg |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + |
| 91 | + - name: Push to NuGet.org |
| 92 | + run: | |
| 93 | + dotnet nuget push ./nupkgs/*.symbols.nupkg \ |
| 94 | + --api-key ${{ secrets.NUGET_API_KEY }} \ |
| 95 | + --source https://api.nuget.org/v3/index.json \ |
| 96 | + --skip-duplicate |
0 commit comments