Skip to content
Merged
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
44 changes: 33 additions & 11 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
name: ${{ steps.meta.outputs.name }}
prerelease: ${{ steps.meta.outputs.prerelease }}
latest: ${{ steps.meta.outputs.latest }}
lastTag: ${{ steps.meta.outputs.lastTag }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 } # full history: version = git describe
Expand Down Expand Up @@ -82,9 +83,15 @@ jobs:
"prerelease=true" >> $env:GITHUB_OUTPUT
"latest=false" >> $env:GITHUB_OUTPUT
}
# Last official release tag reachable from HEAD (e.g. v2.0.0). Used to pin the
# base for nightly release-notes so they cover only "since the last release"
# instead of the whole history. Match v<digit> to skip legacy junk tags
# (OpenXcomCoop_*, v-non-numeric). Empty on a repo with no release tag yet.
$lastTag = (git describe --tags --abbrev=0 --match "v[0-9]*" 2>$null)
"lastTag=$lastTag" >> $env:GITHUB_OUTPUT
"version=$v" >> $env:GITHUB_OUTPUT
"gitSuffix=$gitSuffix" >> $env:GITHUB_OUTPUT
Write-Host "version: $v$gitSuffix"
Write-Host "version: $v$gitSuffix (base: $lastTag)"

build:
needs: meta
Expand Down Expand Up @@ -361,24 +368,39 @@ jobs:
prerelease: ${{ needs.meta.outputs.prerelease }}
make_latest: ${{ needs.meta.outputs.latest }}
files: ${{ env.ASSETS }} # x64 zip + WinXP zip + Linux tarball, one call
# release -> curated notes from CHANGELOG.md; nightly -> auto-generated
# release -> curated notes from CHANGELOG.md; nightly -> generated by the next
# step, pinned to previous_tag_name (GitHub's auto base picks the whole history
# for the non-semver `nightly` tag -> notes grow forever). Publish with an empty
# body; the strip step below fills it in.
body_path: ${{ needs.meta.outputs.channel == 'release' && 'release-notes.md' || '' }}
generate_release_notes: ${{ needs.meta.outputs.channel != 'release' }}
generate_release_notes: false

- name: Strip 'New Contributors' + author handles from nightly notes
- name: Generate nightly notes since last release + strip authorship
if: needs.meta.outputs.channel == 'nightly'
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
# Generate the "What's Changed" list ourselves, pinned to the last official
# release. GitHub's auto base-selection can't order the non-semver `nightly`
# tag against the legacy junk tags, so it diffs from ~repo start and the notes
# grow without bound. previous_tag_name = last release => notes cover exactly
# the commits since that release. Empty lastTag (no release yet) falls back to
# GitHub's default base.
$prev = "${{ needs.meta.outputs.lastTag }}"
$call = @('api', "repos/$env:GITHUB_REPOSITORY/releases/generate-notes",
'-f', 'tag_name=nightly',
'-f', 'target_commitish=${{ github.sha }}')
if ($prev) { $call += @('-f', "previous_tag_name=$prev") }
Write-Host "generate-notes base: $(if ($prev) { $prev } else { '(auto)' })"
# gh returns the body as a string[] (one element per line). Without an explicit
# -join, PowerShell coerces it to a single string joined with SPACES, which
# destroys every newline (notes render as one run-on paragraph) and makes the
# regexes below never match. Always -join "`n" first.
$body = (& gh @call --jq '.body') -join "`n"
# "New Contributors" is meaningless on a rolling tag: GitHub recomputes it each
# run against a shifting base (the last release tag) and flags even the original
# dev as "new". Remove that section, keeping "## What's Changed" + "Full Changelog".
# NOTE: gh returns the body as a string[] (one element per line). Without an
# explicit -join, PowerShell coerces it to a single string joined with SPACES,
# which destroys every newline (notes render as one run-on paragraph) and makes
# the regex below never match. Always -join "`n" first.
$body = (gh release view nightly --repo "$env:GITHUB_REPOSITORY" --json body --jq '.body') -join "`n"
# run against a shifting base and flags even the original dev as "new". Remove
# that section, keeping "## What's Changed" + "Full Changelog".
$clean = [regex]::Replace($body, "(?s)\r?\n?## New Contributors\r?\n(?:\*.*\r?\n?)*\r?\n?(?=\*\*Full Changelog\*\*)", "`n`n")
# Drop the "by @author" credit from each "What's Changed" bullet - the notes
# should describe the change, not the committer.
Expand Down
Loading