Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions .github/workflows/build-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ jobs:
uses: actions/checkout@v6

- name: Get build version
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
run: |
Import-Module .\tools\GetBuildVersion.psm1
Write-Host "GitHub Reference = $($env:GITHUB_REF)"
$version = GetBuildVersion -BaseVersion $env:BASE_VERSION -VersionString $env:GITHUB_REF -BuildNumber $env:GITHUB_RUN_NUMBER
# github.ref / $env:GITHUB_REF can be empty on 'release' events (see #495), so use the
# release's tag name directly instead of relying on ref resolution for that event.
$refString = if ($env:GITHUB_EVENT_NAME -eq 'release') { "refs/tags/$($env:RELEASE_TAG_NAME)" } else { $env:GITHUB_REF }
Write-Host "GitHub Reference = $refString"
$version = GetBuildVersion -BaseVersion $env:BASE_VERSION -VersionString $refString -BuildNumber $env:GITHUB_RUN_NUMBER
echo "BUILD_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
Write-Host "BUILD_VERSION=$version"
shell: pwsh
Expand Down Expand Up @@ -138,7 +143,12 @@ jobs:

sign:
needs: [build]
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
# Gate on the triggering event rather than github.ref: github.ref/GITHUB_REF can be empty on
# 'release' events (see #495), which previously caused this job to be silently skipped.
if: >-
${{ github.event_name == 'release' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))) }}
runs-on: windows-latest
permissions:
id-token: write
Expand Down Expand Up @@ -205,7 +215,11 @@ jobs:
--skip-duplicate

release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
# Gate on the triggering event rather than github.ref: github.ref/GITHUB_REF can be empty on
# 'release' events (see #495), which previously caused this job to be silently skipped.
if: >-
${{ github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')) }}
needs: [ sign ]
environment: nuget-release-gate
runs-on: ubuntu-latest
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/build-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ jobs:
uses: actions/checkout@v6

- name: Get build version
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
run: |
Import-Module .\tools\GetBuildVersion.psm1
Write-Host "GitHub Reference = $($env:GITHUB_REF)"
$version = GetBuildVersion -BaseVersion $env:BASE_VERSION -VersionString $env:GITHUB_REF -BuildNumber $env:GITHUB_RUN_NUMBER
# github.ref / $env:GITHUB_REF can be empty on 'release' events (see #495), so use the
# release's tag name directly instead of relying on ref resolution for that event.
$refString = if ($env:GITHUB_EVENT_NAME -eq 'release') { "refs/tags/$($env:RELEASE_TAG_NAME)" } else { $env:GITHUB_REF }
Write-Host "GitHub Reference = $refString"
$version = GetBuildVersion -BaseVersion $env:BASE_VERSION -VersionString $refString -BuildNumber $env:GITHUB_RUN_NUMBER
echo "BUILD_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append
Write-Host "BUILD_VERSION=$version"
shell: pwsh
Expand Down Expand Up @@ -82,7 +87,12 @@ jobs:

sign:
needs: [build]
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
# Gate on the triggering event rather than github.ref: github.ref/GITHUB_REF can be empty on
# 'release' events (see #495), which previously caused this job to be silently skipped.
if: >-
${{ github.event_name == 'release' ||
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))) }}
runs-on: windows-latest
permissions:
id-token: write
Expand Down Expand Up @@ -149,7 +159,11 @@ jobs:
--skip-duplicate

release:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
# Gate on the triggering event rather than github.ref: github.ref/GITHUB_REF can be empty on
# 'release' events (see #495), which previously caused this job to be silently skipped.
if: >-
${{ github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/')) }}
needs: [ sign ]
environment: nuget-release-gate
runs-on: ubuntu-latest
Expand Down