Files
grimmory/.github/workflows/compute-release-notes.yml
dependabot[bot] 936ebe5299 chore(deps): bump actions/checkout from 6.0.2 to 7.0.1 (#2924)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-10-16 11:55:43 +01:00

150 lines
4.7 KiB
YAML

name: Compute Release Notes
on:
workflow_call:
inputs:
bump:
description: Whether to bump the version for the changelog generated
required: false
type: boolean
default: false
from-ref:
description: Git ref that marks the start of the changelog range
type: string
required: true
to-ref:
description: Git ref that marks the end of the changelog range
type: string
required: true
outputs:
compare-url:
description: Compare URL for the computed range
value: ${{ jobs.compute-release-notes.outputs.compare-url }}
details-url:
description: Workflow run URL that contains the full markdown summary
value: ${{ jobs.compute-release-notes.outputs.details-url }}
version:
description: Predicted semantic version for the supplied range
value: ${{ jobs.compute-release-notes.outputs.version }}
release-notes:
description: Markdown notes generated from conventional commits
value: ${{ jobs.compute-release-notes.outputs.release-notes }}
jobs:
compute-release-notes:
name: Compute Release Notes
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
compare-url: ${{ steps.extract.outputs.compare-url }}
details-url: ${{ steps.extract.outputs.details-url }}
version: ${{ steps.git-cliff.outputs.version }}
release-notes: ${{ steps.git-cliff.outputs.release-notes }}
steps:
- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ inputs.to-ref }}
- name: Install git-cliff
uses: taiki-e/install-action@1168f6810a3cb30a3514bf5756a3b7f0422c6df8 # v2.87.28
with:
tool: git-cliff
- name: Run git-cliff
id: git-cliff
shell: bash
env:
IS_BUMP: ${{ inputs.bump }}
GIT_CLIFF_CONFIG: .github/cliff.toml
FROM_REF: ${{ inputs.from-ref }}
TO_REF: ${{ inputs.to-ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: |
set -eu
git-cliff \
--config ${GIT_CLIFF_CONFIG} \
--context \
--output range-context.json \
"${FROM_REF}..${TO_REF}"
if [ "$IS_BUMP" = "true" ]; then
BUMP_ARG="--bump"
else
BUMP_ARG=""
fi
git-cliff \
--config ${GIT_CLIFF_CONFIG} \
--from-context range-context.json \
${BUMP_ARG} \
--output range-notes.md \
"${FROM_REF}..${TO_REF}"
RELEASE_NOTES_DELIM="EOF_$(openssl rand -hex 16)"
{
echo "release-notes<<${RELEASE_NOTES_DELIM}"
cat range-notes.md
printf '\n'
echo "${RELEASE_NOTES_DELIM}"
} >> "$GITHUB_OUTPUT"
PREDICTED_VERSION=$(
git-cliff \
--config ${GIT_CLIFF_CONFIG} \
--from-context range-context.json \
--bumped-version \
"${FROM_REF}..${TO_REF}"
)
echo "version=${PREDICTED_VERSION}" >> "$GITHUB_OUTPUT"
- name: Extract Range Outputs
id: extract
shell: bash
env:
FROM_REF: ${{ inputs.from-ref }}
TO_REF: ${{ inputs.to-ref }}
PREDICTED_VERSION: ${{ steps.git-cliff.outputs.version }}
RELEASE_NOTES: ${{ steps.git-cliff.outputs.release-notes }}
DETAILS_URL: ${{ format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
COMPARE_URL: ${{ format('{0}/{1}/compare/{2}...{3}', github.server_url, github.repository, inputs.from-ref, inputs.to-ref) }}
run: |
set -eu
{
echo "compare-url=${COMPARE_URL}"
echo "details-url=${DETAILS_URL}"
} >> "$GITHUB_OUTPUT"
{
echo "## Full Changelog"
echo
echo "- Range: \`${FROM_REF}..${TO_REF}\`"
echo "- Predicted version: \`${PREDICTED_VERSION:-none}\`"
if [ -n "$COMPARE_URL" ]; then
echo "- Compare: ${COMPARE_URL}"
fi
echo
echo "$RELEASE_NOTES"
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload Range Notes Artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: range-release-notes
path: |
range-context.json
range-notes.md
retention-days: 14