ci: switch to git-cliff for changelog generation (#2802)
This commit is contained in:
@@ -7,10 +7,6 @@ scratch
|
||||
node_modules
|
||||
.pnpm-store
|
||||
pnpm-debug.log
|
||||
tools/*
|
||||
!tools/release/
|
||||
tools/release/*
|
||||
!tools/release/package.json
|
||||
|
||||
frontend/.angular
|
||||
frontend/dist
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
name: Compute Release Notes
|
||||
description: Build conventional-commit release notes for an explicit git range.
|
||||
|
||||
inputs:
|
||||
base_tag:
|
||||
description: Stable tag that anchors the preview version calculation
|
||||
required: false
|
||||
default: ''
|
||||
from_ref:
|
||||
description: Git ref that marks the start of the changelog range
|
||||
required: true
|
||||
repository_url:
|
||||
description: Repository URL used for compare and commit links
|
||||
required: false
|
||||
default: ''
|
||||
to_ref:
|
||||
description: Git ref that marks the end of the changelog range
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
compare_url:
|
||||
description: Compare URL for the computed range
|
||||
value: ${{ steps.extract.outputs.compare_url }}
|
||||
details_url:
|
||||
description: Workflow run URL that contains the full markdown summary
|
||||
value: ${{ steps.extract.outputs.details_url }}
|
||||
predicted_version:
|
||||
description: Predicted semantic version for the supplied range
|
||||
value: ${{ steps.extract.outputs.predicted_version }}
|
||||
release_notes:
|
||||
description: Markdown notes generated from conventional commits
|
||||
value: ${{ steps.extract.outputs.release_notes }}
|
||||
release_type:
|
||||
description: Highest semantic release type found in the range
|
||||
value: ${{ steps.extract.outputs.release_type }}
|
||||
released:
|
||||
description: Whether the range contains any releasable commits
|
||||
value: ${{ steps.extract.outputs.released }}
|
||||
to_sha:
|
||||
description: Resolved ending SHA for the range
|
||||
value: ${{ steps.extract.outputs.to_sha }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: ${{ inputs.to_ref }}
|
||||
|
||||
- name: Install just
|
||||
uses: taiki-e/install-action@a1df9120380005ebdc788c62449b841b205541dd # v2.71.0
|
||||
with:
|
||||
tool: just
|
||||
|
||||
- name: Set Up pnpm
|
||||
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
|
||||
|
||||
- name: Set Up Node.js
|
||||
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
||||
with:
|
||||
node-version-file: .nvmrc
|
||||
|
||||
- name: Install Release Tooling Dependencies
|
||||
shell: bash
|
||||
run: just release install
|
||||
|
||||
- name: Generate Range Notes
|
||||
shell: bash
|
||||
env:
|
||||
BASE_TAG: ${{ inputs.base_tag }}
|
||||
FROM_REF: ${{ inputs.from_ref }}
|
||||
OUTPUT_JSON: range-release.json
|
||||
OUTPUT_NOTES: range-release-notes.md
|
||||
REPOSITORY_URL: ${{ inputs.repository_url != '' && inputs.repository_url || format('{0}/{1}', github.server_url, github.repository) }}
|
||||
TO_REF: ${{ inputs.to_ref }}
|
||||
run: |
|
||||
just release range-notes | tee tools/release/range-release.log
|
||||
|
||||
- name: Extract Range Outputs
|
||||
id: extract
|
||||
shell: bash
|
||||
env:
|
||||
BASE_TAG: ${{ inputs.base_tag }}
|
||||
DETAILS_URL: ${{ format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
|
||||
FROM_REF: ${{ inputs.from_ref }}
|
||||
TO_REF: ${{ inputs.to_ref }}
|
||||
run: |
|
||||
set -eu
|
||||
|
||||
compare_url="$(jq -r '.compareUrl // empty' tools/release/range-release.json)"
|
||||
predicted_version="$(jq -r '.nextVersion // empty' tools/release/range-release.json)"
|
||||
release_type="$(jq -r '.releaseType // empty' tools/release/range-release.json)"
|
||||
released="$(jq -r '.released' tools/release/range-release.json)"
|
||||
to_sha="$(jq -r '.toSha // empty' tools/release/range-release.json)"
|
||||
release_notes_delim="EOF_$(openssl rand -hex 16)"
|
||||
|
||||
{
|
||||
echo "compare_url=${compare_url}"
|
||||
echo "details_url=${DETAILS_URL}"
|
||||
echo "predicted_version=${predicted_version}"
|
||||
echo "release_type=${release_type}"
|
||||
echo "released=${released}"
|
||||
echo "to_sha=${to_sha}"
|
||||
echo "release_notes<<${release_notes_delim}"
|
||||
cat tools/release/range-release-notes.md
|
||||
printf '\n'
|
||||
echo "${release_notes_delim}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
{
|
||||
echo "## Full Changelog"
|
||||
echo
|
||||
echo "- Range: \`${FROM_REF}..${TO_REF}\`"
|
||||
echo "- Predicted version: \`${predicted_version:-none}\`"
|
||||
echo "- Release type: \`${release_type:-none}\`"
|
||||
if [ -n "${BASE_TAG}" ]; then
|
||||
echo "- Base stable tag: \`${BASE_TAG}\`"
|
||||
fi
|
||||
if [ -n "$compare_url" ]; then
|
||||
echo "- Compare: ${compare_url}"
|
||||
fi
|
||||
echo
|
||||
cat tools/release/range-release-notes.md
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Upload Range Notes Artifact
|
||||
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
|
||||
with:
|
||||
name: range-release-notes
|
||||
path: |
|
||||
tools/release/range-release.json
|
||||
tools/release/range-release-notes.md
|
||||
tools/release/range-release.log
|
||||
retention-days: 14
|
||||
@@ -0,0 +1,137 @@
|
||||
# git-cliff ~ configuration file
|
||||
# https://git-cliff.org/docs/configuration
|
||||
|
||||
[bump]
|
||||
features_always_bump_minor = true
|
||||
breaking_always_bump_major = true
|
||||
|
||||
[changelog]
|
||||
# A Tera template to be rendered as the changelog's header.
|
||||
# See https://keats.github.io/tera/#getting-started
|
||||
header = """
|
||||
"""
|
||||
|
||||
# A Tera template to be rendered for each release in the changelog.
|
||||
# See https://keats.github.io/tera/#getting-started
|
||||
body = """
|
||||
{%- macro remote_url() -%}
|
||||
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{% macro print_commit(commit) -%}
|
||||
- {% if commit.scope %}**{{ commit.scope }}:** {% endif %}\
|
||||
{% if commit.breaking %}[**breaking**] {% endif %}\
|
||||
{{ commit.message | upper_first }} \
|
||||
([`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{ commit.id }}))\
|
||||
{% endmacro -%}
|
||||
|
||||
{% if version -%}
|
||||
{% if previous.version -%}
|
||||
## [{{ version | trim_start_matches(pat="v") }}]\
|
||||
({{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}) ({{ timestamp | date(format="%Y-%m-%d") }})
|
||||
{%- else -%}
|
||||
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
||||
{%- endif %}
|
||||
{%- else -%}
|
||||
## [unreleased]
|
||||
{%- endif %}
|
||||
|
||||
## Changelog
|
||||
{% if version and previous.version %}
|
||||
**Full Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
|
||||
|
||||
{% endif -%}
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | striptags | trim | upper_first }}
|
||||
{% for commit in commits
|
||||
| filter(attribute="scope")
|
||||
| sort(attribute="scope") %}
|
||||
{{ self::print_commit(commit=commit) }}
|
||||
{%- endfor %}
|
||||
{% for commit in commits %}
|
||||
{%- if not commit.scope -%}
|
||||
{{ self::print_commit(commit=commit) }}
|
||||
{% endif -%}
|
||||
{% endfor -%}
|
||||
{% endfor -%}
|
||||
{%- if version -%}
|
||||
{%- if github %}
|
||||
## Contributors
|
||||
|
||||
We'd like to thank the contributors for this release for taking the time to make Grimmory better.
|
||||
|
||||
Including but not limited to:
|
||||
{%- for contributor in github.contributors -%}
|
||||
{%- if contributor.username and contributor.username is not ending_with("[bot]") -%}
|
||||
{% raw %} {% endraw -%}@{{ contributor.username }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{% set first_time_contributors = github.contributors | filter(attribute="is_first_time", value=true) -%}
|
||||
{% if first_time_contributors | length != 0 %}
|
||||
|
||||
### New Contributors
|
||||
{% endif %}\
|
||||
{% for contributor in first_time_contributors %}
|
||||
* @{{ contributor.username }} made their first contribution
|
||||
{%- if contributor.pr_number %} in #{{ contributor.pr_number }}{%- endif %}
|
||||
{%- endfor -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
"""
|
||||
# A Tera template to be rendered as the changelog's footer.
|
||||
# See https://keats.github.io/tera/#getting-started
|
||||
footer = """
|
||||
"""
|
||||
|
||||
# Remove leading and trailing whitespaces from the changelog's body.
|
||||
trim = true
|
||||
# Format the rendered changelog as Markdown (only applies to Markdown output).
|
||||
# format = true
|
||||
# An array of regex based postprocessors to modify the changelog.
|
||||
postprocessors = [
|
||||
|
||||
]
|
||||
|
||||
[git]
|
||||
# Parse commits according to the conventional commits specification.
|
||||
# See https://www.conventionalcommits.org
|
||||
conventional_commits = true
|
||||
# Exclude commits that do not match the conventional commits specification.
|
||||
filter_unconventional = true
|
||||
# Split commits on newlines, treating each line as an individual commit.
|
||||
split_commits = false
|
||||
# An array of regex based parsers to modify commit messages prior to further processing.
|
||||
commit_preprocessors = [
|
||||
|
||||
]
|
||||
# An array of regex based parsers for extracting data from the commit message.
|
||||
# Assigns commits to groups.
|
||||
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
|
||||
commit_parsers = [
|
||||
# Skip commits without a scope, except breaking changes (e.g., "feat!: xxx")
|
||||
{ message = "^feat", group = "<!-- 0 -->Features" },
|
||||
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
|
||||
{ message = "^doc", group = "<!-- 3 -->Documentation" },
|
||||
{ message = "^perf", group = "<!-- 4 -->Performance" },
|
||||
{ message = "^refactor", group = "<!-- 2 -->Refactor" },
|
||||
{ message = "^style", group = "<!-- 5 -->Styling" },
|
||||
{ message = "^test", group = "<!-- 6 -->Testing" },
|
||||
{ message = "^chore\\(deps.*\\)", group = "<!-- 8 -->Dependencies" },
|
||||
{ message = "^chore|^ci", group = "<!-- 7 -->Miscellaneous Tasks" },
|
||||
{ message = "^revert", group = "<!-- 9 -->Revert" },
|
||||
]
|
||||
# Prevent commits that are breaking from being excluded by commit parsers.
|
||||
protect_breaking_commits = false
|
||||
# Exclude commits that are not matched by any commit parser.
|
||||
filter_commits = false
|
||||
# Regex to select git tags that represent releases.
|
||||
tag_pattern = "v[0-9].*"
|
||||
# Regex to select git tags that do not represent proper releases.
|
||||
# Takes precedence over `tag_pattern`.
|
||||
# Changes belonging to these releases will be included in the next release.
|
||||
skip_tags = "beta|alpha"
|
||||
# Order releases topologically instead of chronologically.
|
||||
topo_order = false
|
||||
# Order of commits in each group/release within the changelog.
|
||||
# Allowed values: newest, oldest
|
||||
sort_commits = "newest"
|
||||
@@ -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 }}
|
||||
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 }}
|
||||
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
|
||||
semantic-version:
|
||||
name: Generate Notes
|
||||
needs:
|
||||
- resolve-refs
|
||||
- migration-check
|
||||
uses: ./.github/workflows/compute-release-notes.yml
|
||||
permissions:
|
||||
contents: read
|
||||
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 }}
|
||||
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/*
|
||||
|
||||
@@ -14,7 +14,6 @@ RUN --mount=type=cache,target=/pnpm/store \
|
||||
|
||||
COPY package.json ./
|
||||
COPY frontend/package.json ./frontend/
|
||||
COPY tools/release/package.json ./tools/release/
|
||||
RUN --mount=type=cache,target=/pnpm/store \
|
||||
pnpm install --offline --frozen-lockfile --ignore-scripts
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
|
||||
|
||||
mod api 'backend/Justfile'
|
||||
mod ui 'frontend/Justfile'
|
||||
mod release 'tools/release/Justfile'
|
||||
|
||||
compose_file := env_var_or_default('GRIMMORY_COMPOSE_FILE', 'dev.docker-compose.yml')
|
||||
compose_cmd := 'docker compose -f ' + compose_file
|
||||
|
||||
Generated
-1849
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
||||
packages:
|
||||
- frontend
|
||||
- tools/release
|
||||
|
||||
minimumReleaseAge: 4320
|
||||
blockExoticSubdeps: true
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
|
||||
|
||||
pnpm := "pnpm"
|
||||
|
||||
# Show the release-tooling recipes available in this directory.
|
||||
help:
|
||||
@just --list
|
||||
|
||||
# Install the pinned semantic-release tooling used by local and CI release tasks.
|
||||
install:
|
||||
{{ pnpm }} install --frozen-lockfile
|
||||
|
||||
# Preview the next semantic-release result for the current checkout.
|
||||
preview:
|
||||
{{ pnpm }} run release:dry-run
|
||||
|
||||
# Generate release notes for an explicit commit range.
|
||||
range-notes:
|
||||
{{ pnpm }} run release:range-notes
|
||||
|
||||
# Run semantic-release for the current checkout.
|
||||
run:
|
||||
{{ pnpm }} run release
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "grimmory-release-tooling",
|
||||
"private": true,
|
||||
"description": "Release automation tooling for Grimmory",
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
},
|
||||
"scripts": {
|
||||
"release": "semantic-release",
|
||||
"release:dry-run": "semantic-release --dry-run",
|
||||
"release:range-notes": "node ./scripts/generate-range-notes.mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "7.0.0",
|
||||
"@semantic-release/commit-analyzer": "13.0.1",
|
||||
"@semantic-release/git": "11.0.1",
|
||||
"@semantic-release/release-notes-generator": "14.1.1",
|
||||
"conventional-changelog-conventionalcommits": "10.4.0",
|
||||
"semantic-release": "25.0.9"
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
const types = [
|
||||
{ type: "feat", section: "Features" },
|
||||
{ type: "fix", section: "Bug Fixes" },
|
||||
{ type: "perf", section: "Performance" },
|
||||
{ type: "refactor", section: "Refactors", release: "patch" },
|
||||
{ type: "chore", section: "Chores", release: false },
|
||||
{ type: "docs", section: "Documentation", release: false },
|
||||
{ type: "ci", section: "CI", release: false },
|
||||
{ type: "build", section: "Build", release: false },
|
||||
{ type: "test", section: "Tests", release: false },
|
||||
{ type: "style", section: "Style", release: false },
|
||||
{ type: "revert", section: "Reverts", release: "patch" }
|
||||
];
|
||||
|
||||
const noteKeywords = ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"];
|
||||
|
||||
module.exports = {
|
||||
noteKeywords,
|
||||
types,
|
||||
writerSortFields: ["scope", "subject"]
|
||||
};
|
||||
@@ -1,48 +0,0 @@
|
||||
const releasePolicy = require("./release-policy.cjs");
|
||||
|
||||
module.exports = {
|
||||
branches: ["main"],
|
||||
tagFormat: "v${version}",
|
||||
plugins: [
|
||||
[
|
||||
"@semantic-release/commit-analyzer",
|
||||
{
|
||||
preset: "conventionalcommits",
|
||||
presetConfig: {
|
||||
types: releasePolicy.types.map(({ section, type }) => ({ hidden: false, section, type }))
|
||||
},
|
||||
parserOpts: {
|
||||
noteKeywords: releasePolicy.noteKeywords
|
||||
},
|
||||
releaseRules: releasePolicy.types
|
||||
.filter((entry) => Object.prototype.hasOwnProperty.call(entry, "release"))
|
||||
.map(({ release, type }) => ({ release, type }))
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/release-notes-generator",
|
||||
{
|
||||
preset: "conventionalcommits",
|
||||
presetConfig: {
|
||||
types: releasePolicy.types.map(({ section, type }) => ({ hidden: false, section, type }))
|
||||
},
|
||||
parserOpts: {
|
||||
noteKeywords: releasePolicy.noteKeywords
|
||||
},
|
||||
writerOpts: {
|
||||
commitsSort: releasePolicy.writerSortFields
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
"@semantic-release/github",
|
||||
{
|
||||
draftRelease: true,
|
||||
releaseNameTemplate: "Release <%= nextRelease.gitTag %>",
|
||||
successComment: false,
|
||||
failComment: false,
|
||||
releasedLabels: false
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
@@ -1,276 +0,0 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { writeFileSync } from "node:fs";
|
||||
import releasePolicy from "../release-policy.cjs";
|
||||
|
||||
const repoRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], { encoding: "utf8" }).trim();
|
||||
const fromRef = requiredEnv("FROM_REF");
|
||||
const toRef = process.env.TO_REF || "HEAD";
|
||||
const outputJsonPath = process.env.OUTPUT_JSON || "range-release.json";
|
||||
const outputNotesPath = process.env.OUTPUT_NOTES || "range-release-notes.md";
|
||||
const baseTag = process.env.BASE_TAG || "";
|
||||
const baseVersion = coerceVersion(process.env.BASE_VERSION || stripVersion(baseTag) || stripVersion(fromRef));
|
||||
const repositoryUrl = normalizeRepositoryUrl(process.env.REPOSITORY_URL || defaultRepositoryUrl());
|
||||
const compareBase = process.env.COMPARE_FROM_REF || fromRef;
|
||||
const compareHead = process.env.COMPARE_TO_REF || toRef;
|
||||
|
||||
const policyByType = new Map(releasePolicy.types.map((entry) => [entry.type, entry]));
|
||||
const sections = releasePolicy.types.map((entry) => entry.section);
|
||||
|
||||
const fromSha = runGit(["rev-parse", fromRef]).trim();
|
||||
const toSha = runGit(["rev-parse", toRef]).trim();
|
||||
const commits = parseCommits(listCommits(fromRef, toRef));
|
||||
const groupedCommits = new Map();
|
||||
|
||||
for (const section of sections) {
|
||||
groupedCommits.set(section, []);
|
||||
}
|
||||
groupedCommits.set("Other Changes", []);
|
||||
|
||||
let releaseType = "none";
|
||||
const breakingChanges = [];
|
||||
|
||||
for (const commit of commits) {
|
||||
groupedCommits.get(commit.section).push(commit);
|
||||
releaseType = maxReleaseType(releaseType, commit.releaseType);
|
||||
for (const note of commit.breakingNotes) {
|
||||
breakingChanges.push({ hash: commit.hash, note });
|
||||
}
|
||||
}
|
||||
|
||||
const predictedVersion = releaseType !== "none" ? incrementVersion(baseVersion, releaseType) : "";
|
||||
const compareUrl = repositoryUrl ? `${repositoryUrl}/compare/${compareBase}...${compareHead}` : "";
|
||||
const releaseNotes = renderReleaseNotes(groupedCommits, breakingChanges, repositoryUrl);
|
||||
|
||||
const payload = {
|
||||
baseTag,
|
||||
baseVersion,
|
||||
compareUrl,
|
||||
fromRef,
|
||||
fromSha,
|
||||
nextGitTag: predictedVersion ? `v${predictedVersion}` : "",
|
||||
nextVersion: predictedVersion,
|
||||
releaseNotes,
|
||||
releaseType,
|
||||
released: releaseType !== "none",
|
||||
toRef,
|
||||
toSha
|
||||
};
|
||||
|
||||
writeFileSync(outputJsonPath, `${JSON.stringify(payload, null, 2)}\n`);
|
||||
writeFileSync(outputNotesPath, releaseNotes ? `${releaseNotes}\n` : "");
|
||||
|
||||
function runGit(args) {
|
||||
return execFileSync("git", args, { cwd: repoRoot, encoding: "utf8" });
|
||||
}
|
||||
|
||||
function requiredEnv(name) {
|
||||
const value = process.env[name];
|
||||
if (!value) {
|
||||
throw new Error(`Missing required environment variable: ${name}`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function defaultRepositoryUrl() {
|
||||
if (process.env.GITHUB_SERVER_URL && process.env.GITHUB_REPOSITORY) {
|
||||
return `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function normalizeRepositoryUrl(value) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return value.replace(/\.git$/, "");
|
||||
}
|
||||
|
||||
function stripVersion(value) {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const match = value.match(/^v?(\d+\.\d+\.\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
|
||||
return match ? match[1] : "";
|
||||
}
|
||||
|
||||
function coerceVersion(value) {
|
||||
if (!value) {
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
const match = value.match(/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/);
|
||||
return match ? match[1] + "." + match[2] + "." + match[3] : "0.0.0";
|
||||
}
|
||||
|
||||
function listCommits(startRef, endRef) {
|
||||
return runGit([
|
||||
"log",
|
||||
"--reverse",
|
||||
"--no-merges",
|
||||
"--format=%H%x1f%s%x1f%b%x1e",
|
||||
`${startRef}..${endRef}`
|
||||
]);
|
||||
}
|
||||
|
||||
function parseCommits(rawLog) {
|
||||
return rawLog
|
||||
.split("\x1e")
|
||||
.map((entry) => entry.trim())
|
||||
.filter(Boolean)
|
||||
.map((entry) => {
|
||||
const [hash, subject, body = ""] = entry.split("\x1f");
|
||||
const conventional = parseConventionalSubject(subject);
|
||||
const type = conventional?.type || "";
|
||||
const policy = policyByType.get(type);
|
||||
|
||||
return {
|
||||
body,
|
||||
breakingNotes: findBreakingNotes(body, subject),
|
||||
hash,
|
||||
releaseType: detectReleaseType(conventional, body),
|
||||
scope: conventional?.scope || "",
|
||||
section: policy?.section || "Other Changes",
|
||||
subject: conventional?.subject || subject,
|
||||
type
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function parseConventionalSubject(subject) {
|
||||
const match = subject.match(/^(?<type>[a-z]+)(?:\((?<scope>[^)]+)\))?(?<breaking>!)?: (?<subject>.+)$/i);
|
||||
if (!match?.groups) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
breaking: Boolean(match.groups.breaking),
|
||||
scope: match.groups.scope || "",
|
||||
subject: match.groups.subject,
|
||||
type: match.groups.type.toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
function findBreakingNotes(body, subject) {
|
||||
const lines = body.split(/\r?\n/);
|
||||
const notes = [];
|
||||
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (const keyword of releasePolicy.noteKeywords) {
|
||||
const prefix = `${keyword}:`;
|
||||
if (trimmed.startsWith(prefix)) {
|
||||
notes.push(trimmed.slice(prefix.length).trim() || subject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
function detectReleaseType(conventional, body) {
|
||||
if (!conventional) {
|
||||
return "none";
|
||||
}
|
||||
|
||||
if (conventional.breaking || findBreakingNotes(body, conventional.subject).length > 0) {
|
||||
return "major";
|
||||
}
|
||||
|
||||
if (conventional.type === "feat") {
|
||||
return "minor";
|
||||
}
|
||||
|
||||
if (conventional.type === "fix" || conventional.type === "perf" || conventional.type === "revert") {
|
||||
return "patch";
|
||||
}
|
||||
|
||||
if (conventional.type === "refactor") {
|
||||
return "patch";
|
||||
}
|
||||
|
||||
const policy = policyByType.get(conventional.type);
|
||||
if (policy?.release === false) {
|
||||
return "none";
|
||||
}
|
||||
|
||||
return "none";
|
||||
}
|
||||
|
||||
function maxReleaseType(current, next) {
|
||||
const rank = new Map([
|
||||
["none", 0],
|
||||
["patch", 1],
|
||||
["minor", 2],
|
||||
["major", 3]
|
||||
]);
|
||||
|
||||
return rank.get(next) > rank.get(current) ? next : current;
|
||||
}
|
||||
|
||||
function incrementVersion(version, releaseType) {
|
||||
const [major, minor, patch] = version.split(".").map((value) => Number.parseInt(value, 10) || 0);
|
||||
|
||||
if (releaseType === "major") {
|
||||
return `${major + 1}.0.0`;
|
||||
}
|
||||
|
||||
if (releaseType === "minor") {
|
||||
return `${major}.${minor + 1}.0`;
|
||||
}
|
||||
|
||||
if (releaseType === "patch") {
|
||||
return `${major}.${minor}.${patch + 1}`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function renderReleaseNotes(grouped, breakingNotes, repository) {
|
||||
const lines = [];
|
||||
|
||||
if (breakingNotes.length > 0) {
|
||||
lines.push("## Breaking Changes", "");
|
||||
for (const entry of breakingNotes) {
|
||||
lines.push(`- ${entry.note} (${formatCommitRef(entry.hash, repository)})`);
|
||||
}
|
||||
lines.push("");
|
||||
}
|
||||
|
||||
for (const [section, commits] of grouped.entries()) {
|
||||
if (commits.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const sortedCommits = [...commits].sort((left, right) => {
|
||||
const leftKey = `${left.scope}\u0000${left.subject}`.toLowerCase();
|
||||
const rightKey = `${right.scope}\u0000${right.subject}`.toLowerCase();
|
||||
return leftKey.localeCompare(rightKey);
|
||||
});
|
||||
|
||||
lines.push(`## ${section}`, "");
|
||||
for (const commit of sortedCommits) {
|
||||
const scopePrefix = commit.scope ? `**${commit.scope}:** ` : "";
|
||||
lines.push(`- ${scopePrefix}${commit.subject} (${formatCommitRef(commit.hash, repository)})`);
|
||||
}
|
||||
lines.push("");
|
||||
}
|
||||
|
||||
return lines.join("\n").trim();
|
||||
}
|
||||
|
||||
function formatCommitRef(hash, repository) {
|
||||
const shortHash = hash.slice(0, 7);
|
||||
if (!repository) {
|
||||
return `\`${shortHash}\``;
|
||||
}
|
||||
|
||||
return `[\`${shortHash}\`](${repository}/commit/${hash})`;
|
||||
}
|
||||
Reference in New Issue
Block a user