|
| 1 | +# Release guide This document describes release procedures, conventions, and |
| 2 | +utilities for `pywatershed`. |
| 3 | + |
| 4 | +<!-- START doctoc generated TOC please keep comment here to allow auto update --> |
| 5 | +<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 6 | +**Contents** |
| 7 | + |
| 8 | +- [Conventions](#conventions) |
| 9 | +- [Releasing `pywatershed`](#releasing-pywatershed) |
| 10 | +- [Utility scripts](#utility-scripts) |
| 11 | + - [Updating version numbers](#updating-version-numbers) |
| 12 | + |
| 13 | +<!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 14 | + |
| 15 | +## Conventions |
| 16 | + |
| 17 | +- Releases follow the [git |
| 18 | + flow](https://nvie.com/posts/a-successful-git-branching-model/). - Release |
| 19 | + numbers follow [semantic version](https://semver.org/) conventions. - Minor |
| 20 | + and major releases branch from `develop`. Patches branch from `main`. |
| 21 | + |
| 22 | +## Releasing `pywatershed` |
| 23 | + |
| 24 | +The release procedure is mostly automated. The workflow is defined in |
| 25 | +`.github/workflows/release.yaml` and triggers when a release or patch branch is |
| 26 | +pushed to this repo. |
| 27 | + |
| 28 | +To release a new version: |
| 29 | + |
| 30 | +1. Test asv benchmarking with the `-q` flag to ensure it is working (multiple |
| 31 | + platformas a bonus). |
| 32 | + |
| 33 | +1. On your local machine, create a release branch from `develop` or a patch |
| 34 | + branch from `main`. The branch's name must follow format |
| 35 | + `v{major}.{minor}.{patch}` ([semantic version](https://semver.org/) number |
| 36 | + with a leading 'v'). For instance, for a minor release, if this repo is an |
| 37 | + `upstream` remote and one's local `develop` is up to date with upstream |
| 38 | + `develop`, then from `develop` run `git switch -c vx.y.z`. |
| 39 | + |
| 40 | +1. If this is a patch release, make changes/fixes locally. If this is a major or |
| 41 | + minor release, no changes are needed. |
| 42 | + |
| 43 | + In either case, add the release version and date to the top of |
| 44 | + `doc/whats-new.rst`. If a patch, put it below the pending minor release. |
| 45 | + |
| 46 | +1. Push the branch to this repo. For instance, if this repo is an `upstream` |
| 47 | + remote: `git push -u upstream vx.y.z`. This starts a job to: |
| 48 | + |
| 49 | + - Check out the release branch Update version number in `version.txt` and |
| 50 | + - `pywatershed/version.py` to match the version in the branch name Build and |
| 51 | + - check the Python package Generate a changelog since the last release |
| 52 | + - Prepend the changelog to the cumulative `HISTORY.md` Upload the package |
| 53 | + - and changelog as artifacts Draft a PR against `main` with the updated |
| 54 | + - version files and cumulative changelog. The cumulative `HISTORY.md` is |
| 55 | + - version-controlled, release changelogs are not. |
| 56 | + |
| 57 | +1. On all platforms, pull the release from upstream and perform ASV performance |
| 58 | + benchmarks against previous release , e.g., ``` asv continuous --verbose |
| 59 | + --show-stderr --factor 1.3 previous_release this_release ``` Collect |
| 60 | + performance reports from various machines into a single report and use `asv |
| 61 | + publish` to generate the static webpages to be included with the release as |
| 62 | + artifacts in that step below. |
| 63 | + |
| 64 | +1. Inspect the package and changelog. If they look good, merge the PR to `main`. |
| 65 | + |
| 66 | + **Note**: it is critical to *merge* the PR to `main`, not squash as is |
| 67 | + conventional for development PRs. Squashing causes `develop` and `main` to |
| 68 | + diverge. Merging to `main` preserves commit history and ensures `develop` |
| 69 | + and `main` don't diverge. |
| 70 | + |
| 71 | + Merging the PR to `main` will trigger another job to draft a [GitHub |
| 72 | + release](https://github.com/EC-USGS/pywatershed/releases). The release is |
| 73 | + not yet publicly visible at this point. The release notes are autofilled as |
| 74 | + the changelog since the last release. |
| 75 | + |
| 76 | +1. Inspect the GitHub release. If needed, make any manual edits to the release |
| 77 | + notes. If the release looks good, publish it via GitHub UI or CLI. Manually |
| 78 | + add the asv static web pages and frozen conda dependencies for each platform. |
| 79 | + |
| 80 | + Publishing the release on GitHub automatically tags the head of `main` with |
| 81 | + the release version number (**Note**: release tags, unlike branches, don't |
| 82 | + include an initial `v`, as is common in some projects) and triggers jobs to: |
| 83 | + |
| 84 | + - Publish the package to PyPI |
| 85 | + - Check out `main` |
| 86 | + - Run `.github/scripts/update_version.py -v x.y+1.0.dev0` to update |
| 87 | + `version.txt` and `pywatershed/version.py` with the minor version number |
| 88 | + incremented. The `.dev0` suffix indicates preliminary development status. |
| 89 | + - Draft a PR against `develop` with the updated version files and the |
| 90 | + updates previously merged to `main`. |
| 91 | + |
| 92 | +1. In the case of a minor or major release, a couple of manual steps: |
| 93 | + - Update the PR against `develop` to add a new minor or major release to |
| 94 | + the top of `doc/whats-new.rst` |
| 95 | + - Update `main` image on WholeTale to have the current release. |
| 96 | + |
| 97 | +1. Merge the PR to `develop`. As above, it is important to *merge* the PR, not |
| 98 | + squash, to preserve history and keep `develop` and `main` from diverging. |
| 99 | + |
| 100 | + |
| 101 | +## Utility scripts |
| 102 | + |
| 103 | +The automated release procedure uses a few scripts, located in |
| 104 | +`.github/scripts`. |
| 105 | + |
| 106 | +### Updating version numbers |
| 107 | + |
| 108 | +The `update_version.py` script can be used to update version numbers embedded in |
| 109 | +the repository. The script acquires a file lock to make sure only one process |
| 110 | +edits version files at a given time. If the script is run with no arguments, |
| 111 | +updated timestamp comments are written but the version number is not changed. To |
| 112 | +set the version number, use the `--version` (short `-v`) option. |
| 113 | + |
| 114 | +For instance, to set the version number before a release: |
| 115 | + |
| 116 | +```shell python .github/scripts/update_version.py -a -v 0.1.3 ``` |
| 117 | + |
| 118 | +Or to set the version number on `develop` following a release: |
| 119 | + |
| 120 | +```shell python .github/scripts/update_version.py -a -v 0.2.0.dev0 ``` |
| 121 | + |
| 122 | +To get the current version number without writing any changes to the |
| 123 | +repository's files, use the `--get` (short `-g`) flag: |
| 124 | + |
| 125 | +```shell python .github/scripts/update_version.py -g ``` |
| 126 | + |
| 127 | +**Note**: this script should not need to be run manually, as it is run automatically in the release automation. |
0 commit comments