Skip to content

Commit

Permalink
Clean up bump version script (#960)
Browse files Browse the repository at this point in the history
* Clean up bump version script

* Update RELEASE.md

* Update RELEASE.md

* Fix typos
  • Loading branch information
jtpio authored Sep 13, 2021
1 parent a550871 commit aa79d9c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,9 @@ jobs:
run: |
pip install .
- name: Configure Version Spec
id: version-spec
if: ${{ matrix.group == 'check_release' }}
run: |
set -eux
version=$(python setup.py --version)
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
version_spec=patch
else
version_spec=build
fi
echo "::set-output name=spec::${version_spec}"
- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
env:
RH_VERSION_SPEC: ${{ steps.version-spec.outputs.spec }}
RH_VERSION_SPEC: next
with:
token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 12 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ For now releases are still done manually (see section below).

https://github.com/jupyterlab/jupyterlab/blob/master/RELEASE.md#bump-version

`jupyter_releaser` handles the bump automatically so it is not necessary to do it manually, as long as the spec is correctly specified in the workflow.

### Manual bump

To manually bump the version, run:

```bash
Expand All @@ -22,7 +26,13 @@ python -m pip install -e ".[test,dev]"
python scripts/bump-version.py <spec>
```

Where `<spec>` can be one of the following: `patch`, `minor`, `major`, `release`.
Where `<spec>` can be one of the following: `patch`, `minor`, `major`, `release` or `next` (auto for `patch` or `minor`).

## Major JS bump

When there is a breaking change in a JS package, the version of the package should be bumped by one major version.

For example if the version of the preview extension was `2.1.0-alpha.1` and a breaking is introduced, bump to `3.0.0-alpha.0`.

## Releasing on conda-forge

Expand Down Expand Up @@ -55,8 +65,7 @@ Make sure the `dist/` folder is empty.

1. Bump the version:
- `python -m pip install bump2version jupyter-releaser`
- For a patch release: `python scripts/bump-version patch`
- For a build release: `python scripts/bump-version build`
- For a patch or build release: `python scripts/bump-version next`
2. `python -m build`
3. Double check the size of the bundles in the `dist/` folder
4. Make sure the JupyterLab extension is correctly bundled in source distribution
Expand Down
11 changes: 8 additions & 3 deletions scripts/bump-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# - https://github.com/jupyterlab/retrolab/blob/main/buildutils/src/release-bump.ts

import click
from jupyter_releaser.util import get_version, run
from jupyter_releaser.util import is_prerelease, get_version, run


OPTIONS = ["major", "minor", "release", "build"]


def patch(force=False):
version = get_version()
if "a" in version or "b" in version or "rc" in version:
if is_prerelease(version):
raise Exception("Can only make a patch release from a final version")

run("bumpversion patch", quiet=True)
Expand All @@ -40,7 +40,7 @@ def update(spec, force=False):
if spec not in OPTIONS:
raise Exception(f"Version spec must be one of: {OPTIONS}")

is_final = "a" not in prev and "b" not in prev and "c" not in prev
is_final = not is_prerelease(prev)

if is_final and spec == "release":
raise Exception('Use "major" or "minor" to switch back to alpha release')
Expand Down Expand Up @@ -94,6 +94,11 @@ def bump(force, spec):
if len(status) > 0:
raise Exception("Must be in a clean git state with no untracked files")

prev = get_version()
is_final = not is_prerelease(prev)
if spec == "next":
spec = "patch" if is_final else "build"

if spec == "patch":
patch(force)
return
Expand Down

0 comments on commit aa79d9c

Please sign in to comment.