Skip to content

Commit cfafd02

Browse files
authored
Document release process in CONTRIBUTING.md and make it slightly easier (ni#2050)
* update LATEST_RELEASE together with config_addon.py * Don't create nifake LATEST_RELEASE file * Document release process in CONTRIBUTING.md * Delete duplicate releaase process steps from build_release.py * Don't mention Python 2.7 * Make the wait our 1st release step * **update** the LATEST_RELEASE versions to match
1 parent ac6f0b6 commit cfafd02

File tree

3 files changed

+72
-44
lines changed

3 files changed

+72
-44
lines changed

CONTRIBUTING.md

+54
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,60 @@ begin contributing to to the project.
131131
1. On GitHub, send a New pull request to the main repository's master branch. GitHub
132132
pull requests are the expected method of code collaboration on this project.
133133

134+
Release Process
135+
---------------
136+
1. Pre-Release Steps
137+
1. Checkout the master branch and pull down the latest changes
138+
```bash
139+
git checkout master
140+
# Discard all local changes
141+
git restore .
142+
# Merge changes from upstream
143+
git pull upstream master
144+
```
145+
1. Build master to ensure it is in a good state and ready for release
146+
```bash
147+
tox -e clean
148+
tox
149+
```
150+
1. Ensure no commits are made on ni/nimi-python/master until the release is complete
151+
1. Create and checkout a branch for release-related changes
152+
1. Update [CHANGELOG.md](./CHANGELOG.md)
153+
* Delete empty (i.e. No changes) sub-sections under "Unreleased" section
154+
* Change the "Unreleased" header to the version of the release
155+
* Change [Unreleased] in TOC to the version of the release
156+
* Commit to branch
157+
1. Update release versions
158+
* `python3 tools/build_release.py --update --release`
159+
* For each module, this will drop the .devN from our versions in config_addon.py and update the LATEST_RELEASE versions to match.
160+
* Commit to branch
161+
1. Clean and build to update generated files with new version
162+
* `python3 tools/build_release.py --build`
163+
* Commit to branch
164+
1. Create a pull request
165+
* It should contain all the changes made so far
166+
* Get the pull request reviewed but DO NOT merge to master yet
167+
1. Release Steps
168+
1. Wait until the pull request has been approved
169+
1. Upload the releases to PyPI
170+
* `python3 tools/build_release.py --upload`
171+
* You will need to type in your PyPI credentials
172+
1. Merge the pull request to origin/master
173+
1. Create a release on GitHub using the portion from the changelog for this release for the description
174+
* Add the ZIP files under `generated/examples` for each module as a release artifact.
175+
1. Post-Release Steps
176+
1. Create and checkout another branch for post-release changes
177+
1. Update the module versions
178+
* `python3 tools/build_release.py --update`
179+
* This will update the version to X.X.(N+1).dev0
180+
* Commit to branch
181+
1. Clean and build to update generated files with new version
182+
* `python3 tools/build_release.py --build`
183+
* Commit to branch
184+
1. Update changelog
185+
* Copy Unreleased section from bottom of changelog to the top and add a link to it in the TOC
186+
* Commit to branch
187+
1. Create a pull request containing post-release changes and get it merged
134188

135189
Developer Certificate of Origin (DCO)
136190
-------------------------------------

tools/build_release.py

+4-40
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,8 @@ def main():
2727
usage = """Release script
2828
Prereqs
2929
* Be able to build locally
30-
* `pip install --upgrade twine tox` into whichever Python 2.7 you use to build
31-
32-
Steps
33-
* Build master to ensure it is in a good state and ready for release
34-
* Ensure no commits are made on master until the release is complete
35-
* Create and checkout a branch for release-related changes
36-
* Update CHANGELOG.md
37-
* Delete empty (i.e. No changes) sub-sections under "Unreleased" section
38-
* Change the "Unreleased" header to the version of the release
39-
* Change [Unreleased] in TOC to the version of the release
40-
* Commit to branch
41-
* Update contents of src/<driver>/LATEST_RELEASE with the versions of each module being released by dropping the '.dev0' suffix.
42-
* `python3 tools/build_release.py --update --release`
43-
* This will update all the versions to remove any '.devN'
44-
* Commit to branch
45-
* `python3 tools/build_release.py --build`
46-
* Clean and build to update generated files with new version
47-
* Commit to branch
48-
* Create a pull request
49-
* It should contain all the changes made so far
50-
* Get the pull request reviewed but DO NOT merge to master yet
51-
* `python3 tools/build_release.py --upload`
52-
* Upload to PyPI - you will need to type in your credentials
53-
* Merge the pull request to origin/master
54-
* Create a release on GitHub using the portion from the changelog for this release for the description
55-
* Add the ZIP files under `generated/examples` for each module as a release artifact.
56-
* Create and checkout another branch for post-release changes
57-
* `python3 tools/build_release.py --update`
58-
* This will update the version to X.X.(N+1).dev0
59-
* Commit to branch
60-
* `python3 tools/build_release.py --build`
61-
* Clean and Build to update generated files
62-
* Commit to branch
63-
* Update changelog
64-
* Copy Unreleased section from bottom of changelog to the top and add a link to it in the TOC
65-
* Commit to branch
66-
* Create a pull request containing post-release changes and get it merged
67-
30+
* `pip install --upgrade twine tox` into whichever Python you use to build
31+
Steps: see "Release Process" section of CONTRIBUTING.md
6832
"""
6933
parser = argparse.ArgumentParser(description=usage, formatter_class=CustomFormatter)
7034

@@ -107,8 +71,8 @@ def main():
10771
logging.info('Updating versions')
10872

10973
for d in drivers_to_update:
110-
logging.info(pp.pformat(python_cmd + ['tools/updateReleaseInfo.py', '--src-file', f'src/{d}/metadata/config_addon.py', ] + passthrough_params))
111-
check_call(python_cmd + ['tools/updateReleaseInfo.py', '--src-file', f'src/{d}/metadata/config_addon.py', ] + passthrough_params)
74+
logging.info(pp.pformat(python_cmd + ['tools/updateReleaseInfo.py', '--src-folder', f'src/{d}', ] + passthrough_params))
75+
check_call(python_cmd + ['tools/updateReleaseInfo.py', '--src-folder', f'src/{d}', ] + passthrough_params)
11276

11377
if args.build:
11478
logging.info('Clean and build')

tools/updateReleaseInfo.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
from configure_logging import configure_logging
55
import logging
6+
import os
67
import pprint
78
import re
89

@@ -12,11 +13,11 @@
1213
def main():
1314
# Setup the required arguments for this script
1415
usage = """
15-
Update version when it is a dev version. I.e. X.Y.Z.devN to X.Y.Z.dev(N+1)
16+
Update version in files. Example: X.Y.Z.devN to X.Y.Z
1617
"""
1718
parser = argparse.ArgumentParser(description=usage)
1819
file_group = parser.add_argument_group("Input and Output files")
19-
file_group.add_argument("--src-file", action="store", required=True, help="Source file")
20+
file_group.add_argument("--src-folder", action="store", required=True, help="Source folder")
2021
file_group.add_argument("--release", action="store_true", default=False, help="This is a release build, so only remove '.devN'. Error if not there")
2122

2223
verbosity_group = parser.add_argument_group("Verbosity, Logging & Debugging")
@@ -34,7 +35,8 @@ def main():
3435

3536
logging.info(pp.pformat(args))
3637

37-
with open(args.src_file) as content_file:
38+
metadata_file = os.path.join(args.src_folder, "metadata", "config_addon.py")
39+
with open(metadata_file) as content_file:
3840
contents = content_file.read()
3941

4042
module_dev_version_re = re.compile(r"'module_version': '(\d+\.\d+\.\d+)\.dev(\d+)'")
@@ -43,6 +45,7 @@ def main():
4345
if args.release:
4446
logging.info('Dev version found, updating {0}.dev{1} to {0}'.format(m.group(1), int(m.group(2))))
4547
contents = module_dev_version_re.sub(f"'module_version': '{m.group(1)}'", contents)
48+
new_version = m.group(1)
4649
else:
4750
logging.info('Dev version found, updating {0}.dev{1} to {0}.dev{2}'.format(m.group(1), int(m.group(2)), int(m.group(2)) + 1))
4851
contents = module_dev_version_re.sub(f"'module_version': '{m.group(1)}.dev{int(m.group(2)) + 1}'", contents)
@@ -54,9 +57,16 @@ def main():
5457
contents = module_version_re.sub(f"'module_version': '{m.group(1)}{int(m.group(2)) + 1}.dev0'", contents)
5558

5659
if not args.preview:
57-
with open(args.src_file, 'w') as content_file:
60+
with open(metadata_file, 'w') as content_file:
5861
content_file.write(contents)
5962

63+
if args.release and "nifake" not in args.src_folder:
64+
latest_release_file = os.path.join(args.src_folder, "LATEST_RELEASE")
65+
logging.info(f'Updating version in {latest_release_file} to {new_version}.')
66+
if not args.preview:
67+
with open(latest_release_file, 'w') as content_file:
68+
content_file.write(f'{new_version}\n')
69+
6070

6171
if __name__ == '__main__':
6272
main()

0 commit comments

Comments
 (0)