Skip to content

Changelog script #3637

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

Closed
wants to merge 3 commits into from
Closed
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
66 changes: 0 additions & 66 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,5 @@
# Changelog

<!--

This should be updated on every PR.

We copy from here into the release notes.

-->

<!--
Add next version above previous version but below this line using the template

## Next Version

VS Code v0.00.0

### New Features

- item

### Bug Fixes

- fix(socket): did this thing #321 @githubuser

### Documentation

- item

### Development

- item

-->

## 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
Expand Down
16 changes: 16 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions docs/MAINTAINING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<pr title> <pr #> <author> 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

Expand Down
110 changes: 110 additions & 0 deletions prepare_changelog.py
Original file line number Diff line number Diff line change
@@ -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 <release> <vscode release> <last PR of previous release>"
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))