From 77b7b228004b24ab079b3173baabc471d5c98764 Mon Sep 17 00:00:00 2001 From: John Judd Date: Fri, 19 Jun 2026 11:48:11 -0500 Subject: [PATCH] use releasegen validate changlog workflow --- .github/workflows/ensure_changelog.yml | 17 ----- .github/workflows/releasegen.yml | 7 +- .github/workflows/scripts/changelog.sh | 86 ------------------------ .github/workflows/validate-changelog.yml | 34 ++++++++++ .prenup.yaml | 15 ++++- .releasegen.yaml | 21 ++++++ CHANGELOG.md | 2 + 7 files changed, 73 insertions(+), 109 deletions(-) delete mode 100644 .github/workflows/ensure_changelog.yml delete mode 100644 .github/workflows/scripts/changelog.sh create mode 100644 .github/workflows/validate-changelog.yml create mode 100644 .releasegen.yaml diff --git a/.github/workflows/ensure_changelog.yml b/.github/workflows/ensure_changelog.yml deleted file mode 100644 index 6a060155..00000000 --- a/.github/workflows/ensure_changelog.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: CHANGELOG.md Check -on: - pull_request: - branches: - - main - - v6 -jobs: - verify_changelog_job: - runs-on: ubuntu-latest - name: Did CHANGELOG.md change? - steps: - - name: checkout - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: fetch - run: git fetch - - name: run changelog.sh - run: 'bash ${GITHUB_WORKSPACE}/.github/workflows/scripts/changelog.sh' diff --git a/.github/workflows/releasegen.yml b/.github/workflows/releasegen.yml index 00a03498..57318e3c 100644 --- a/.github/workflows/releasegen.yml +++ b/.github/workflows/releasegen.yml @@ -42,6 +42,9 @@ jobs: token: ${{ steps.generate-token.outputs.token }} - name: Run ReleaseGen + # custom_change_types now live in .releasegen.yaml so the validate + # and release workflows share one source of truth. Per-run values + # stay in env below. env: GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} GITHUB_REPOSITORY: ${{ github.repository }} @@ -49,9 +52,6 @@ jobs: GITHUB_REF_NAME: ${{ github.event.inputs.branch || github.ref_name }} MANUAL_VERSION: ${{ github.event.inputs.version || '' }} REASON: ${{ github.event.inputs.reason || '' }} - CUSTOM_CHANGE_TYPES: | - documentation:patch - performance:minor run: | docker run --rm \ -e GITHUB_TOKEN \ @@ -60,7 +60,6 @@ jobs: -e GITHUB_REF_NAME \ -e MANUAL_VERSION \ -e REASON \ - -e CUSTOM_CHANGE_TYPES \ -v "$(pwd):/workspace" \ ghcr.io/c2fo/releasegen:v1 \ --repo-root /workspace diff --git a/.github/workflows/scripts/changelog.sh b/.github/workflows/scripts/changelog.sh deleted file mode 100644 index f9962189..00000000 --- a/.github/workflows/scripts/changelog.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash - -# Find all directories containing a CHANGELOG.md file -changelogDirs=$(find . -type f -name 'CHANGELOG.md' -exec dirname {} \; | sort -u) -changedDirs="" - -# Function to print a separator -print_separator() { - echo "----------------------------------------" -} - -# Check each directory for changes and ensure CHANGELOG.md is updated -for dir in $changelogDirs; do - if [[ "$dir" == "." ]]; then - continue - fi - print_separator - echo "Checking: $dir" - - # Check if there are any changes in the directory - dirChanges=$(git --no-pager diff -w --numstat origin/main -- $dir | wc -l) - if [[ "$dirChanges" -gt 0 ]]; then - echo " - changes detected" - - # Check if CHANGELOG.md has been modified - changelogMod=$(git --no-pager diff -w --numstat origin/main -- $dir/CHANGELOG.md) - if [[ -z "$changelogMod" ]]; then - echo " - $dir/CHANGELOG.md not modified - Please update it with your changes before merging to main." - exit 1 - else - echo " - $dir/CHANGELOG.md modified" - changelogLines=$(echo "$changelogMod" | awk '{print $1}') - if [[ "$changelogLines" -lt 1 ]]; then - echo " - didn't detect any substantial changes to CHANGELOG.md in $dir." - exit 1 - else - echo " - detected '$changelogLines' new non-whitespace lines in CHANGELOG.md in $dir. Thanks +1" - changedDirs+=" $dir" - fi - fi - else - echo " - no changes detected" - fi -done - -print_separator - -# Build exclusion pattern for directories with their own CHANGELOG.md -excludePatterns=(":!*/CHANGELOG.md") # always exclude sub-CHANGELOG.md -for dir in $changedDirs; do - excludePatterns+=(":!$dir/*") -done - -echo "Checking root: ./" -# Check for changes in the root directory and subdirectories without their own CHANGELOG.md -rootChanges=$(git --no-pager diff -w --numstat origin/main -- . "${excludePatterns[@]}" | wc -l) -if [[ "$rootChanges" -gt 0 ]]; then - echo " - changes detected" - - # Check if root CHANGELOG.md exists - if [[ ! -f "./CHANGELOG.md" ]]; then - echo "::warning:: - changes detected but no ./CHANGELOG.md was found" - else - echo " - ./CHANGELOG.md exists" - rootChangelogMod=$(git --no-pager diff -w --numstat origin/main -- ./CHANGELOG.md) - if [[ -z "$rootChangelogMod" ]]; then - echo " - ./CHANGELOG.md not modified - Please update it with your changes before merging to main." - exit 1 - else - echo " - ./CHANGELOG.md modified" - rootChangelogLines=$(echo "$rootChangelogMod" | awk '{print $1}') - if [[ "$rootChangelogLines" -lt 1 ]]; then - echo " - didn't detect any substantial changes to CHANGELOG.md in root CHANGELOG.md." - exit 1 - else - echo " - detected '$rootChangelogLines' new non-whitespace lines in root CHANGELOG.md. Thanks +1" - fi - fi - fi -else - echo " - no changes detected" -fi - -print_separator -echo "All directories with changes have updated CHANGELOG.md files." -exit 0 diff --git a/.github/workflows/validate-changelog.yml b/.github/workflows/validate-changelog.yml new file mode 100644 index 00000000..9d4b969b --- /dev/null +++ b/.github/workflows/validate-changelog.yml @@ -0,0 +1,34 @@ +name: Validate Changelog + +# Lightweight PR-time check that parses every CHANGELOG.md's [Unreleased] +# section and reports malformed headings (e.g. ### Changed without the +# BREAKING CHANGE marker, or an unknown heading not declared in +# .releasegen.yaml's custom_change_types). No token, no commits, no side +# effects. Pairs with the release-by-changelog workflow that runs on merge +# to main / v6. + +on: + pull_request: + branches: + - main + - v6 + +permissions: + contents: read + +jobs: + validate-changelog: + name: Validate CHANGELOG.md + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + fetch-depth: 0 + + - name: Run releasegen validate + run: | + docker run --rm \ + -v "$(pwd):/workspace" \ + ghcr.io/c2fo/releasegen:v1 \ + validate --repo-root /workspace diff --git a/.prenup.yaml b/.prenup.yaml index 9a2d6f3b..9343ef73 100644 --- a/.prenup.yaml +++ b/.prenup.yaml @@ -18,6 +18,17 @@ tasks: command: golangci-lint run --max-same-issues 0 --build-tags=vfsintegration ./... per_module: true working_dir: '{{.module_root}}' - - name: Check for changes in CHANGELOG.md + - name: Validate CHANGELOG.md default_selected: true - command: /bin/bash {{.repo_root}}/.github/workflows/scripts/changelog.sh + # Runs the same image and subcommand the validate workflow uses in CI, + # reading custom_change_types from .releasegen.yaml. Replaces the + # legacy changelog.sh "did the changelog change?" guard. + # + # --pull=always forces Docker to check GHCR for the current digest of + # the `v1` moving tag before each run, so we stay automatically in + # sync with the latest v1.x release that CI uses. Without this flag + # Docker uses its default --pull=missing behavior and will keep + # running whatever was first cached locally, even after newer v1.x + # images ship. Cost is one HTTP HEAD per invocation; layers stay + # cached so re-downloads only happen on a real version bump. + command: docker run --rm --pull=always -v "{{.repo_root}}:/workspace" ghcr.io/c2fo/releasegen:v1 validate --repo-root /workspace diff --git a/.releasegen.yaml b/.releasegen.yaml new file mode 100644 index 00000000..a27b8173 --- /dev/null +++ b/.releasegen.yaml @@ -0,0 +1,21 @@ +# ReleaseGen configuration shared by the release and validate workflows. +# Per-invocation values (GITHUB_TOKEN, MANUAL_VERSION, etc.) stay in the +# workflow env / CLI flags; repo-shape settings live here. +# +# Keep keys in lower-case; releasegen matches headings case-insensitively +# but the canonical on-disk form is lower-cased. + +custom_change_types: + documentation: patch + performance: minor + +validate: + # Fail any PR whose non-CHANGELOG files changed vs the base ref but whose + # [Unreleased] section gained no new lines. Modules are scoped by where + # CHANGELOG.md lives; the root changelog catches everything not claimed + # by a submodule changelog. Replaces the legacy ensure_changelog.sh + # presence check and folds it into the same batched validate report. + require_changelog_entry: true + # base_ref defaults to origin/$GITHUB_BASE_REF on PR runs, else origin/main. + # Override here if you need to validate against a different revision. + # base_ref: origin/main diff --git a/CHANGELOG.md b/CHANGELOG.md index e29cf15c..e2ed6258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Added `releasegen validate` changelog workflow as pr check ## [[v7.19.0](https://github.com/C2FO/vfs/releases/tag/v7.19.0)] - 2026-06-18 ### Added