Skip to content
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

Clean up bump version script #960

Merged
merged 4 commits into from
Sep 13, 2021
Merged
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
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