Skip to content

Commit

Permalink
Check if run is release before publishing to nuget (#1503)
Browse files Browse the repository at this point in the history
Update GitHub Actions, so that the package only publishes to nuget on release.
  • Loading branch information
mikeebowen authored Aug 2, 2023
1 parent a6e4dab commit 76c2273
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

sign:
name: "Sign Package"
if: ${{ github.event.workflow_run.conclusion == 'success' }} && github.event_name == 'release'
if: github.event.workflow_run.conclusion == 'success' && github.event_name == 'release'
needs: [pack]
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -107,3 +107,16 @@ jobs:
path: |
${{ github.workspace }}\unsigned\*.snupkg
${{ github.workspace }}\unsigned\raw\*.nupkg
releaseInfo:
name: Release Info
needs: [sign]
runs-on: windows-latest
steps:
- name: Get Release Info
run: >
echo ${{ github.event_name == 'release' }} >> release-info.txt
- name: Upload Release Info
uses: actions/upload-artifact@v3
with:
name: release-info
path: release-info.txt
28 changes: 26 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,33 @@ permissions:
issues: write

jobs:
releaseInfo:
name: Check for Release
runs-on: windows-latest
outputs:
IS_RELEASE: ${{ steps.releaseInfoStep.outputs.isRelease}}
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download Release Info
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ github.event.workflow_run.id }}
name: release-info
- name: Check if workflow is release
id: releaseInfoStep
shell: pwsh
run: |
$isRelease = Get-Content -Path release-info.txt
if ($isRelease -eq 'true') {
echo "isRelease=true" >> $env:GITHUB_OUTPUT
} else {
echo "isRelease=false" >> $env:GITHUB_OUTPUT
}
deploy:
name: "Deploy Packages to Nuget"
if: ${{ github.event.workflow_run.conclusion == 'success' }} && github.event_name == 'release'
needs: [releaseInfo]
if: needs.releaseInfo.outputs.IS_RELEASE == 'true'
runs-on: ubuntu-latest
steps:
- name: Download and Extract Artifacts from build
Expand All @@ -28,7 +52,7 @@ jobs:
uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: twsouthwick
approvers: twsouthwick,tomjebo,mikeebowen
minimum-approvals: 1
issue-title: "Approval for publishing to Nuget.org"
issue-body: "Please approve or deny the deployment to Nuget.org"
Expand Down

0 comments on commit 76c2273

Please sign in to comment.