diff --git a/.github/stale.yml b/.github/stale.yml deleted file mode 100644 index 0d0b1c9..0000000 --- a/.github/stale.yml +++ /dev/null @@ -1 +0,0 @@ -_extends: .github diff --git a/.github/workflows/binary-builds.yml b/.github/workflows/binary-builds.yml index 6076ae4..053c2c8 100644 --- a/.github/workflows/binary-builds.yml +++ b/.github/workflows/binary-builds.yml @@ -6,10 +6,20 @@ permissions: on: push: branches: [main] + paths: + - cpp-linter/src/** + - cpp-linter/Cargo.toml + - Cargo.toml + - Cargo.lock tags: - - v[0-9]+.* + - v* pull_request: branches: [main] + paths: + - cpp-linter/src/** + - cpp-linter/Cargo.toml + - Cargo.toml + - Cargo.lock env: CARGO_TERM_COLOR: always @@ -124,7 +134,7 @@ jobs: path: cpp-linter-${{ matrix.target }}* if-no-files-found: error - create-release: + publish: if: startswith(github.ref, 'refs/tags') runs-on: ubuntu-latest needs: [create-assets] @@ -136,6 +146,9 @@ jobs: persist-credentials: false - name: Install Rust run: rustup update stable --no-self-update + - uses: actions/setup-python@v5 + with: + python-version: 3.x - name: Download built assets uses: actions/download-artifact@v4 with: @@ -147,7 +160,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | files=$(ls dist/cpp-linter*) - gh release create ${{ github.ref_name }} ${{ contains(github.ref_name, 'rc') && '--prerelease' || '' }} --generate-notes $files + gh release upload "${{ github.ref_name }}" $files - run: cargo publish -p cpp-linter env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 010d0b4..75f7f0e 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -1,6 +1,23 @@ name: Docs -on: [push, workflow_dispatch] +on: + push: + branches: [main] + paths: + - docs/** + - .github/workflows/build-docs.yml + - cpp-linter/src/** + - '*.md' + - '*/*.md' + pull_request: + branches: [main] + paths: + - docs/** + - .github/workflows/build-docs.yml + - cpp-linter/src/** + - '*.md' + - '*/*.md' + workflow_dispatch: env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/bump-n-release.yml b/.github/workflows/bump-n-release.yml new file mode 100644 index 0000000..12c5fd0 --- /dev/null +++ b/.github/workflows/bump-n-release.yml @@ -0,0 +1,63 @@ +name: Bump-n-Release + +# NOTE: The change log is only updated in the remote upon release (in `bump-release` job) + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + workflow_dispatch: + inputs: + component: + type: choice + required: true + default: patch + options: + - major + - minor + - patch + - rc + +jobs: + bump-release: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.BUMP_N_RELEASE }} + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + - uses: cargo-bins/cargo-binstall@main + - run: cargo binstall -y git-cliff + - name: Bump ${{ inputs.component }} verion + env: + GITHUB_TOKEN: ${{ secrets.BUMP_N_RELEASE }} + GH_TOKEN: ${{ secrets.BUMP_N_RELEASE }} + run: python .github/workflows/bump_version.py ${{ inputs.component }} + id: tagged + + update-changelog: + if: github.event_name != 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.BUMP_N_RELEASE }} + fetch-depth: 0 + - name: Generate a changelog + uses: orhun/git-cliff-action@v4 + id: git-cliff + with: + config: cliff.toml + args: --unreleased + env: + OUTPUT: ${{ runner.temp }}/changes.md + GITHUB_REPO: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.BUMP_N_RELEASE }} + - run: cat "${{ runner.temp }}/changes.md" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/bump_version.py b/.github/workflows/bump_version.py index a80b192..5d937d9 100644 --- a/.github/workflows/bump_version.py +++ b/.github/workflows/bump_version.py @@ -1,3 +1,38 @@ +"""This script automates the release process for all of the packages in this repository. +In order, this script does the following: + +1. Bump version number in manifest files according to given required arg (see `--help`). + This alters the Cargo.toml in repo root and the package.json files in node-binding. + + Requires `yarn` (see https://yarnpkg.com) and `napi` (see https://napi.rs) to be + installed to bump node-binding versions. + +2. Updates the CHANGELOG.md + + Requires `git-cliff` (see https://git-cliff.org) to be installed + to regenerate the change logs from git history. + + NOTE: `git cliff` uses GITHUB_TOKEN env var to access GitHub's REST API for + fetching certain data (like PR labels and commit author's username). + +3. Pushes the changes from above 2 steps to remote + +4. Creates a GitHub Release and uses the section from the CHANGELOG about the new tag + as a release description. + + Requires `gh-cli` (see https://cli.github.com) to be installed to create the release + and push the tag. + + NOTE: This step also tags the commit from step 3. + When a tag is pushed to the remote, the CI builds are triggered and + + - release assets are uploaded to the Github Release corresponding to the new tag + - packages are published for npm, pip, and cargo + + NOTE: In a CI run, the GH_TOKEN env var to authenticate access. + Locally, you can use `gh login` to interactively authenticate the user account. +""" + import argparse from pathlib import Path import subprocess @@ -8,6 +43,7 @@ ) VER_REPLACE = 'version = "%d.%d.%d%s" # auto' COMPONENTS = ("major", "minor", "patch", "rc") +VERSION_LOG = re.compile(r"^## \[\d+\.\d+\.\d+(?:\-rc)?\d*\]") class Updater: @@ -40,10 +76,34 @@ def replace(match: re.Match[str]) -> str: return VER_REPLACE % (tuple(ver[:3]) + (rc_str,)) +def get_release_notes(tag: str = Updater.new_version): + title, buf = "", "" + log_file = Path(__file__).parent.parent.parent / "CHANGELOG.md" + tag_pattern = f"[{tag}]" + with open(str(log_file), "r", encoding="utf-8") as logs: + found_notes = False + for line in logs: + matched = VERSION_LOG.match(line) + if matched is not None: + if tag_pattern in matched.group(0): + title = tag + line[matched.end() :] + found_notes = True + else: + found_notes = False + elif line.startswith("[unreleased]: ") and found_notes: + found_notes = False + elif found_notes: + buf += line + elif line.startswith(tag_pattern + ": "): + buf += line.replace(tag_pattern, "Full commit diff", 1) + return title.rstrip(), buf.strip() + + def main(): parser = argparse.ArgumentParser() parser.add_argument("component", default="patch", choices=COMPONENTS) parser.parse_args(namespace=Updater) + cargo_path = Path("Cargo.toml") doc = cargo_path.read_text(encoding="utf-8") doc = VER_PATTERN.sub(Updater.replace, doc) @@ -63,20 +123,31 @@ def main(): ) subprocess.run(["napi", "version"], cwd="node-binding", check=True) print("Updated version in node-binding/**package.json") - tag = "v" + Updater.new_version + + subprocess.run(["git", "cliff", "--tag", Updater.new_version], check=True) + print("Updated CHANGELOG.md") + subprocess.run(["git", "add", "--all"], check=True) - subprocess.run(["git", "commit", "-m", f"bump version to {tag}"], check=True) + tag = "v" + Updater.new_version + subprocess.run(["git", "commit", "-m", f"Bump version to {tag}"], check=True) try: subprocess.run(["git", "push"], check=True) except subprocess.CalledProcessError as exc: - raise RuntimeError("Failed to push commit for version bump") from exc - print("Pushed commit to 'bump version to", tag, "'") + raise RuntimeError( + """Failed to push commit for version bump. Please ensure that +- You have the necessary permissions and are authenticated properly. +- All other commits on the branch have ben pushed already.""" + ) from exc + title, notes = get_release_notes() + print("Pushed commit to 'Bump version to", tag, "'") + gh_cmd = ["gh", "release", "create", tag, "--title", title, "--notes", notes] + if Updater.component == "rc": + gh_cmd.append("--prerelease") try: - subprocess.run(["git", "tag", tag], check=True) + subprocess.run(gh_cmd, check=True) + print("Created tag", tag, "and corresponding GitHub Release") except subprocess.CalledProcessError as exc: - raise RuntimeError("Failed to create tag for commit") from exc - print("Created tag", tag) - print(f"Use 'git push origin refs/tags/{tag}' to publish a release") + raise RuntimeError("Failed to create GitHub Release") from exc if __name__ == "__main__": diff --git a/.github/workflows/node-js-packaging.yml b/.github/workflows/node-js-packaging.yml index ef920d8..349f5d3 100644 --- a/.github/workflows/node-js-packaging.yml +++ b/.github/workflows/node-js-packaging.yml @@ -8,19 +8,30 @@ permissions: id-token: write on: push: - branches: - - main + branches: [main] + paths: + - cpp-linter/src/** + - cpp-linter/Cargo.toml + - Cargo.toml + - Cargo.lock + - node-binding/** + - package.json + - yarn.lock + - .github/workflows/node-js-packaging.yml tags: - '*' - paths-ignore: - - '**/*.md' - - LICENSE - - '**/*.gitignore' - - .editorconfig - - docs/** pull_request: - branches: - - main + branches: [main] + paths: + - cpp-linter/src/** + - cpp-linter/Cargo.toml + - Cargo.toml + - Cargo.lock + - node-binding/** + - package.json + - yarn.lock + - .github/workflows/node-js-packaging.yml + jobs: build: strategy: @@ -218,3 +229,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + # - name: Upload release assets + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # run: + # files=$(ls ./npm/**cpp-linter.*.node) + # gh release upload "${{ github.ref_name }}" $files diff --git a/.github/workflows/python-packaging.yml b/.github/workflows/python-packaging.yml index 320a41c..7a501d0 100644 --- a/.github/workflows/python-packaging.yml +++ b/.github/workflows/python-packaging.yml @@ -14,14 +14,21 @@ name: Python builds on: push: - branches: - - main + branches: [main] + paths: + - cpp-linter/**.{rs,toml} + - py-binding/** + - Cargo.{toml,lock} + - .github/workflows/python-packaging.yml tags: - '*' pull_request: - branches: - - main - workflow_dispatch: + branches: [main] + paths: + - cpp-linter/**.{rs,toml} + - py-binding/** + - Cargo.{toml,lock} + - .github/workflows/python-packaging.yml permissions: contents: read @@ -180,3 +187,9 @@ jobs: # This workflow is registered as a trusted publisher (for test-pypi and pypi). # A token should not be required (and actually is discouraged with trusted publishers). repository-url: ${{ contains(github.ref_name, 'rc') && 'https://test.pypi.org/legacy/' || 'https://upload.pypi.org/legacy/' }} + # - name: Upload release assets + # env: + # GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # run: + # files=$(ls ./dist/cpp-linter*.{whl,atr.gz}) + # gh release upload "${{ github.ref_name }}" $files diff --git a/.github/workflows/run-dev-tests.yml b/.github/workflows/run-dev-tests.yml index dbb794f..9a0e5ca 100644 --- a/.github/workflows/run-dev-tests.yml +++ b/.github/workflows/run-dev-tests.yml @@ -4,18 +4,17 @@ on: push: branches: [main] paths: - - "**.rs" - - "*.toml" - - "Cargo.lock" - - ".github/workflows/run-dev-tests.yml" + - cpp-linter/** + - Cargo.toml + - Cargo.lock + - .github/workflows/run-dev-tests.yml pull_request: - # types: opened branches: [main] paths: - - "**.rs" - - "*.toml" - - "Cargo.lock" - - ".github/workflows/run-dev-tests.yml" + - cpp-linter/** + - Cargo.toml + - Cargo.lock + - .github/workflows/run-dev-tests.yml env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..952263f --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,10 @@ +name: 'Close stale issues' +on: + schedule: + - cron: '30 1 * * *' +permissions: + issues: write + +jobs: + stale: + uses: cpp-linter/.github/.github/workflows/stale.yml@main diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d5791bf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,123 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [Unreleased] + +### 🚀 Added + +- Add a change log in [`9bfab31`](https://github.com/cpp-linter/cpp_linter_rs/commit/9bfab318394814d2515f3959f744d60a12d415f1) + +### 🛠️ Fixed + +- Fix typo in node-binding/README by @2bndy5 in [`7732676`](https://github.com/cpp-linter/cpp_linter_rs/commit/7732676e03941a37a4fb5b474d319c640689985a) + +### 📝 Documentation + +- Release trial follow up by @2bndy5 in [#41](https://github.com/cpp-linter/cpp_linter_rs/pull/41) + +### 🗨️ Changed + +- Gimme them badges by @2bndy5 in [`c0f1ea5`](https://github.com/cpp-linter/cpp_linter_rs/commit/c0f1ea516ee6efdf1137884cbc2e99e4ce1d4a11) + +## [2.0.0-rc4] - 2024-09-21 + +### 🛠️ Fixed + +- Fix metadata in platform-specific node pkgs by @2bndy5 in [`1dbb1de`](https://github.com/cpp-linter/cpp_linter_rs/commit/1dbb1de3abdb231646a33ac2721e6a8778ca4ece) + +### 🗨️ Changed + +- Bump version to v2.0.0-rc4 by @2bndy5 in [`3e98e20`](https://github.com/cpp-linter/cpp_linter_rs/commit/3e98e20d2405b909b038ff87911dc0d5457613cc) + +## [2.0.0-rc3] - 2024-09-21 + +### 🗨️ Changed + +- [node] add life cycle script prepublishOnly by @2bndy5 in [`55650ea`](https://github.com/cpp-linter/cpp_linter_rs/commit/55650ea96aac628023acb120525d674bcf17a529) +- Bump version to v2.0.0-rc3 by @2bndy5 in [`070c5f7`](https://github.com/cpp-linter/cpp_linter_rs/commit/070c5f75f15d0190ee0204992165673c8f16c47d) + +## [2.0.0-rc2] - 2024-09-21 + +### 🚀 Added + +- Use napi-rs by @2bndy5 in [#39](https://github.com/cpp-linter/cpp_linter_rs/pull/39) +- Add `napi version` cmd to `just bump` script by @2bndy5 in [`a6a8bf2`](https://github.com/cpp-linter/cpp_linter_rs/commit/a6a8bf2f8f02c8d1a7b4047dae7bb13b537c370a) + +### 📦 Dependency updates + +- Bump pypa/gh-action-pypi-publish in the actions group by @dependabot[bot] in [#40](https://github.com/cpp-linter/cpp_linter_rs/pull/40) + +### 🗨️ Changed + +- Update READMEs by @2bndy5 in [`3e9c128`](https://github.com/cpp-linter/cpp_linter_rs/commit/3e9c12846c0eb96f8cdd68fc7435bd8965e7ce6a) +- Some cleanup from release trials by @2bndy5 in [`25c3951`](https://github.com/cpp-linter/cpp_linter_rs/commit/25c3951b0ecef9e078ea71932c9401ad8abc2a28) +- Bump version to v2.0.0-rc2 by @2bndy5 in [`ebcb6c4`](https://github.com/cpp-linter/cpp_linter_rs/commit/ebcb6c4941fbaa8147c768252d6d7d9adcfa3bb3) + +## [2.0.0-rc1] - 2024-09-19 + +### 🚀 Added + +- Add more testing and various improvements by @2bndy5 in [#4](https://github.com/cpp-linter/cpp_linter_rs/pull/4) +- Support file paths in CLI positional argument by @2bndy5 in [#16](https://github.com/cpp-linter/cpp_linter_rs/pull/16) +- Support glob patterns by @2bndy5 in [#25](https://github.com/cpp-linter/cpp_linter_rs/pull/25) +- Resort to paginated requests for changed files by @2bndy5 in [#37](https://github.com/cpp-linter/cpp_linter_rs/pull/37) + +### 🛠️ Fixed + +- Fix parsing of `--extra-arg` by @2bndy5 in [`03f3de5`](https://github.com/cpp-linter/cpp_linter_rs/commit/03f3de5232e29446d57de00d8ac6deb2fc17d9a5) +- Fix CI docs workflow by @2bndy5 in [`ae33a6d`](https://github.com/cpp-linter/cpp_linter_rs/commit/ae33a6d81da82d8f6c1b2b438e748dd276e4f61f) +- Fix GithubApiClient init for non-PR events by @2bndy5 in [`5b60ab8`](https://github.com/cpp-linter/cpp_linter_rs/commit/5b60ab8af020f81fc986cdf86568263b5e5f8e50) +- Fix typo in README by @2bndy5 in [`afa1312`](https://github.com/cpp-linter/cpp_linter_rs/commit/afa1312af05f3920e9750dd1371fcad09643bc3f) +- Fix dependabot config by @2bndy5 in [`3957be2`](https://github.com/cpp-linter/cpp_linter_rs/commit/3957be228662faa3ab0c7241a88ac3b9d3bd09f8) +- Fix links to clang-analyzer diagnostic's help site by @2bndy5 in [#36](https://github.com/cpp-linter/cpp_linter_rs/pull/36) +- Fix CI workflows for publishing releases by @2bndy5 in [`4f9b912`](https://github.com/cpp-linter/cpp_linter_rs/commit/4f9b91234bf05fd14afc60d7c87768d7ca0d7bb0) +- Fix release CI by @2bndy5 in [`49b3487`](https://github.com/cpp-linter/cpp_linter_rs/commit/49b3487c6d0804c075c7e8863be921c8ba3fdaea) +- Fix release CI steps by @2bndy5 in [`23efee5`](https://github.com/cpp-linter/cpp_linter_rs/commit/23efee50413ae6b6d1b51d147dcdc832d213de94) +- Fix metadata and switch to pypa-publish action by @2bndy5 in [`092e0c2`](https://github.com/cpp-linter/cpp_linter_rs/commit/092e0c20cf66747b59bab4bdf60be29f7f02dcc6) + +### 📦 Dependency updates + +- Bump openssl from 0.10.62 to 0.10.66 by @dependabot[bot] in [#6](https://github.com/cpp-linter/cpp_linter_rs/pull/6) +- Bump the cargo group with 5 updates by @dependabot[bot] in [#7](https://github.com/cpp-linter/cpp_linter_rs/pull/7) +- Bump the cargo group with 3 updates by @dependabot[bot] in [#15](https://github.com/cpp-linter/cpp_linter_rs/pull/15) +- Bump serde_json from 1.0.125 to 1.0.127 in the cargo group by @dependabot[bot] in [#19](https://github.com/cpp-linter/cpp_linter_rs/pull/19) +- Bump serde from 1.0.208 to 1.0.209 in the cargo group by @dependabot[bot] in [#23](https://github.com/cpp-linter/cpp_linter_rs/pull/23) +- Bump tempfile from 3.9.0 to 3.12.0 in the cargo group by @dependabot[bot] in [#26](https://github.com/cpp-linter/cpp_linter_rs/pull/26) +- Bump the cargo group across 1 directory with 6 updates by @dependabot[bot] in [#34](https://github.com/cpp-linter/cpp_linter_rs/pull/34) + +### 🚦 Tests + +- Refactor line filters; minor metadata updates by @2bndy5 in [`19d5517`](https://github.com/cpp-linter/cpp_linter_rs/commit/19d5517dc1c95c8269c0beb583387df6197b1ec7) +- Mock REST API calls in tests by @2bndy5 in [#21](https://github.com/cpp-linter/cpp_linter_rs/pull/21) +- PR review suggestions by @2bndy5 in [`bd049d0`](https://github.com/cpp-linter/cpp_linter_rs/commit/bd049d06c48b4dc40da958a478873ac30183ee46) + +### 📝 Documentation + +- Switch to mdbook for docs by @2bndy5 in [#13](https://github.com/cpp-linter/cpp_linter_rs/pull/13) +- Begin documenting permissions by @2bndy5 in [#22](https://github.com/cpp-linter/cpp_linter_rs/pull/22) + +### 🗨️ Changed + +- Init commit by @2bndy5 in [`2e25fec`](https://github.com/cpp-linter/cpp_linter_rs/commit/2e25fec0a447df24d0bcc1b80f6624040bab755e) +- Use separate crates for different entry points by @2bndy5 in [#2](https://github.com/cpp-linter/cpp_linter_rs/pull/2) +- Update README.md by @2bndy5 in [`ff4a735`](https://github.com/cpp-linter/cpp_linter_rs/commit/ff4a735ec5a74cc9a2e835e58dc76696233ad688) +- Some updates from py codebase by @2bndy5 in [#5](https://github.com/cpp-linter/cpp_linter_rs/pull/5) +- Rename test CI; add badges to README by @2bndy5 in [`b77058f`](https://github.com/cpp-linter/cpp_linter_rs/commit/b77058f166f1062abe8193ab6fc4bc671793a7c8) +- Use task runner `just` (or VSCode "tasks") by @2bndy5 in [#14](https://github.com/cpp-linter/cpp_linter_rs/pull/14) +- Update README by @2bndy5 in [`215485c`](https://github.com/cpp-linter/cpp_linter_rs/commit/215485c3f5032b7253e2d13f6726e3bfe70a16d0) +- Prepare for v2.0.0-rc1 by @2bndy5 in [`9189e86`](https://github.com/cpp-linter/cpp_linter_rs/commit/9189e86da499606439f6b65b62df5603f57d9da7) +- Refactor files by @2bndy5 in [#38](https://github.com/cpp-linter/cpp_linter_rs/pull/38) +- Metadata changes by @2bndy5 in [`f4237ae`](https://github.com/cpp-linter/cpp_linter_rs/commit/f4237ae593e468eca0e63169c9360e97bd6e1f26) + +[unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD +[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4 +[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3 +[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2 +[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1 + + diff --git a/cliff.toml b/cliff.toml new file mode 100644 index 0000000..85eb084 --- /dev/null +++ b/cliff.toml @@ -0,0 +1,141 @@ +# git-cliff ~ configuration file +# https://git-cliff.org/docs/configuration + +[changelog] +# template for the changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{%- macro remote_url() -%} + https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} +{%- endmacro -%} + +{% if version -%} + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {%- if message %} + + > {{ message }} + {%- endif %} +{% else -%} + ## [Unreleased] +{% endif -%} + +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits %} + - {{ commit.message | split(pat="\n") | first | upper_first | trim }}\ + {% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%} + {% if commit.remote.pr_number %} in \ + [#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) + {%- else %} in \ + [`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }}) + {%- endif -%} + {% endfor %} +{% endfor %} + +{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} + ## New Contributors +{%- endif -%} + +{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} + * @{{ contributor.username }} made their first contribution + {%- if contributor.pr_number %} in \ + [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \ + {%- endif %} +{%- endfor %}\n +""" +# template for the changelog footer +footer = """ +{%- macro remote_url() -%} + https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} +{%- endmacro -%} + +{% for release in releases -%} + {% if release.version -%} + {% if release.previous.version -%} + [{{ release.version | trim_start_matches(pat="v") }}]: \ + {{ self::remote_url() }}/compare/{{ release.previous.version }}...{{ release.version }} + {% endif -%} + {% else -%} + [unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}...HEAD + {% endif -%} +{% endfor -%} +[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1 + + +""" +# remove the leading and trailing whitespace from the templates +trim = true +# The file path for output. This can be overridden with `--output` CLI arg +output = "CHANGELOG.md" + +[git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +# filter out the commits that are not conventional +filter_unconventional = false +# regex for preprocessing the commit messages +commit_preprocessors = [ + # remove issue numbers from commits + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }, +] +# regex for parsing and grouping commits +commit_parsers = [ + { field = "github.pr_labels", pattern = "breaking", group = " 💥 Breaking changes" }, + { field = "github.pr_labels", pattern = "breaking-change", group = " 💥 Breaking changes" }, + { field = "github.pr_labels", pattern = "feature", group = " 🚀 Added" }, + { field = "github.pr_labels", pattern = "enhancement", group = " 🚀 Added" }, + { field = "github.pr_labels", pattern = "deprecated", group = " 🚫 Deprecated" }, + { field = "github.pr_labels", pattern = "removed", group = " 🗑️ Removed" }, + { field = "github.pr_labels", pattern = "bug", group = " 🛠️ Fixed" }, + { field = "github.pr_labels", pattern = "security", group = " 🔐 Security" }, + { field = "github.pr_labels", pattern = "dependencies", group = " 📦 Dependency updates" }, + { field = "github.pr_labels", pattern = "test", group = "🚦 Tests"}, + { field = "github.pr_labels", pattern = "tests", group = "🚦 Tests"}, + { field = "github.pr_labels", pattern = "documentation", group = " 📝 Documentation" }, + { field = "github.pr_labels", pattern = "refactor", group = " 🗨️ Changed" }, + { field = "github.pr_labels", pattern = "skip-changelog", skip = true }, + { field = "github.pr_labels", pattern = "no-changelog", skip = true }, + { field = "github.pr_labels", pattern = "invalid", skip = true }, + # The order of parsers matters. Put rules for PR labels first to prioritize PR labels. + { message = "^[a|A]dd", group = " 🚀 Added" }, + { message = "^[s|S]upport", group = " 🚀 Added" }, + { message = "^.*: support", group = " 🚀 Added" }, + { message = "^.*: add", group = " 🚀 Added" }, + { message = "^.*: deprecated", group = " 🚫 Deprecated" }, + { message = "[d|D]eprecate", group = " 🚫 Deprecated" }, + { message = "[t|T]ests", group = "🚦 Tests"}, + { message = "[r|R]emove", group = " 🗑️ Removed" }, + { message = "^.*: remove", group = " 🗑️ Removed" }, + { message = "^.*: delete", group = " 🗑️ Removed" }, + { message = "^[f|F]ix", group = " 🛠️ Fixed" }, + { message = "^.*: fix", group = " 🛠️ Fixed" }, + { message = "^.*: secure", group = " 🔐 Security" }, + { message = "[s|S]ecure", group = " 🔐 Security" }, + { message = "[s|S]ecurity", group = " 🔐 Security" }, + { message = "^.*: security", group = " 🔐 Security" }, + { message = "doc", group = " 📝 Documentation" }, + { message = "docs", group = " 📝 Documentation" }, + { message = "documentation", group = " 📝 Documentation" }, + { message = "[r|R]efactor", group = " 🗨️ Changed" }, + { field = "github.pr_labels", pattern = ".*", group = " 🗨️ Changed" }, + { message = "^.*", group = " 🗨️ Changed" }, +] +# filter out the commits that are not matched by commit parsers +filter_commits = true +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" + +# [remote.github] +# owner = "cpp-linter" +# repo = "cpp_linter_rs" diff --git a/cspell.config.yml b/cspell.config.yml index d24f7e6..d5a1fc0 100644 --- a/cspell.config.yml +++ b/cspell.config.yml @@ -2,6 +2,7 @@ version: "0.2" language: en words: - binstall + - bndy - Boolish - bugprone - chrono @@ -10,7 +11,10 @@ words: - cppcoreguidelines - cstdio - Doherty + - endfor - endgroup + - endmacro + - endwith - Falsey - gitmodules - iomanip @@ -22,16 +26,19 @@ words: - napi - nonminimal - peekable + - pkgs - posix - preprocess - pybind - pyfunction - pymodule + - pypa - pypi - pyproject - ratelimit - reqwest - revparse + - serde - tempdir - tempfile - vararg diff --git a/docs/src/CHANGELOG.md b/docs/src/CHANGELOG.md new file mode 100644 index 0000000..ce53563 --- /dev/null +++ b/docs/src/CHANGELOG.md @@ -0,0 +1,3 @@ + + +{{#include ../../CHANGELOG.md}} diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index b617df9..c240a27 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -8,3 +8,4 @@ - [Pull Request Review Caveats](./pr-review-caveats.md) - [Python Binding](./python.md) - [Node.js Binding](./node.md) +- [Change Log](./CHANGELOG.md) diff --git a/docs/theme/pagetoc.js b/docs/theme/pagetoc.js index d5fefc5..a9d7a91 100644 --- a/docs/theme/pagetoc.js +++ b/docs/theme/pagetoc.js @@ -59,14 +59,33 @@ const updateFunction = () => { if (activeLink) activeLink.classList.add("active"); } }; +function getHeaderText(header) { + let text = header.textContent; + if (text === "") { + let sibling = header.nextSibling; + let maxIterations = 100; + while (sibling != null && maxIterations > 0) { + text += sibling.textContent; + sibling = sibling.nextSibling; + maxIterations--; + } + if (maxIterations === 0) { + console.warn( + "Possible circular reference in DOM when extracting header text" + ); + } + } + return text; +} const onLoad = () => { const pagetoc = getPagetoc(); var headers = [...document.getElementsByClassName("header")]; headers.shift(); headers.forEach((header) => { + const text = getHeaderText(header); const link = Object.assign(document.createElement("a"), { - textContent: header.text, + textContent: text, href: header.href, className: `pagetoc-${header.parentElement.tagName}`, });