Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update changelog-generation and RELEASES.md #13

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/cargo_machete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Cargo Machete

on:
push:
branches:
- "main"
pull_request:
types: [opened, synchronize]

jobs:
cargo-machete:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Machete
uses: bnjbvr/cargo-machete@main
7 changes: 0 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"

[[package]]
name = "log"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"

[[package]]
name = "memchr"
version = "2.7.4"
Expand Down Expand Up @@ -102,7 +96,6 @@ version = "0.1.0"
dependencies = [
"byteorder",
"bytes",
"log",
"num-rational",
"serde",
"serde_json",
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ default = []
[dependencies]
byteorder = "1"
bytes = "1.1.0"
log = "0.4.17"
num-rational = { version = "0.4.0", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
6 changes: 3 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Release Checklist

* [ ] Update `CHANGELOG.md` using `./scripts/generate_changelog.py --commit-range 0.x.y..HEAD`
* [ ] Bump version numbers
* [ ] Update `CHANGELOG.md` using `./scripts/generate_changelog.py --version 0.NEW.VERSION`
* [ ] Bump version numbers in `Cargo.toml` and run `cargo check`.
* [ ] `git commit -m 'Release 0.x.0 - summary'`
* [ ] `cargo publish --quiet -p re_mp4`
* [ ] `git tag -a 0.x.0 -m 'Release 0.x.0 - summary'`
* [ ] `git pull --tags && git tag -d latest && git tag -a latest -m 'Latest release' && git push --tags origin latest --force && git push origin main ; git push --tags ; git push`
* [ ] `git pull --tags && git tag -d latest && git tag -a latest -m 'Latest release' && git push --tags origin latest --force && git push origin main ; git push --tags`
* [ ] Do a GitHub release: https://github.com/rerun-io/re_mp4/releases/new
36 changes: 33 additions & 3 deletions scripts/generate_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
import re
import sys
from dataclasses import dataclass
from datetime import date
from typing import Any, Optional

import requests
from git import Repo # pip install GitPython
from tqdm import tqdm

OWNER = "rerun-io"
REPO = "re_mp4"
REPO = "new_repo_name"
INCLUDE_LABELS = False # It adds quite a bit of visual noise


Expand Down Expand Up @@ -110,13 +111,41 @@ def print_section(crate: str, items: list[str]) -> None:
print()


def commit_range(new_version: str) -> str:
parts = new_version.split(".")
assert len(parts) == 3, "Expected version to be on the format X.Y.Z"
major = int(parts[0])
minor = int(parts[1])
patch = int(parts[2])

if 0 < patch:
# A patch release.
# Include changes since last patch release.
# This assumes we've cherry-picked stuff for this release.
diff_since_version = f"0.{minor}.{patch - 1}"
elif 0 < minor:
# A minor release
# The diff should span everything since the last minor release.
# The script later excludes duplicated automatically, so we don't include stuff that
# was part of intervening patch releases.
diff_since_version = f"{major}.{minor - 1}.0"
else:
# A major release
# The diff should span everything since the last major release.
# The script later excludes duplicated automatically, so we don't include stuff that
# was part of intervening minor/patch releases.
diff_since_version = f"{major - 1}.{minor}.0"

return f"{diff_since_version}..HEAD"


def main() -> None:
parser = argparse.ArgumentParser(description="Generate a changelog.")
parser.add_argument("--commit-range", help="e.g. 0.1.0..HEAD", required=True)
parser.add_argument("--version", required=True, help="The version of the new release, e.g. 0.42.0")
args = parser.parse_args()

repo = Repo(".")
commits = list(repo.iter_commits(args.commit_range))
commits = list(repo.iter_commits(commit_range(args.version)))
commits.reverse() # Most recent last
commit_infos = list(map(get_commit_info, commits))

Expand Down Expand Up @@ -170,6 +199,7 @@ def main() -> None:
line = line[0].upper() + line[1:] # Upper-case first letter
prs[i] = line

print(f"## {args.version} - {date.today()}")
print()
print(f"Full diff at https://github.com/{OWNER}/{REPO}/compare/{args.commit_range}")
print()
Expand Down
2 changes: 2 additions & 0 deletions scripts/template_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

# Files required by Rust, but not by _both_ C++ and Python
RUST_FILES = {
".github/workflows/cargo_machete.yml",
".github/workflows/rust.yml",
"bacon.toml",
"Cargo.lock",
Expand All @@ -67,6 +68,7 @@
"clippy.toml",
"Cranky.toml",
"deny.toml",
"RELEASES.md",
"rust-toolchain",
"scripts/clippy_wasm/",
"scripts/clippy_wasm/clippy.toml",
Expand Down
Loading