We use gitflow and gitversion for versioning. I am trying to come up with a workflow for releasing nuget package using github actions to push packages whenever a feature is merged to develop (alpha suffix, pre-release nuget package), release branch is created from develop (beta suffix, pre-release nuget package) or release branch is merged to main (no suffix, Release nuget package). Can anyone help me with the pipeline ? So far I was able to get to a point where the develop packages are released without any issue. problem comes when I create a release branch. The workflow is not triggered. Here is the pipeline I'm using:
`` name: Build and Publish NuGet Package on: push: branches: - '*'
jobs: build: runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
- name: Install GitVersion
run: dotnet tool install --global GitVersion.Tool
- name: Configure GitVersion
run: dotnet-gitversion /config /.github/GitVersion.yml
- name: Configure NuGet Feed
run: dotnet nuget add source --username USERNAME --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name UltimateSuite "https://nuget.pkg.github.com/ultimatesuite/index.json "
- name: Restore dependencies
run: dotnet restore
- name: Build and Pack
run: dotnet build --configuration Release
&& dotnet pack --configuration Release --no-build --output ./nuget
- name: Archive NuGet package
uses: actions/upload-artifact@v2
with:
name: nuget-package
path: ./nuget
publish:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/release/') || github.ref == 'refs/heads/master'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download NuGet package
uses: actions/download-artifact@v2
with:
name: nuget-package
path: ./nuget
- name: Publish NuGet package
run: dotnet nuget push ./nuget/*.nupkg --source https://nuget.pkg.github.com/*******/index.json --api-key ${{ github.token }}
``
Thanks!