You've already forked computing-box
chore: add git-cliff configuration
Some checks failed
Changelog + Release on main / changelog_and_release (push) Failing after 33s
Some checks failed
Changelog + Release on main / changelog_and_release (push) Failing after 33s
feat(release): implement incremental changelog and versioned release workflow - Generate changelog from previous release tag to HEAD - Replace full-history changelog with incremental git-cliff usage - Add automatic version bump from date-based tag - Commit and push version updates (package.json and lockfile) - Refactor workflow order to align changelog, versioning, and build - Improve Node setup and add version checks - Introduce cliff.toml configuration for grouped changelog output - Add generated version.json for runtime version display - Update footer layout to include dynamic version and release link Signed-off-by: Alexander Lyall <alex@adcm.uk>
This commit is contained in:
@@ -15,7 +15,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Stop if this is the bot changelog commit
|
- name: Stop if this is the bot changelog/version commit
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
@@ -36,58 +36,6 @@ jobs:
|
|||||||
sudo install /tmp/git-cliff-*/git-cliff /usr/local/bin/git-cliff
|
sudo install /tmp/git-cliff-*/git-cliff /usr/local/bin/git-cliff
|
||||||
git-cliff --version
|
git-cliff --version
|
||||||
|
|
||||||
- name: Generate CHANGELOG.md (Keep a Changelog)
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
git-cliff --config cliff.toml --output CHANGELOG.md
|
|
||||||
test -s CHANGELOG.md
|
|
||||||
|
|
||||||
- name: Commit and push CHANGELOG.md if changed (CHANGELOG_PAT)
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }}
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if git diff --quiet -- CHANGELOG.md; then
|
|
||||||
echo "No changelog changes."
|
|
||||||
else
|
|
||||||
git config user.name "changelog-bot"
|
|
||||||
git config user.email "changelog-bot@users.noreply.local"
|
|
||||||
|
|
||||||
git add CHANGELOG.md
|
|
||||||
git commit -m "docs(changelog): update changelog [skip ci]"
|
|
||||||
|
|
||||||
origin_url="$(git remote get-url origin)"
|
|
||||||
|
|
||||||
# Convert SSH origin to HTTPS if needed
|
|
||||||
if echo "$origin_url" | grep -q "^git@"; then
|
|
||||||
host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')"
|
|
||||||
path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')"
|
|
||||||
origin_url="https://$host/$path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")"
|
|
||||||
git push "$authed_url" HEAD:main
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Extract newest changelog section for release body
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
awk '
|
|
||||||
/^## / { if (seen) exit; seen=1 }
|
|
||||||
seen { print }
|
|
||||||
' CHANGELOG.md > RELEASE_NOTES.md
|
|
||||||
|
|
||||||
sed -i 's/[[:space:]]*$//' RELEASE_NOTES.md
|
|
||||||
|
|
||||||
test -s RELEASE_NOTES.md
|
|
||||||
echo "---- RELEASE_NOTES.md ----"
|
|
||||||
head -n 60 RELEASE_NOTES.md
|
|
||||||
echo "--------------------------"
|
|
||||||
|
|
||||||
- name: Prepare YY.MM.DD letter-suffix tag + release name
|
- name: Prepare YY.MM.DD letter-suffix tag + release name
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -139,13 +87,87 @@ jobs:
|
|||||||
echo "Release name: $RELEASE_NAME"
|
echo "Release name: $RELEASE_NAME"
|
||||||
echo "Release URL: $RELEASE_URL"
|
echo "Release URL: $RELEASE_URL"
|
||||||
|
|
||||||
|
- name: Find previous release tag
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
PREV_TAG="$(
|
||||||
|
git tag --list 'v*' \
|
||||||
|
| grep -E '^v[0-9]{2}\.[0-9]{2}\.[0-9]{2}[a-z]$' \
|
||||||
|
| sort -V \
|
||||||
|
| tail -n 1
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [ -n "$PREV_TAG" ]; then
|
||||||
|
echo "PREV_TAG=$PREV_TAG" >> "$GITHUB_ENV"
|
||||||
|
echo "Previous release tag: $PREV_TAG"
|
||||||
|
else
|
||||||
|
echo "PREV_TAG=" >> "$GITHUB_ENV"
|
||||||
|
echo "No previous release tag found."
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Generate CHANGELOG.md from previous release to HEAD
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ -n "${PREV_TAG}" ]; then
|
||||||
|
echo "Generating changelog from ${PREV_TAG}..HEAD"
|
||||||
|
git-cliff --config cliff.toml "${PREV_TAG}..HEAD" --output CHANGELOG.md
|
||||||
|
else
|
||||||
|
echo "Generating changelog from full history"
|
||||||
|
git-cliff --config cliff.toml --output CHANGELOG.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -s CHANGELOG.md
|
||||||
|
echo "---- CHANGELOG.md ----"
|
||||||
|
head -n 120 CHANGELOG.md
|
||||||
|
echo "----------------------"
|
||||||
|
|
||||||
|
- name: Commit and push CHANGELOG.md if changed (CHANGELOG_PAT)
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if git diff --quiet -- CHANGELOG.md; then
|
||||||
|
echo "No changelog changes."
|
||||||
|
else
|
||||||
|
git config user.name "changelog-bot"
|
||||||
|
git config user.email "changelog-bot@users.noreply.local"
|
||||||
|
|
||||||
|
git add CHANGELOG.md
|
||||||
|
git commit -m "docs(changelog): update changelog [skip ci]"
|
||||||
|
|
||||||
|
origin_url="$(git remote get-url origin)"
|
||||||
|
|
||||||
|
if echo "$origin_url" | grep -q "^git@"; then
|
||||||
|
host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')"
|
||||||
|
path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')"
|
||||||
|
origin_url="https://$host/$path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")"
|
||||||
|
git push "$authed_url" HEAD:main
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Prepare release notes
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
cp CHANGELOG.md RELEASE_NOTES.md
|
||||||
|
test -s RELEASE_NOTES.md
|
||||||
|
echo "---- RELEASE_NOTES.md ----"
|
||||||
|
head -n 120 RELEASE_NOTES.md
|
||||||
|
echo "--------------------------"
|
||||||
|
|
||||||
- name: Derive semver package version from tag
|
- name: Derive semver package version from tag
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# Convert:
|
|
||||||
# v25.03.21a -> 25.3.21-a
|
|
||||||
PACKAGE_VERSION="$(echo "$TAG" | sed -E 's/^v([0-9]{2})\.0?([0-9]{1,2})\.0?([0-9]{1,2})([a-z])$/\1.\2.\3-\4/')"
|
PACKAGE_VERSION="$(echo "$TAG" | sed -E 's/^v([0-9]{2})\.0?([0-9]{1,2})\.0?([0-9]{1,2})([a-z])$/\1.\2.\3-\4/')"
|
||||||
|
|
||||||
if [ -z "$PACKAGE_VERSION" ]; then
|
if [ -z "$PACKAGE_VERSION" ]; then
|
||||||
@@ -174,9 +196,15 @@ jobs:
|
|||||||
- name: Set up Node
|
- name: Set up Node
|
||||||
uses: actions/setup-node@v6
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: 25
|
node-version: 22.12.0
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
|
- name: Check Node version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
node -v
|
||||||
|
npm -v
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -195,6 +223,34 @@ jobs:
|
|||||||
echo "package-lock.json version:"
|
echo "package-lock.json version:"
|
||||||
node -p "require('./package-lock.json').version"
|
node -p "require('./package-lock.json').version"
|
||||||
|
|
||||||
|
- name: Commit and push version bump (CHANGELOG_PAT)
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if git diff --quiet -- package.json package-lock.json; then
|
||||||
|
echo "No version changes to commit."
|
||||||
|
else
|
||||||
|
git config user.name "release-bot"
|
||||||
|
git config user.email "release-bot@users.noreply.local"
|
||||||
|
|
||||||
|
git add package.json package-lock.json
|
||||||
|
git commit -m "chore(release): bump version to ${PACKAGE_VERSION} [skip ci]"
|
||||||
|
|
||||||
|
origin_url="$(git remote get-url origin)"
|
||||||
|
|
||||||
|
if echo "$origin_url" | grep -q "^git@"; then
|
||||||
|
host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')"
|
||||||
|
path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')"
|
||||||
|
origin_url="https://$host/$path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")"
|
||||||
|
git push "$authed_url" HEAD:main
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Build Astro site
|
- name: Build Astro site
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@@ -306,34 +362,4 @@ jobs:
|
|||||||
-F "attachment=@${ZIP_PATH}" \
|
-F "attachment=@${ZIP_PATH}" \
|
||||||
>/dev/null
|
>/dev/null
|
||||||
|
|
||||||
echo "✅ Release created: ${RELEASE_NAME} (tag: ${TAG}) with asset uploaded"
|
echo "✅ Release created: ${RELEASE_NAME} (tag: ${TAG}) with asset uploaded"
|
||||||
|
|
||||||
- name: Commit and push version bump (CHANGELOG_PAT)
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
CHANGELOG_PAT: ${{ secrets.CHANGELOG_PAT }}
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
if git diff --quiet -- package.json package-lock.json; then
|
|
||||||
echo "No version changes to commit."
|
|
||||||
else
|
|
||||||
git config user.name "release-bot"
|
|
||||||
git config user.email "release-bot@users.noreply.local"
|
|
||||||
|
|
||||||
git add package.json package-lock.json
|
|
||||||
git commit -m "chore(release): bump version to ${PACKAGE_VERSION} [skip ci]"
|
|
||||||
|
|
||||||
origin_url="$(git remote get-url origin)"
|
|
||||||
|
|
||||||
# Convert SSH → HTTPS if needed
|
|
||||||
if echo "$origin_url" | grep -q "^git@"; then
|
|
||||||
host="$(echo "$origin_url" | sed -E 's#git@([^:]+):.*#\1#')"
|
|
||||||
path="$(echo "$origin_url" | sed -E 's#git@[^:]+:(.*)#\1#')"
|
|
||||||
origin_url="https://$host/$path"
|
|
||||||
fi
|
|
||||||
|
|
||||||
authed_url="$(echo "$origin_url" | sed -E "s#^https://#https://oauth2:${CHANGELOG_PAT}@#")"
|
|
||||||
|
|
||||||
git push "$authed_url" HEAD:main
|
|
||||||
fi
|
|
||||||
35
cliff.toml
Normal file
35
cliff.toml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[changelog]
|
||||||
|
header = """
|
||||||
|
# Changelog
|
||||||
|
"""
|
||||||
|
|
||||||
|
body = """
|
||||||
|
{% for group, commits in commits | group_by(attribute="group") %}
|
||||||
|
## {{ group }}
|
||||||
|
{% for commit in commits %}
|
||||||
|
- {{ commit.message | upper_first }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
"""
|
||||||
|
|
||||||
|
footer = ""
|
||||||
|
|
||||||
|
[git]
|
||||||
|
conventional_commits = false
|
||||||
|
filter_unconventional = false
|
||||||
|
split_commits = false
|
||||||
|
topo_order = true
|
||||||
|
|
||||||
|
# IMPORTANT: match your tag format
|
||||||
|
tag_pattern = "^v[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}[a-z]$"
|
||||||
|
|
||||||
|
commit_parsers = [
|
||||||
|
{ message = "^feat", group = "🚀 Features" },
|
||||||
|
{ message = "^fix", group = "🐛 Fixes" },
|
||||||
|
{ message = "^refactor", group = "♻️ Refactoring" },
|
||||||
|
{ message = "^docs", group = "📚 Documentation" },
|
||||||
|
{ message = "^chore", group = "💼 Other" },
|
||||||
|
|
||||||
|
# catch-all so NOTHING is dropped
|
||||||
|
{ message = ".*", group = "💼 Other" },
|
||||||
|
]
|
||||||
4
src/generated/version.json
Normal file
4
src/generated/version.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"version": "dev",
|
||||||
|
"url": "#"
|
||||||
|
}
|
||||||
@@ -64,13 +64,10 @@ const { title = "Computing:Box" } = Astro.props;
|
|||||||
<a href="/legal-code" style="margin-left: 32px; color: var(--muted); text-decoration: underline;">Legal Code</a>
|
<a href="/legal-code" style="margin-left: 32px; color: var(--muted); text-decoration: underline;">Legal Code</a>
|
||||||
</div>
|
</div>
|
||||||
<div>Computer Science Concept Simulators</div>
|
<div>Computer Science Concept Simulators</div>
|
||||||
<div>
|
<div> Version:
|
||||||
Version:
|
|
||||||
<a href={releaseUrl} target="_blank" rel="noopener noreferrer">
|
<a href={releaseUrl} target="_blank" rel="noopener noreferrer">
|
||||||
{version}
|
{version}
|
||||||
</a>
|
</a> • © {new Date().getFullYear()} Computing:Box • Created with ♥ by Mr A Lyall</div>
|
||||||
</div>
|
|
||||||
<div>© {new Date().getFullYear()} Computing:Box • Created with ♥ by Mr A Lyall</div>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user