-
Notifications
You must be signed in to change notification settings - Fork 949
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6dff84d
commit a3501f0
Showing
16 changed files
with
268 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Check Release | ||
on: | ||
push: | ||
branches: ["master"] | ||
pull_request: | ||
branches: ["*"] | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
check_release: | ||
timeout-minutes: 720 | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
group: [check_release, link_check] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.9 | ||
architecture: "x64" | ||
- name: Install node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14.x" | ||
# Cache yarn | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
- name: Cache yarn | ||
uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Get pip cache dir | ||
id: pip-cache | ||
run: | | ||
echo "::set-output name=dir::$(pip cache dir)" | ||
- name: Cache pip | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.pip-cache.outputs.dir }} | ||
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
${{ runner.os }}-pip- | ||
- name: Cache checked links | ||
if: ${{ matrix.group == 'link_check' }} | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pytest-link-check | ||
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/*.md', '**/*.rst') }}-md-links | ||
restore-keys: | | ||
${{ runner.os }}-linkcheck- | ||
- name: Upgrade packaging dependencies | ||
run: | | ||
pip install --upgrade pip setuptools wheel --user | ||
- name: Check Release | ||
if: ${{ matrix.group == 'check_release' }} | ||
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
RH_VERSION_SPEC: next | ||
- name: Check Links | ||
if: ${{ matrix.group == 'link_check' }} | ||
uses: jupyter-server/jupyter_releaser/.github/actions/check-links@v1 | ||
- name: Upload Distributions | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ipywidgets-jupyter-releaser-dist-${{ github.run_number }} | ||
path: .jupyter_releaser_checkout/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License.import click | ||
|
||
# Heavily inspired by: | ||
# - https://github.com/jupyterlab/jupyterlab/blob/master/buildutils/src/bumpversion.ts | ||
# - https://github.com/jupyterlab/retrolab/blob/main/buildutils/src/release-bump.ts | ||
|
||
import click | ||
from jupyter_releaser.util import is_prerelease, get_version, run | ||
|
||
|
||
OPTIONS = ["major", "minor", "release", "build"] | ||
|
||
|
||
def patch(force=False): | ||
version = get_version() | ||
if is_prerelease(version): | ||
raise Exception("Can only make a patch release from a final version") | ||
|
||
run("bumpversion patch", quiet=True) | ||
# switches to alpha | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to beta | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to rc. | ||
run("bumpversion release --allow-dirty", quiet=True) | ||
# switches to final. | ||
|
||
# Version the changed | ||
cmd = "yarn run lerna version patch --no-push --force-publish --no-git-tag-version" | ||
if force: | ||
cmd += " --yes" | ||
run(cmd) | ||
|
||
|
||
def update(spec, force=False): | ||
prev = get_version() | ||
|
||
# Make sure we have a valid version spec. | ||
if spec not in OPTIONS: | ||
raise Exception(f"Version spec must be one of: {OPTIONS}") | ||
|
||
is_final = not is_prerelease(prev) | ||
|
||
if is_final and spec == "release": | ||
raise Exception('Use "major" or "minor" to switch back to alpha release') | ||
|
||
if is_final and spec == "build": | ||
raise Exception("Cannot increment a build on a final release") | ||
|
||
# If this is a major release during the alpha cycle, bump | ||
# just the Python version. | ||
if "a" in prev and spec == "major": | ||
run(f"bumpversion {spec}") | ||
return | ||
|
||
# Determine the version spec to use for yarn. | ||
version = "preminor" | ||
if spec == "build": | ||
version = "prerelease" | ||
# a -> b | ||
elif spec == "release" and "a" in prev: | ||
version = "prerelease --preid beta" | ||
# b -> rc | ||
elif spec == "release" and "b" in prev: | ||
version = "prerelease --preid rc" | ||
# rc -> final | ||
elif spec == "release" and "c" in prev: | ||
version = "patch" | ||
if version == "preminor": | ||
version += " --preid alpha" | ||
|
||
cmd = f"yarn run lerna version --no-push --force-publish --no-git-tag-version {version}" | ||
if force: | ||
cmd += " --yes" | ||
|
||
# For a preminor release, we bump 10 minor versions so that we do | ||
# not conflict with versions during minor releases of the top level package. | ||
if version == "preminor": | ||
for i in range(10): | ||
run(cmd) | ||
else: | ||
run(cmd) | ||
|
||
# Bump the version. | ||
run(f"bumpversion {spec} --allow-dirty") | ||
|
||
|
||
@click.command() | ||
@click.option("--force", default=False, is_flag=True) | ||
@click.argument("spec", nargs=1) | ||
def bump(force, spec): | ||
status = run("git status --porcelain").strip() | ||
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 | ||
|
||
update(spec, force) | ||
|
||
|
||
if __name__ == "__main__": | ||
bump() |