ci: switch to git-cliff for changelog generation (#2802)
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
ref: ${{ inputs.to-ref }}
|
||||
|
||||
- name: Install git-cliff
|
||||
uses: taiki-e/install-action@4cef1412cce204788f482e778a0b9187f9626a29 # v2.87.21
|
||||
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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
with:
|
||||
name: range-release-notes
|
||||
path: |
|
||||
range-context.json
|
||||
range-notes.md
|
||||
retention-days: 14
|
||||
@@ -11,11 +11,6 @@ on:
|
||||
description: 'Resolved commit SHA for the candidate build'
|
||||
required: true
|
||||
type: string
|
||||
base_tag:
|
||||
description: 'Stable base tag that the candidate is built on top of'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
mention_text:
|
||||
description: 'Optional role mentions or intro text to prepend to the message'
|
||||
required: false
|
||||
|
||||
@@ -9,7 +9,7 @@ on:
|
||||
description: 'Post the Discord nightly announcement'
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
default: false
|
||||
|
||||
jobs:
|
||||
resolve_ref:
|
||||
@@ -20,7 +20,6 @@ jobs:
|
||||
contents: read
|
||||
|
||||
outputs:
|
||||
base_tag: ${{ steps.resolve.outputs.base_tag }}
|
||||
commit_sha: ${{ steps.resolve.outputs.commit_sha }}
|
||||
from_ref: ${{ steps.resolve.outputs.from_ref }}
|
||||
nightly_tag: ${{ steps.resolve.outputs.nightly_tag }}
|
||||
@@ -42,10 +41,8 @@ jobs:
|
||||
short_sha="$(git rev-parse --short HEAD)"
|
||||
build_date="$(date -u +%Y%m%d)"
|
||||
nightly_tag="nightly-${build_date}-${short_sha}"
|
||||
base_tag="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
|
||||
from_ref="$base_tag"
|
||||
from_ref="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
|
||||
|
||||
echo "base_tag=${base_tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||
echo "from_ref=${from_ref}" >> "$GITHUB_OUTPUT"
|
||||
echo "nightly_tag=${nightly_tag}" >> "$GITHUB_OUTPUT"
|
||||
@@ -160,54 +157,25 @@ jobs:
|
||||
retention-days: 30
|
||||
|
||||
generate-notes:
|
||||
name: Nightly Changelog
|
||||
if: ${{ always() && needs.test-suite.result == 'success' }}
|
||||
needs: [resolve_ref, test-suite]
|
||||
runs-on: ubuntu-latest
|
||||
name: Generate Notes
|
||||
needs:
|
||||
- resolve_ref
|
||||
uses: ./.github/workflows/compute-release-notes.yml
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
compare_url: ${{ steps.notes.outputs.compare_url }}
|
||||
details_url: ${{ steps.notes.outputs.details_url }}
|
||||
predicted_version: ${{ steps.notes.outputs.predicted_version }}
|
||||
release_notes: ${{ steps.notes.outputs.release_notes }}
|
||||
release_type: ${{ steps.notes.outputs.release_type }}
|
||||
released: ${{ steps.notes.outputs.released }}
|
||||
to_sha: ${{ steps.notes.outputs.to_sha }}
|
||||
available: ${{ steps.webhook_secrets_check.outputs.available }}
|
||||
steps:
|
||||
- name: Check Discord Webhook secrets
|
||||
id: webhook_secrets_check
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_NIGHTLY_WEBHOOK != '' && secrets.DISCORD_NIGHTLY_WEBHOOK || secrets.DISCORD_RELEASE_WEBHOOK }}
|
||||
run: |
|
||||
# Check here rather than in the `if`.
|
||||
# Github actions does not support the `secrets` context in `if` blocks.
|
||||
if [[ -n "${DISCORD_WEBHOOK}" ]]; then
|
||||
echo "available=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "available=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Checkout Workflow Repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Build Full Changelog
|
||||
if: ${{ steps.webhook_secrets_check.outputs.available == 'true' }}
|
||||
id: notes
|
||||
uses: ./.github/actions/compute-release-notes
|
||||
with:
|
||||
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
from_ref: ${{ needs.resolve_ref.outputs.from_ref }}
|
||||
repository_url: ${{ format('{0}/{1}', github.server_url, github.repository) }}
|
||||
to_ref: ${{ needs.resolve_ref.outputs.commit_sha }}
|
||||
with:
|
||||
from-ref: ${{ needs.resolve_ref.outputs.from_ref }}
|
||||
to-ref: ${{ needs.resolve_ref.outputs.commit_sha }}
|
||||
secrets: inherit
|
||||
|
||||
notify-discord:
|
||||
name: Notify Discord (Nightly)
|
||||
if: ${{ always() && (github.event_name == 'schedule' || inputs.post_discord) && needs.generate-notes.result == 'success' && needs.build-and-push.result == 'success' && needs.export-openapi.result == 'success' && needs.generate-notes.outputs.available == 'true' && needs.generate-notes.outputs.predicted_version != '' }}
|
||||
needs: [resolve_ref, build-and-push, export-openapi, generate-notes]
|
||||
if: ${{ always() && (github.event_name == 'schedule' || inputs.post_discord) && needs.generate-notes.result == 'success' && needs.build-and-push.result == 'success' && needs.export-openapi.result == 'success' }}
|
||||
needs:
|
||||
- resolve_ref
|
||||
- build-and-push
|
||||
- export-openapi
|
||||
- generate-notes
|
||||
permissions: {}
|
||||
uses: ./.github/workflows/notify-discord-release-notes.yml
|
||||
secrets:
|
||||
@@ -215,12 +183,11 @@ jobs:
|
||||
with:
|
||||
channel: nightly
|
||||
candidate_sha: ${{ needs.resolve_ref.outputs.commit_sha }}
|
||||
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
current_version: ${{ needs.resolve_ref.outputs.nightly_tag }}
|
||||
details_url: ${{ needs.generate-notes.outputs.details_url }}
|
||||
compare_url: ${{ needs.generate-notes.outputs.compare_url }}
|
||||
details_url: ${{ needs.generate-notes.outputs.details-url }}
|
||||
compare_url: ${{ needs.generate-notes.outputs.compare-url }}
|
||||
mention_text: ${{ vars.DISCORD_NIGHTLY_MENTIONS }}
|
||||
predicted_version: ${{ needs.generate-notes.outputs.predicted_version }}
|
||||
predicted_version: ${{ needs.generate-notes.outputs.version }}
|
||||
|
||||
test-suite:
|
||||
name: Test Suite
|
||||
|
||||
@@ -119,7 +119,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
base_tag: ${{ steps.metadata.outputs.base_tag }}
|
||||
compare_url: ${{ steps.metadata.outputs.compare_url }}
|
||||
available: ${{ steps.webhook_secrets_check.outputs.available }}
|
||||
|
||||
@@ -163,7 +162,6 @@ jobs:
|
||||
COMPARE_URL="https://github.com/${GITHUB_REPOSITORY}/compare/${BASE_TAG}...${RELEASE_TAG}"
|
||||
fi
|
||||
{
|
||||
echo "base_tag=${BASE_TAG}"
|
||||
echo "compare_url=${COMPARE_URL}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -183,6 +181,5 @@ jobs:
|
||||
predicted_version: ${{ github.event.release.tag_name }}
|
||||
details_url: ${{ github.event.release.html_url }}
|
||||
candidate_sha: ${{ github.sha }}
|
||||
base_tag: ${{ needs.prepare-release-notification.outputs.base_tag }}
|
||||
compare_url: ${{ needs.prepare-release-notification.outputs.compare_url }}
|
||||
mention_text: ${{ vars.DISCORD_STABLE_MENTIONS }}
|
||||
|
||||
@@ -66,33 +66,16 @@ jobs:
|
||||
echo "current_version=${current_version}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
generate-notes:
|
||||
name: Release Candidate Changelog
|
||||
needs: [resolve_ref]
|
||||
runs-on: ubuntu-latest
|
||||
name: Generate Notes
|
||||
needs:
|
||||
- resolve_ref
|
||||
uses: ./.github/workflows/compute-release-notes.yml
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
compare_url: ${{ steps.notes.outputs.compare_url }}
|
||||
details_url: ${{ steps.notes.outputs.details_url }}
|
||||
predicted_version: ${{ steps.notes.outputs.predicted_version }}
|
||||
release_notes: ${{ steps.notes.outputs.release_notes }}
|
||||
release_type: ${{ steps.notes.outputs.release_type }}
|
||||
released: ${{ steps.notes.outputs.released }}
|
||||
to_sha: ${{ steps.notes.outputs.to_sha }}
|
||||
steps:
|
||||
- name: Checkout Workflow Repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Build Full Changelog
|
||||
id: notes
|
||||
uses: ./.github/actions/compute-release-notes
|
||||
with:
|
||||
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
from_ref: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
repository_url: ${{ format('{0}/{1}', github.server_url, github.repository) }}
|
||||
to_ref: ${{ needs.resolve_ref.outputs.candidate_sha }}
|
||||
with:
|
||||
from-ref: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
to-ref: ${{ needs.resolve_ref.outputs.candidate_sha }}
|
||||
secrets: inherit
|
||||
|
||||
notify-discord:
|
||||
name: Notify Discord (RC)
|
||||
@@ -105,9 +88,8 @@ jobs:
|
||||
with:
|
||||
channel: rc
|
||||
candidate_sha: ${{ needs.resolve_ref.outputs.candidate_sha }}
|
||||
base_tag: ${{ needs.resolve_ref.outputs.base_tag }}
|
||||
current_version: ${{ needs.resolve_ref.outputs.current_version }}
|
||||
details_url: ${{ needs.generate-notes.outputs.details_url }}
|
||||
predicted_version: ${{ needs.generate-notes.outputs.predicted_version }}
|
||||
compare_url: ${{ needs.generate-notes.outputs.compare_url }}
|
||||
details_url: ${{ needs.generate-notes.outputs.details-url }}
|
||||
predicted_version: ${{ needs.generate-notes.outputs.version }}
|
||||
compare_url: ${{ needs.generate-notes.outputs.compare-url }}
|
||||
mention_text: ${{ vars.DISCORD_RC_MENTIONS }}
|
||||
|
||||
@@ -30,18 +30,16 @@ jobs:
|
||||
with:
|
||||
checkout_ref: ${{ github.sha }}
|
||||
|
||||
semantic-version:
|
||||
name: Compute Release and Changelog
|
||||
needs:
|
||||
- migration-check
|
||||
- test-suite
|
||||
resolve-refs:
|
||||
name: Resolve release ref
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
outputs:
|
||||
version: ${{ steps.notes.outputs.predicted_version }}
|
||||
commit-sha: ${{ steps.resolve.outputs.commit_sha }}
|
||||
from-ref: ${{ steps.resolve.outputs.from_ref }}
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
@@ -58,21 +56,24 @@ jobs:
|
||||
set -eu
|
||||
|
||||
git fetch origin main --tags --force
|
||||
base_tag="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
|
||||
from_ref="$base_tag"
|
||||
from_ref="$(git describe --tags --abbrev=0 --match 'v*' origin/main)"
|
||||
|
||||
echo "base_tag=${base_tag}" >> "$GITHUB_OUTPUT"
|
||||
echo "commit_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||
echo "from_ref=${from_ref}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build Changelog
|
||||
id: notes
|
||||
uses: ./.github/actions/compute-release-notes
|
||||
with:
|
||||
base_tag: ${{ steps.resolve.outputs.base_tag }}
|
||||
from_ref: ${{ steps.resolve.outputs.from_ref }}
|
||||
repository_url: ${{ format('{0}/{1}', github.server_url, github.repository) }}
|
||||
to_ref: ${{ steps.resolve.outputs.commit_sha }}
|
||||
semantic-version:
|
||||
name: Generate Notes
|
||||
needs:
|
||||
- resolve-refs
|
||||
- migration-check
|
||||
uses: ./.github/workflows/compute-release-notes.yml
|
||||
permissions:
|
||||
contents: read
|
||||
with:
|
||||
bump: true
|
||||
from-ref: ${{ needs.resolve-refs.outputs.from-ref }}
|
||||
to-ref: ${{ needs.resolve-refs.outputs.commit-sha }}
|
||||
secrets: inherit
|
||||
|
||||
build-frontend:
|
||||
name: Build frontend
|
||||
@@ -206,10 +207,6 @@ jobs:
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: range-release-notes
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: frontend
|
||||
@@ -239,14 +236,15 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }}
|
||||
GITHUB_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN != '' && secrets.RELEASE_BOT_TOKEN || github.token }}
|
||||
RELEASE_NOTES: ${{ needs.semantic-version.outputs.release-notes }}
|
||||
RELEASE_VERSION: ${{ needs.semantic-version.outputs.version }}
|
||||
TARGET_REF: ${{ github.sha }}
|
||||
run: |
|
||||
gh release create \
|
||||
"v${RELEASE_VERSION}" \
|
||||
--title "Release v${RELEASE_VERSION}" \
|
||||
"${RELEASE_VERSION}" \
|
||||
--title "Release ${RELEASE_VERSION}" \
|
||||
--draft \
|
||||
--latest \
|
||||
--target "${TARGET_REF}" \
|
||||
--notes-file ./range-release-notes.md \
|
||||
--notes "${RELEASE_NOTES}" \
|
||||
release-assets/*
|
||||
|
||||
Reference in New Issue
Block a user