From 82f9955950323c32785e24cd21549ea2127352f1 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 18 Jun 2023 15:12:26 -0700 Subject: [PATCH 1/3] Do not push on PR events --- .github/workflows/BuildPublishPipeline.yml | 20 +++++++++++--------- Utilities.sln | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/BuildPublishPipeline.yml b/.github/workflows/BuildPublishPipeline.yml index 2c4c5b6..0701c39 100644 --- a/.github/workflows/BuildPublishPipeline.yml +++ b/.github/workflows/BuildPublishPipeline.yml @@ -8,6 +8,12 @@ on: branches: [ main ] workflow_dispatch: +env: + # Do not push on pull_request events + dopush: ${{ github.event_name != 'pull_request' }} + # main branch + mainbranch: ${{ !endsWith(github.ref, 'refs/heads/main') }} + jobs: build: name: 'Build and Publish Pipeline' @@ -58,9 +64,7 @@ jobs: # Publish to NuGet.org Registry # https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push - name: 'Publish to NuGet.org Registry' - # Do not push pull requests - if: ${{ github.event_name != 'pull_request' }} - # Use build platform specific path convention, relative paths do not work + if: ${{ dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://api.nuget.org/v3/index.json @@ -70,9 +74,7 @@ jobs: # Publish to GitHub NuGet Registry # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry - name: 'Publish to GitHub NuGet Registry' - # Do not push pull requests - if: ${{ github.event_name != 'pull_request' }} - # Use build platform specific path convention, relative paths do not work + if: ${{ dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json @@ -81,19 +83,19 @@ jobs: # Zip the output - name: 'Zip Output' + if: ${{ dopush }} run: 7z a -t7z ./Publish/Utilities.7z ./Publish/* # Create GitHub release # https://github.com/marketplace/actions/automatic-releases - name: 'Create GitHub Release' - # Do not push on pull requests - if: ${{ (github.event_name != 'pull_request') }} + if: ${{ dopush }} uses: marvinpinto/action-automatic-releases@latest with: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: ${{ steps.nbgv.outputs.SemVer2 }} # Only main branch is not a pre-release - prerelease: ${{ !endsWith(github.ref, 'refs/heads/main') }} + prerelease: ${{ mainbranch }} files: | LICENSE ./Publish/Utilities.7z diff --git a/Utilities.sln b/Utilities.sln index 6989a70..23a7ece 100644 --- a/Utilities.sln +++ b/Utilities.sln @@ -32,6 +32,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GitHub Actions", "GitHub Actions", "{6AEC3BF4-00CE-4C23-A003-82F12FCBA630}" ProjectSection(SolutionItems) = preProject .github\workflows\BuildPublishPipeline.yml = .github\workflows\BuildPublishPipeline.yml + .github\dependabot.yml = .github\dependabot.yml EndProjectSection EndProject Global From 83d5c44528c36a700b3cc477b1799d1b7cddec6c Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 18 Jun 2023 15:14:17 -0700 Subject: [PATCH 2/3] Update BuildPublishPipeline.yml --- .github/workflows/BuildPublishPipeline.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/BuildPublishPipeline.yml b/.github/workflows/BuildPublishPipeline.yml index 0701c39..3849e98 100644 --- a/.github/workflows/BuildPublishPipeline.yml +++ b/.github/workflows/BuildPublishPipeline.yml @@ -64,7 +64,7 @@ jobs: # Publish to NuGet.org Registry # https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-push - name: 'Publish to NuGet.org Registry' - if: ${{ dopush }} + if: ${{ env.dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://api.nuget.org/v3/index.json @@ -74,7 +74,7 @@ jobs: # Publish to GitHub NuGet Registry # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry - name: 'Publish to GitHub NuGet Registry' - if: ${{ dopush }} + if: ${{ env.dopush }} run: >- dotnet nuget push ${{ github.workspace }}/Publish/*.nupkg --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json @@ -83,19 +83,19 @@ jobs: # Zip the output - name: 'Zip Output' - if: ${{ dopush }} + if: ${{ env.dopush }} run: 7z a -t7z ./Publish/Utilities.7z ./Publish/* # Create GitHub release # https://github.com/marketplace/actions/automatic-releases - name: 'Create GitHub Release' - if: ${{ dopush }} + if: ${{ env.dopush }} uses: marvinpinto/action-automatic-releases@latest with: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: ${{ steps.nbgv.outputs.SemVer2 }} # Only main branch is not a pre-release - prerelease: ${{ mainbranch }} + prerelease: ${{ env.mainbranch }} files: | LICENSE ./Publish/Utilities.7z From b2a1bb73a4dbd6e992fe902d7e55679fc89dbaed Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sun, 18 Jun 2023 15:18:57 -0700 Subject: [PATCH 3/3] Fix mainbranch logic --- .github/workflows/BuildPublishPipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildPublishPipeline.yml b/.github/workflows/BuildPublishPipeline.yml index 3849e98..8686222 100644 --- a/.github/workflows/BuildPublishPipeline.yml +++ b/.github/workflows/BuildPublishPipeline.yml @@ -12,7 +12,7 @@ env: # Do not push on pull_request events dopush: ${{ github.event_name != 'pull_request' }} # main branch - mainbranch: ${{ !endsWith(github.ref, 'refs/heads/main') }} + mainbranch: ${{ endsWith(github.ref, 'refs/heads/main') }} jobs: build: @@ -95,7 +95,7 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: ${{ steps.nbgv.outputs.SemVer2 }} # Only main branch is not a pre-release - prerelease: ${{ env.mainbranch }} + prerelease: ${{ !env.mainbranch }} files: | LICENSE ./Publish/Utilities.7z