From fde6227d4782c8cd124d85b591a40002a2621dca Mon Sep 17 00:00:00 2001 From: Evgeny Kropotin Date: Mon, 1 Sep 2025 17:20:40 -0700 Subject: [PATCH] chore: introduce comprehensive changelog generation system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds automated changelog generation with git-cliff integration across all workflows. Updates version bump workflow to include changelog generation step. Enhances release workflows with proper changelog integration. Introduces generate-changelogs.sh script for automated changelog management. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/crates-version-bump.yml | 50 ++++++++++++++++++----- .github/workflows/release-cli.yml | 9 ++-- .github/workflows/release-core.yml | 8 ++-- .github/workflows/release-server.yml | 27 +++++------- scripts/generate-changelogs.sh | 31 ++++++++++++++ 5 files changed, 88 insertions(+), 37 deletions(-) create mode 100755 scripts/generate-changelogs.sh diff --git a/.github/workflows/crates-version-bump.yml b/.github/workflows/crates-version-bump.yml index f86fdef..a80abb4 100644 --- a/.github/workflows/crates-version-bump.yml +++ b/.github/workflows/crates-version-bump.yml @@ -32,18 +32,22 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable - - name: Cache cargo-workspaces + - name: Cache cargo tools uses: actions/cache@v3 - id: cache-cargo-workspaces + id: cache-cargo-tools with: - path: ~/.cargo/bin/cargo-workspaces - key: cargo-workspaces-${{ runner.os }}-v1 + path: | + ~/.cargo/bin/cargo-workspaces + ~/.cargo/bin/git-cliff + key: cargo-tools-${{ runner.os }}-v1 restore-keys: | - cargo-workspaces-${{ runner.os }}- + cargo-tools-${{ runner.os }}- - - name: Install cargo-workspaces - if: steps.cache-cargo-workspaces.outputs.cache-hit != 'true' - run: cargo install cargo-workspaces + - name: Install cargo tools + if: steps.cache-cargo-tools.outputs.cache-hit != 'true' + run: | + cargo install cargo-workspaces + cargo install git-cliff - name: Setup Git run: | @@ -66,15 +70,41 @@ jobs: FORCE_FLAG="--force '*'" fi + CHANGED_CRATES=$(cargo workspaces changed) + + if [[ -z "$CHANGED_CRATES" ]]; then + echo "No crates changed since last tag. Nothing to do." + exit 0 + fi + case "$BRANCH" in main) - cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG + cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG --no-git-push ;; development) - cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG + cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG --no-git-push ;; *) echo "❌ This workflow can only be run on 'main' or 'development'." exit 1 ;; esac + + NEW_TAGS=$(git tag --points-at HEAD) + echo "Tags created locally:" + echo "$NEW_TAGS" + + ../../scripts/generate-changelogs.sh "$CHANGED_CRATES" + + echo "Amending commit to include changelogs..." + git commit --amend --no-edit + + for tag in $NEW_TAGS; do + echo "Re-applying tag $tag on amended commit..." + git tag -f "$tag" + done + + git push origin "$BRANCH" + git push origin --tags + + echo "✅ Version bump and changelogs pushed successfully!" diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index a2e0a5f..c9e1bdf 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -33,18 +33,17 @@ jobs: run: cargo publish -p quickmark-cli --token ${{ secrets.CRATES_IO_TOKEN }} - name: Generate changelog + id: changelog uses: orhun/git-cliff-action@v4 with: config: cliff.toml - args: --include-path "crates/quickmark-cli/**" --tag-pattern "quickmark-cli@*" - env: - OUTPUT: CHANGELOG.md + args: --include-path "crates/quickmark-cli/**" --tag-pattern "quickmark-cli@*" --latest - name: Create GitHub release uses: softprops/action-gh-release@v2 with: - body_path: CHANGELOG.md + body: ${{ steps.changelog.outputs.content }} draft: false prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-core.yml b/.github/workflows/release-core.yml index e0f20bb..0e52695 100644 --- a/.github/workflows/release-core.yml +++ b/.github/workflows/release-core.yml @@ -36,15 +36,13 @@ jobs: uses: orhun/git-cliff-action@v4 with: config: cliff.toml - args: --include-path "crates/quickmark-core/**" --tag-pattern "quickmark-core@*" - env: - OUTPUT: CHANGELOG.md + args: --include-path "crates/quickmark-core/**" --tag-pattern "quickmark-core@*" --latest - name: Create GitHub release uses: softprops/action-gh-release@v2 with: - body_path: CHANGELOG.md + body: ${{ steps.changelog.outputs.content }} draft: false prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release-server.yml b/.github/workflows/release-server.yml index 512e503..fb4addb 100644 --- a/.github/workflows/release-server.yml +++ b/.github/workflows/release-server.yml @@ -1,4 +1,4 @@ -name: Release QuickMark Server +name: Release QuickMark Server on: push: @@ -64,7 +64,7 @@ jobs: run: | ARCHIVE_NAME="quickmark-server-${{ matrix.target }}.tar.gz" echo "archive_name=$ARCHIVE_NAME" >> $GITHUB_OUTPUT - + # Create archive with the binary renamed to quickmark-server mkdir -p archive-temp cp "target/${{ matrix.target }}/release/quickmark-server${{ matrix.suffix }}" archive-temp/quickmark-server${{ matrix.suffix }} @@ -104,20 +104,6 @@ jobs: - name: Publish quickmark-server to crates.io run: cargo publish -p quickmark-server --token ${{ secrets.CRATES_IO_TOKEN }} - - name: Generate changelog - uses: orhun/git-cliff-action@v4 - with: - config: cliff.toml - args: --include-path "crates/quickmark-server/**" --tag-pattern "quickmark-server@*" - env: - OUTPUT: CHANGELOG.md - - - name: Upload changelog - uses: actions/upload-artifact@v4 - with: - name: changelog - path: CHANGELOG.md - release: name: Create Release needs: [build, publish] @@ -149,11 +135,18 @@ jobs: ls -la release-archives/ if [ -f CHANGELOG.md ]; then ls -la CHANGELOG.md; fi + - name: Generate changelog + id: changelog + uses: orhun/git-cliff-action@v4 + with: + config: cliff.toml + args: --include-path "crates/quickmark-server/**" --tag-pattern "quickmark-server@*" --latest + - name: Create release uses: softprops/action-gh-release@v2 with: files: release-archives/* - body_path: CHANGELOG.md + body: ${{ steps.changelog.outputs.content }} draft: false prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }} env: diff --git a/scripts/generate-changelogs.sh b/scripts/generate-changelogs.sh new file mode 100755 index 0000000..0a08e35 --- /dev/null +++ b/scripts/generate-changelogs.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -eq 0 ]]; then + echo "Usage: $0 [ ...]" + exit 1 +fi + +REPO_ROOT=$(git rev-parse --show-toplevel) +cd "$REPO_ROOT" + +for crate in "$@"; do + echo "Processing crate: $crate" + + # Get crate manifest path from cargo metadata + CRATE_DIR=$(cargo metadata --format-version 1 --no-deps \ + | jq -r --arg NAME "$crate" '.packages[] | select(.name==$NAME) | .manifest_path' \ + | xargs dirname) + + REL_CRATE_DIR=$(realpath --relative-to="$REPO_ROOT" "$CRATE_DIR") + + echo "Generating changelog for $crate in $REL_CRATE_DIR..." + git cliff \ + --tag-pattern "$crate@*" \ + --include-path "$REL_CRATE_DIR/**" \ + --output "$REL_CRATE_DIR/CHANGELOG.md" + + git add "$REL_CRATE_DIR/CHANGELOG.md" +done + +echo "✅ Changelogs staged for crates: $*"