|
| 1 | +name: Release the nuget Package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + rel_version: |
| 7 | + description: 'Release version (e.g., 1.9.0-rc.1, 1.9.1)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +env: |
| 12 | + DOTNET_VERSION: '9.0.x' |
| 13 | + PACKAGE_OUTPUT_PATH: src/ |
| 14 | + BRANCH_NAME: release-${{ inputs.rel_version }} |
| 15 | + PACKAGE_VERSION: ${{ inputs.rel_version }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Setup .NET SDK |
| 28 | + uses: actions/setup-dotnet@v3.2.0 |
| 29 | + with: |
| 30 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 31 | + |
| 32 | + - name: Build project |
| 33 | + run: dotnet build --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} |
| 34 | + |
| 35 | + - name: Run tests |
| 36 | + run: dotnet test --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build |
| 37 | + |
| 38 | + - name: Create NuGet package |
| 39 | + run: dotnet pack --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build |
| 40 | + |
| 41 | + - name: Upload NuGet package artifact |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: nugetPackage |
| 45 | + path: ${{ env.PACKAGE_OUTPUT_PATH }} |
| 46 | + |
| 47 | + release: |
| 48 | + runs-on: ubuntu-latest |
| 49 | + needs: build |
| 50 | + if: github.ref == 'refs/heads/master' |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Download NuGet package artifact |
| 54 | + uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: nugetPackage |
| 57 | + |
| 58 | + - name: Push package to NuGet.org |
| 59 | + run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json |
| 60 | + |
| 61 | + create-release-branch: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + needs: [build, release] |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout repository |
| 67 | + uses: actions/checkout@v2 |
| 68 | + |
| 69 | + - name: Create release branch |
| 70 | + uses: peterjgrainger/action-create-branch@v2.2.0 |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 73 | + with: |
| 74 | + branch: ${{ env.BRANCH_NAME }} |
| 75 | + sha: ${{ github.sha }} |
0 commit comments