Merge pull request #861 from akunzai/ci/optimize-release-flow #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| draft-release: | |
| name: Update Release Draft | |
| if: github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - id: release-drafter | |
| uses: release-drafter/release-drafter@v6 | |
| with: | |
| publish: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-release: | |
| name: Publish GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check pre-release | |
| id: check | |
| run: | | |
| TAG="${GITHUB_REF#refs/tags/}" | |
| if echo "$TAG" | grep -qE '(alpha|beta|preview|rc)'; then | |
| echo "prerelease=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "prerelease=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - id: release-drafter | |
| uses: release-drafter/release-drafter@v6 | |
| with: | |
| publish: true | |
| prerelease: ${{ steps.check.outputs.prerelease == 'true' }} | |
| tag: ${{ github.ref_name }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish-nuget: | |
| name: Publish to NuGet | |
| needs: publish-release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up .NET SDK | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 10.0.x | |
| cache: true | |
| cache-dependency-path: '**/Directory.Packages.props' | |
| - name: Build packages | |
| run: | | |
| dotnet --info | |
| dotnet pack -o packages | |
| - name: Publish to NuGet.org | |
| run: dotnet nuget push "packages/*.nupkg" -k ${{ secrets.NUGET_AUTH_TOKEN }} -s https://api.nuget.org/v3/index.json --skip-duplicate |