mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00
📜 ci: AutomateCHANGELOG.md
(#5838)
* feat: started with automated CHANGELOG.md * fix: no `configuration.json` found * refactor: `configuration.json` * fix: missing label `configuration.json` * fix: missing label `configuration.json` * fix: missing label `configuration.json` * fix: missing label `configuration.json` * fix: missing label `configuration.json` * ci: test new workflow action * ci: test new workflow action * ci: test new workflow action * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * feat: working CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * fix: separate release and Unreleased workflows CHANGELOG.md generation * refactor: only trigger the `unreleased-changelog` action on push to `main` and `generate-release-changelog` only when pushing a tag with `v*.*.*` * refactor: Runs only every Monday at 00:00 UTC
This commit is contained in:
parent
ecddffa7b2
commit
06282b584f
4 changed files with 328 additions and 0 deletions
60
.github/configuration-release.json
vendored
Normal file
60
.github/configuration-release.json
vendored
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "### ✨ New Features",
|
||||||
|
"labels": ["feat"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 🌍 Internationalization",
|
||||||
|
"labels": ["i18n"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 👐 Accessibility",
|
||||||
|
"labels": ["a11y"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 🔧 Fixes",
|
||||||
|
"labels": ["Fix", "fix"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### ⚙️ Other Changes",
|
||||||
|
"labels": ["ci", "style", "docs", "refactor", "chore"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ignore_labels": [
|
||||||
|
"🔁 duplicate",
|
||||||
|
"📊 analytics",
|
||||||
|
"🌱 good first issue",
|
||||||
|
"🔍 investigation",
|
||||||
|
"🙏 help wanted",
|
||||||
|
"❌ invalid",
|
||||||
|
"❓ question",
|
||||||
|
"🚫 wontfix",
|
||||||
|
"🚀 release",
|
||||||
|
"version"
|
||||||
|
],
|
||||||
|
"base_branches": ["main"],
|
||||||
|
"sort": {
|
||||||
|
"order": "ASC",
|
||||||
|
"on_property": "mergedAt"
|
||||||
|
},
|
||||||
|
"label_extractor": [
|
||||||
|
{
|
||||||
|
"pattern": "^(?:[^A-Za-z0-9]*)(feat|fix|chore|docs|refactor|ci|style|a11y|i18n)\\s*:",
|
||||||
|
"target": "$1",
|
||||||
|
"flags": "i",
|
||||||
|
"on_property": "title",
|
||||||
|
"method": "match"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "^(?:[^A-Za-z0-9]*)(v\\d+\\.\\d+\\.\\d+(?:-rc\\d+)?).*",
|
||||||
|
"target": "version",
|
||||||
|
"flags": "i",
|
||||||
|
"on_property": "title",
|
||||||
|
"method": "match"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template": "## [#{{TO_TAG}}] - #{{TO_TAG_DATE}}\n\nChanges from #{{FROM_TAG}} to #{{TO_TAG}}.\n\n#{{CHANGELOG}}\n\n[See full release details][release-#{{TO_TAG}}]\n\n[release-#{{TO_TAG}}]: https://github.com/#{{OWNER}}/#{{REPO}}/releases/tag/#{{TO_TAG}}\n\n---",
|
||||||
|
"pr_template": "- #{{TITLE}} by **@#{{AUTHOR}}** in [##{{NUMBER}}](#{{URL}})",
|
||||||
|
"empty_template": "- no changes"
|
||||||
|
}
|
68
.github/configuration-unreleased.json
vendored
Normal file
68
.github/configuration-unreleased.json
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{
|
||||||
|
"categories": [
|
||||||
|
{
|
||||||
|
"title": "### ✨ New Features",
|
||||||
|
"labels": ["feat"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 🌍 Internationalization",
|
||||||
|
"labels": ["i18n"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 👐 Accessibility",
|
||||||
|
"labels": ["a11y"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### 🔧 Fixes",
|
||||||
|
"labels": ["Fix", "fix"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "### ⚙️ Other Changes",
|
||||||
|
"labels": ["ci", "style", "docs", "refactor", "chore"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ignore_labels": [
|
||||||
|
"🔁 duplicate",
|
||||||
|
"📊 analytics",
|
||||||
|
"🌱 good first issue",
|
||||||
|
"🔍 investigation",
|
||||||
|
"🙏 help wanted",
|
||||||
|
"❌ invalid",
|
||||||
|
"❓ question",
|
||||||
|
"🚫 wontfix",
|
||||||
|
"🚀 release",
|
||||||
|
"version",
|
||||||
|
"action"
|
||||||
|
],
|
||||||
|
"base_branches": ["main"],
|
||||||
|
"sort": {
|
||||||
|
"order": "ASC",
|
||||||
|
"on_property": "mergedAt"
|
||||||
|
},
|
||||||
|
"label_extractor": [
|
||||||
|
{
|
||||||
|
"pattern": "^(?:[^A-Za-z0-9]*)(feat|fix|chore|docs|refactor|ci|style|a11y|i18n)\\s*:",
|
||||||
|
"target": "$1",
|
||||||
|
"flags": "i",
|
||||||
|
"on_property": "title",
|
||||||
|
"method": "match"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "^(?:[^A-Za-z0-9]*)(v\\d+\\.\\d+\\.\\d+(?:-rc\\d+)?).*",
|
||||||
|
"target": "version",
|
||||||
|
"flags": "i",
|
||||||
|
"on_property": "title",
|
||||||
|
"method": "match"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "^(?:[^A-Za-z0-9]*)(action)\\b.*",
|
||||||
|
"target": "action",
|
||||||
|
"flags": "i",
|
||||||
|
"on_property": "title",
|
||||||
|
"method": "match"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"template": "## [Unreleased]\n\n#{{CHANGELOG}}\n\n---",
|
||||||
|
"pr_template": "- #{{TITLE}} by **@#{{AUTHOR}}** in [##{{NUMBER}}](#{{URL}})",
|
||||||
|
"empty_template": "- no changes"
|
||||||
|
}
|
94
.github/workflows/generate-release-changelog-pr.yml
vendored
Normal file
94
.github/workflows/generate-release-changelog-pr.yml
vendored
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
name: Generate Release Changelog PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-release-changelog-pr:
|
||||||
|
permissions:
|
||||||
|
contents: write # Needed for pushing commits and creating branches.
|
||||||
|
pull-requests: write
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# 1. Checkout the repository (with full history).
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# 2. Generate the release changelog using our custom configuration.
|
||||||
|
- name: Generate Release Changelog
|
||||||
|
id: generate_release
|
||||||
|
uses: mikepenz/release-changelog-builder-action@v5.1.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
configuration: ".github/configuration-release.json"
|
||||||
|
owner: ${{ github.repository_owner }}
|
||||||
|
repo: ${{ github.event.repository.name }}
|
||||||
|
outputFile: CHANGELOG-release.md
|
||||||
|
|
||||||
|
# 3. Update the main CHANGELOG.md:
|
||||||
|
# - If it doesn't exist, create it with a basic header.
|
||||||
|
# - Remove the "Unreleased" section (if present).
|
||||||
|
# - Prepend the new release changelog above previous releases.
|
||||||
|
# - Remove all temporary files before committing.
|
||||||
|
- name: Update CHANGELOG.md
|
||||||
|
run: |
|
||||||
|
# Determine the release tag, e.g. "v1.2.3"
|
||||||
|
TAG=${GITHUB_REF##*/}
|
||||||
|
echo "Using release tag: $TAG"
|
||||||
|
|
||||||
|
# Ensure CHANGELOG.md exists; if not, create a basic header.
|
||||||
|
if [ ! -f CHANGELOG.md ]; then
|
||||||
|
echo "# Changelog" > CHANGELOG.md
|
||||||
|
echo "" >> CHANGELOG.md
|
||||||
|
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
|
||||||
|
echo "" >> CHANGELOG.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Updating CHANGELOG.md…"
|
||||||
|
|
||||||
|
# Remove the "Unreleased" section (from "## [Unreleased]" until the first occurrence of '---') if it exists.
|
||||||
|
if grep -q "^## \[Unreleased\]" CHANGELOG.md; then
|
||||||
|
awk '/^## \[Unreleased\]/{flag=1} flag && /^---/{flag=0; next} !flag' CHANGELOG.md > CHANGELOG.cleaned
|
||||||
|
else
|
||||||
|
cp CHANGELOG.md CHANGELOG.cleaned
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Split the cleaned file into:
|
||||||
|
# - header.md: content before the first release header ("## [v...").
|
||||||
|
# - tail.md: content from the first release header onward.
|
||||||
|
awk '/^## \[v/{exit} {print}' CHANGELOG.cleaned > header.md
|
||||||
|
awk 'f{print} /^## \[v/{f=1; print}' CHANGELOG.cleaned > tail.md
|
||||||
|
|
||||||
|
# Combine header, the new release changelog, and the tail.
|
||||||
|
echo "Combining updated changelog parts..."
|
||||||
|
cat header.md CHANGELOG-release.md > CHANGELOG.md.new
|
||||||
|
echo "" >> CHANGELOG.md.new
|
||||||
|
cat tail.md >> CHANGELOG.md.new
|
||||||
|
|
||||||
|
mv CHANGELOG.md.new CHANGELOG.md
|
||||||
|
|
||||||
|
# Remove temporary files.
|
||||||
|
rm -f CHANGELOG.cleaned header.md tail.md CHANGELOG-release.md
|
||||||
|
|
||||||
|
echo "Final CHANGELOG.md content:"
|
||||||
|
cat CHANGELOG.md
|
||||||
|
|
||||||
|
# 4. Create (or update) the Pull Request with the updated CHANGELOG.md.
|
||||||
|
- name: Create Pull Request
|
||||||
|
uses: peter-evans/create-pull-request@v7
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
sign-commits: true
|
||||||
|
commit-message: "chore: update CHANGELOG for release ${GITHUB_REF##*/}"
|
||||||
|
base: main
|
||||||
|
branch: "changelog/${GITHUB_REF##*/}"
|
||||||
|
reviewers: danny-avila
|
||||||
|
title: "chore: update CHANGELOG for release ${GITHUB_REF##*/}"
|
||||||
|
body: |
|
||||||
|
**Description**:
|
||||||
|
- This PR updates the CHANGELOG.md by removing the "Unreleased" section and adding new release notes for release ${GITHUB_REF##*/} above previous releases.
|
106
.github/workflows/generate-unreleased-changelog-pr.yml
vendored
Normal file
106
.github/workflows/generate-unreleased-changelog-pr.yml
vendored
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
name: Generate Unreleased Changelog PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * 1" # Runs every Monday at 00:00 UTC
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
generate-unreleased-changelog-pr:
|
||||||
|
permissions:
|
||||||
|
contents: write # Needed for pushing commits and creating branches.
|
||||||
|
pull-requests: write
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# 1. Checkout the repository on main.
|
||||||
|
- name: Checkout Repository on Main
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: main
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
# 4. Get the latest version tag.
|
||||||
|
- name: Get Latest Tag
|
||||||
|
id: get_latest_tag
|
||||||
|
run: |
|
||||||
|
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "none")
|
||||||
|
echo "Latest tag: $LATEST_TAG"
|
||||||
|
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
# 5. Generate the Unreleased changelog.
|
||||||
|
- name: Generate Unreleased Changelog
|
||||||
|
id: generate_unreleased
|
||||||
|
uses: mikepenz/release-changelog-builder-action@v5.1.0
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
configuration: ".github/configuration-unreleased.json"
|
||||||
|
owner: ${{ github.repository_owner }}
|
||||||
|
repo: ${{ github.event.repository.name }}
|
||||||
|
outputFile: CHANGELOG-unreleased.md
|
||||||
|
fromTag: ${{ steps.get_latest_tag.outputs.tag }}
|
||||||
|
toTag: main
|
||||||
|
|
||||||
|
# 7. Update CHANGELOG.md with the new Unreleased section.
|
||||||
|
- name: Update CHANGELOG.md
|
||||||
|
id: update_changelog
|
||||||
|
run: |
|
||||||
|
# Create CHANGELOG.md if it doesn't exist.
|
||||||
|
if [ ! -f CHANGELOG.md ]; then
|
||||||
|
echo "# Changelog" > CHANGELOG.md
|
||||||
|
echo "" >> CHANGELOG.md
|
||||||
|
echo "All notable changes to this project will be documented in this file." >> CHANGELOG.md
|
||||||
|
echo "" >> CHANGELOG.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Updating CHANGELOG.md…"
|
||||||
|
|
||||||
|
# Extract content before the "## [Unreleased]" (or first version header if missing).
|
||||||
|
if grep -q "^## \[Unreleased\]" CHANGELOG.md; then
|
||||||
|
awk '/^## \[Unreleased\]/{exit} {print}' CHANGELOG.md > CHANGELOG_TMP.md
|
||||||
|
else
|
||||||
|
awk '/^## \[v/{exit} {print}' CHANGELOG.md > CHANGELOG_TMP.md
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Append the generated Unreleased changelog.
|
||||||
|
echo "" >> CHANGELOG_TMP.md
|
||||||
|
cat CHANGELOG-unreleased.md >> CHANGELOG_TMP.md
|
||||||
|
echo "" >> CHANGELOG_TMP.md
|
||||||
|
|
||||||
|
# Append the remainder of the original changelog (starting from the first version header).
|
||||||
|
awk 'f{print} /^## \[v/{f=1; print}' CHANGELOG.md >> CHANGELOG_TMP.md
|
||||||
|
|
||||||
|
# Replace the old file with the updated file.
|
||||||
|
mv CHANGELOG_TMP.md CHANGELOG.md
|
||||||
|
|
||||||
|
# Remove the temporary generated file.
|
||||||
|
rm -f CHANGELOG-unreleased.md
|
||||||
|
|
||||||
|
echo "Final CHANGELOG.md:"
|
||||||
|
cat CHANGELOG.md
|
||||||
|
|
||||||
|
# 8. Check if CHANGELOG.md has any updates.
|
||||||
|
- name: Check for CHANGELOG.md changes
|
||||||
|
id: changelog_changes
|
||||||
|
run: |
|
||||||
|
if git diff --quiet CHANGELOG.md; then
|
||||||
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 9. Create (or update) the Pull Request only if there are changes.
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: steps.changelog_changes.outputs.has_changes == 'true'
|
||||||
|
uses: peter-evans/create-pull-request@v7
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
base: main
|
||||||
|
branch: "changelog/unreleased-update"
|
||||||
|
sign-commits: true
|
||||||
|
commit-message: "action: update Unreleased changelog"
|
||||||
|
title: "action: update Unreleased changelog"
|
||||||
|
body: |
|
||||||
|
**Description**:
|
||||||
|
- This PR updates the Unreleased section in CHANGELOG.md.
|
||||||
|
- It compares the current main branch with the latest version tag (determined as ${{ steps.get_latest_tag.outputs.tag }}),
|
||||||
|
regenerates the Unreleased changelog, removes any old Unreleased block, and inserts the new content.
|
Loading…
Add table
Add a link
Reference in a new issue