diff --git a/CHANGELOG.md b/CHANGELOG.md index f63d3d4c65a0..fc96235c2cde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,71 +1,5 @@ # Changelog - - - - -## Next Version - -VS Code v0.00.0 - -### New Features - -- item - -### Bug Fixes - -- Fix logout when using a base path (#3608) - -### Documentation - -- docs: add Pomerium #3424 @desimone -- docs: fix confusing sentence in pull requests section #3460 @shiv-tyagi -- docs: remove toc from changelog @oxy @jsjoeio -- docs(MAINTAINING): add information about CHANGELOG #3467 @jsjoeio -- docs: move release process to MAINTAINING.md #3441 @oxy @Prashant168 -- docs: format 'Caddy' from guide.md @PisecesPeng - -### Development - -- chore: cross-compile docker images with buildx #3166 @oxy -- chore: update node to v14 #3458 @oxy -- chore: update .gitignore #3557 @cuining -- fix: use sufficient computational effort for password hash #3422 @jsjoeio -- docs(CONTRIBUTING): add section on testing #3629 @jsjoeio - -### Development - -- fix(publish): update cdrci fork in brew-bump.sh #3468 @jsjoeio - ## 3.10.2 VS Code v1.56.1 diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index e0017bfe71b2..4d8c6688f6ea 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -15,6 +15,7 @@ - [End-to-End Tests](#end-to-end-tests) - [Structure](#structure) - [Modifications to VS Code](#modifications-to-vs-code) + - [Prepare CHANGELOG.md for releases.](#prepare-changelogmd-for-releases) - [Currently Known Issues](#currently-known-issues) @@ -196,6 +197,21 @@ work as expected. If the functionality you're working on does NOT depend on code from VS Code, please move it out and into code-server. +### Prepare CHANGELOG.md for releases. + +prepare_changelog.py does: + +- extract merged PR´s from last release +- Prepare CHANGELOG.md (needs manual editing to group the PRs) + +the script depend on `gh` which must be installed. + +example + +``` +./prepare_changelog.py 3.10.3 1.56.1 3393 +``` + ### Currently Known Issues - Creating custom VS Code extensions and debugging them doesn't work diff --git a/docs/MAINTAINING.md b/docs/MAINTAINING.md index c56e5b334c94..af01d3f83660 100644 --- a/docs/MAINTAINING.md +++ b/docs/MAINTAINING.md @@ -83,11 +83,7 @@ The code-server project follows traditional [semantic versioning](ttps://semver. ### Changelog -To save time when creating a new release for code-server, we keep a running changelog at `CHANGELOG.md`. - -If either author or reviewer of a PR believe the change should be mentioned in the `CHANGELOG`, then it should be added. - -If there is not a "Next Version" when you modify `CHANGELOG`, please add it using the template you see near the top of `CHANGELOG`. You can use the suggested format: ` Example: `fix: Check the logged user instead of $USER #3330 @videlanicolas` +To save time when creating a new release for code-server, we have a script that generates `CHANGELOG.md`. ## Release diff --git a/prepare_changelog.py b/prepare_changelog.py new file mode 100755 index 000000000000..31b4f6b34230 --- /dev/null +++ b/prepare_changelog.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Prepare CHANGELOG.md for a new release.""" +import os +import sys +import subprocess +import json + +AUTHOR="author" +TITLE="title" +PR="number" +FEATURE="feature" +FIX="fix" +DOCS="docs" +DEVELOPMENT="development" + + +def gather_pr_list(repo="cdr/code-server", count=500): + """Use 'gh' to retrieve all new merged PR""" + + cmd = [ + "gh", "pr", "list", + "--state", "merged", + "--repo", repo, + "-L", str(count), + "--json", "author,number,title" + ] + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) + pr_dict = json.load(proc.stdout) + for entry in pr_dict: + entry[AUTHOR] = entry[AUTHOR]['login'] + entry[PR] = int(entry[PR]) + return pr_dict + + +def generate_lines(pr_dict, last=0): + """Format PR entries as text lines, ready to go into CHANGELOG.md""" + + def get_type(source) -> bool: + """Intelligent compare""" + + for x in [FEATURE, FIX, DOCS]: + source_prefix = source[:len(x)].casefold() + if source_prefix == x: + return x + return DEVELOPMENT + + result = { + FEATURE: [], + FIX: [], + DOCS: [], + DEVELOPMENT: [], + } + for entry in pr_dict: + if entry[PR] <= last: + continue + line = f"- {entry[TITLE]} #{entry[PR]} {entry[AUTHOR]}\n" + result[get_type(entry[TITLE])].append(line) + return result + + +def read_changelog(): + """Read lines in CHANGELOG.md and skip white spaces""" + with open("CHANGELOG.md") as f: + content = f.readlines() + del content[0] + del content[0] + return content + + +def build_changelog(version, vscode_version, pr_lines, old_lines): + """Build lines in changelog and write new changelog""" + + lines = [ + f"# Changelog\n\n## {version}\n\nVS Code {vscode_version}\n\n", + ] + for content in [ + (FEATURE, "### New Features"), + (FIX, "### Bug Fixes"), + (DOCS, "### Documentation"), + (DEVELOPMENT, "### Development"), + ]: + lines.append(f"{content[1]}\n\n") + lines.extend(pr_lines[content[0]]) + lines.append("\n") + lines.extend(old_lines) + with open("CHANGELOG.md", "w") as f: + f.writelines(lines) + + +def main(argv): + """Run the script.""" + if not os.path.isfile("CHANGELOG.md"): + print("Run prepare_changelog.py from code-server root dir") + return 1 + if len(argv) != 4: + usage = "prepare_changelog.py " + print(f"Usage\n {usage}") + return 1 + version = argv[1] + vscode_version = argv[2] + last = int(argv[3]) + pr_dict = gather_pr_list() + pr_lines = generate_lines(pr_dict, last) + lines = read_changelog() + build_changelog(version, vscode_version, pr_lines, lines) + return 0 + + +if __name__ == "__main__": + sys.exit(main(sys.argv))