From a20de2cda671cf2965f0bcc3d0c00d6616b8d041 Mon Sep 17 00:00:00 2001 From: Jaz Thomson Date: Fri, 15 Mar 2024 14:29:22 +0000 Subject: [PATCH] Split GitHub workflows out into build and release --- .github/workflows/build.yml | 30 +++++++++++++++++++ .../workflows/{deployment.yml => release.yml} | 25 +++++++++------- 2 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{deployment.yml => release.yml} (64%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..cafd9e7 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,30 @@ +name: Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Check out + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4.0.0 + + - name: Restore tools + run: dotnet tool restore + + - name: Restore dependencies + run: dotnet restore + working-directory: ./src + + - name: Build + run: dotnet build --configuration Release --no-restore + working-directory: ./src diff --git a/.github/workflows/deployment.yml b/.github/workflows/release.yml similarity index 64% rename from .github/workflows/deployment.yml rename to .github/workflows/release.yml index 1c91d0a..8ab1dbb 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/release.yml @@ -1,36 +1,39 @@ -name: Nuget-Publish +name: Release Package on: - push: - branches: [ main ] - pull_request: - branches: [ main ] + release: + types: [ published ] jobs: build: runs-on: ubuntu-latest + permissions: + contents: write + steps: - name: Check out - uses: actions/checkout@v4.1.1 + uses: actions/checkout@v4 + - name: Setup .NET uses: actions/setup-dotnet@v4.0.0 - with: - dotnet-version: 6.0.300 + - name: Restore tools run: dotnet tool restore + - name: Restore dependencies run: dotnet restore working-directory: ./src + - name: Build run: dotnet build --configuration Release --no-restore working-directory: ./src + - name: Pack - run: dotnet pack --configuration Release --no-build --output . + run: dotnet pack --no-build -p:PackageVersion=${{ github.ref_name }} -p:PackageReleaseNotes=${{ github.event.release.html_url }} --output . working-directory: ./src - if: ${{ github.ref == 'refs/heads/main' }} + - name: Publish run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json working-directory: ./src - if: ${{ github.ref == 'refs/heads/main' }}