Skip to content

cicd: try to fix push nuget #11

cicd: try to fix push nuget

cicd: try to fix push nuget #11

name: Publish GitHub release
on:
pull_request:
types:
- closed
branches:
- 'master'
jobs:
publish_github_release:
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
outputs:
is_release_drafted: ${{ steps.checkIfReleaseIsDrafted.outputs.IS_RELEASE_DRAFTED }}
steps:
# TODO: add steps to publish (undraft) release on GitHub
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Read package version
shell: pwsh
run: |
([XML]$nugetCsprojXml = Get-Content ./src/Pororoca.Test/Pororoca.Test.csproj)
$versionName = $nugetCsprojXml.Project.PropertyGroup.PackageVersion
echo "RELEASE_NAME=${versionName}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Check if release already exists
id: checkIfReleaseIsDrafted
shell: pwsh
run: |
$releasesList = (gh release list --json name,isDraft) | ConvertFrom-Json;
$existingRelease = $releasesList | where { $_.Name -eq $env:RELEASE_NAME } | Select -First 1
if ($existingRelease -eq $null)
{
echo "No release found."
exit 0;
}
elseif ($existingRelease.IsDraft -eq $True)
{
echo "IS_RELEASE_DRAFTED=1" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
}
else
{
echo "This release exists and is published!";
exit 1;
}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
push_package_to_nuget:
needs: publish_github_release
if: ${{ needs.publish_github_release.outputs.is_release_drafted == '1' }}
uses: ./.github/workflows/cicd-wfw.yml
with:
os: ubuntu-latest
prNumber: ${{ github.event.number }}
runCD: true
producePororocaTestNuget: true
pushPackageToNuGetServer: true