1
- """This script automated the release process for all of the packages in this repository.
1
+ """This script automates the release process for all of the packages in this repository.
2
2
In order, this script does the following:
3
3
4
4
1. Bump version number in manifest files according to given required arg (see `--help`).
5
5
This alters the Cargo.toml in repo root and the package.json files in node-binding.
6
6
7
- Requires `yarn` (see https://yarnpkg.com) and `napi` (see https://napi.rs) installed
8
- to bump node-binding versions.
7
+ Requires `yarn` (see https://yarnpkg.com) and `napi` (see https://napi.rs) to be
8
+ installed to bump node-binding versions.
9
9
10
10
2. Updates the CHANGELOG.md
11
11
12
- Requires `git-cliff` installed (see https://git-cliff.org)
12
+ Requires `git-cliff` (see https://git-cliff.org) to be installed
13
13
to regenerate the change logs from git history.
14
14
15
15
NOTE: `git cliff` uses GITHUB_TOKEN env var to access GitHub's REST API for
20
20
4. Creates a GitHub Release and uses the section from the CHANGELOG about the new tag
21
21
as a release description.
22
22
23
- Requires `gh-cli` installed (see https://cli.github.com) to create the release and
24
- push the tag.
23
+ Requires `gh-cli` (see https://cli.github.com) to be installed to create the release
24
+ and push the tag.
25
25
26
26
NOTE: This step also tags the commit from step 3.
27
27
When a tag is pushed to the remote, the CI builds are triggered and
28
28
29
29
- release assets are uploaded to the Github Release corresponding to the new tag
30
- - packages are published for npm, pip and cargo
30
+ - packages are published for npm, pip, and cargo
31
31
32
32
NOTE: In a CI run, the GH_TOKEN env var to authenticate access.
33
33
Locally, you can use `gh login` to interactively authenticate the user account.
43
43
)
44
44
VER_REPLACE = 'version = "%d.%d.%d%s" # auto'
45
45
COMPONENTS = ("major" , "minor" , "patch" , "rc" )
46
- VERSION_LOG = re .compile (rb "^## \[\d+\.\d+\.\d+(?:\-rc)?\d*\]" )
46
+ VERSION_LOG = re .compile (r "^## \[\d+\.\d+\.\d+(?:\-rc)?\d*\]" )
47
47
48
48
49
49
class Updater :
@@ -77,25 +77,25 @@ def replace(match: re.Match[str]) -> str:
77
77
78
78
79
79
def get_release_notes (tag : str = Updater .new_version ):
80
- title , buf = ( "" , b"" )
80
+ title , buf = "" , ""
81
81
log_file = Path (__file__ ).parent .parent .parent / "CHANGELOG.md"
82
- tag_buf = f"[{ tag } ]" . encode ( encoding = "utf-8" )
83
- with open (str (log_file ), "rb" ) as log :
82
+ tag_pattern = f"[{ tag } ]"
83
+ with open (str (log_file ), "r" , encoding = "utf-8" ) as logs :
84
84
found_notes = False
85
- for line in log . readlines () :
85
+ for line in logs :
86
86
matched = VERSION_LOG .match (line )
87
87
if matched is not None :
88
- if tag_buf in matched .group (0 ):
89
- title = tag + line [matched .end () :]. decode ( encoding = "utf-8" )
88
+ if tag_pattern in matched .group (0 ):
89
+ title = tag + line [matched .end () :]
90
90
found_notes = True
91
91
else :
92
92
found_notes = False
93
- elif line .startswith (b "[unreleased]: " ) and found_notes :
93
+ elif line .startswith ("[unreleased]: " ) and found_notes :
94
94
found_notes = False
95
95
elif found_notes :
96
96
buf += line
97
- elif line .startswith (tag_buf + b ": " ):
98
- buf += line .replace (tag_buf , b "Full commit diff" , 1 )
97
+ elif line .startswith (tag_pattern + ": " ):
98
+ buf += line .replace (tag_pattern , "Full commit diff" , 1 )
99
99
return title .rstrip (), buf .strip ()
100
100
101
101
@@ -133,8 +133,11 @@ def main():
133
133
try :
134
134
subprocess .run (["git" , "push" ], check = True )
135
135
except subprocess .CalledProcessError as exc :
136
- raise RuntimeError ("Failed to push commit for version bump" ) from exc
137
-
136
+ raise RuntimeError (
137
+ """Failed to push commit for version bump. Please ensure that
138
+ - You have the necessary permissions and are authenticated properly.
139
+ - All other commits on the branch have ben pushed already."""
140
+ ) from exc
138
141
title , notes = get_release_notes ()
139
142
print ("Pushed commit to 'Bump version to" , tag , "'" )
140
143
gh_cmd = [
@@ -145,7 +148,7 @@ def main():
145
148
"--title" ,
146
149
title ,
147
150
"--notes" ,
148
- notes . decode ( "utf-8" ) ,
151
+ notes ,
149
152
]
150
153
if Updater .component == "rc" :
151
154
gh_cmd .append ("--prerelease" )
0 commit comments