Skip to content

Commit

Permalink
Merge pull request #486 from consideRatio/pr/modern-release-workflow
Browse files Browse the repository at this point in the history
Update release workflow and RELEASE.md, set version with tbump
  • Loading branch information
minrk committed Jun 1, 2023
2 parents 2c4839a + 47567e0 commit 3317c81
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 108 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/publish.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/release.yaml
@@ -0,0 +1,54 @@
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
#
name: Release

# Always tests wheel building, but only publish to PyPI on pushed tags.
on:
pull_request:
paths-ignore:
- "docs/**"
- ".github/workflows/*.yaml"
- "!.github/workflows/release.yaml"
push:
paths-ignore:
- "docs/**"
- ".github/workflows/*.yaml"
- "!.github/workflows/release.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags: ["**"]
workflow_dispatch:

jobs:
build-release:
runs-on: ubuntu-22.04
permissions:
# id-token=write is required for pypa/gh-action-pypi-publish, and the PyPI
# project needs to be configured to trust this workflow.
#
# ref: https://github.com/jupyterhub/team-compass/issues/648
#
id-token: write

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: install build package
run: |
pip install --upgrade pip
pip install build
pip freeze
- name: build release
run: |
python -m build --sdist --wheel .
ls -l dist
- name: publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/')
12 changes: 6 additions & 6 deletions README.md
@@ -1,11 +1,11 @@
# DockerSpawner

[![GitHub Workflow Status - Test](https://img.shields.io/github/workflow/status/jupyterhub/dockerspawner/Tests?logo=github&label=tests)](https://github.com/jupyterhub/dockerspawner/actions)
[![Latest PyPI version](https://img.shields.io/pypi/v/dockerspawner?logo=pypi)](https://pypi.org/project/dockerspawner/)
[![Documentation build status](https://img.shields.io/readthedocs/jupyterhub?logo=read-the-docs)](https://jupyterhub-dockerspawner.readthedocs.org/en/latest/)
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/dockerspawner/issues)
[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)
[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub)
[![Latest PyPI version](https://img.shields.io/pypi/v/dockerspawner?logo=pypi)](https://pypi.python.org/pypi/dockerspawner)
[![Latest conda-forge version](https://img.shields.io/conda/vn/conda-forge/dockerspawner?logo=conda-forge)](https://anaconda.org/conda-forge/dockerspawner)
[![GitHub Workflow Status - Test](https://img.shields.io/github/actions/workflow/status/jupyterhub/dockerspawner/test.yaml?logo=github&label=tests)](https://github.com/jupyterhub/dockerspawner/actions)
[![Test coverage of code](https://codecov.io/gh/jupyterhub/dockerspawner/branch/main/graph/badge.svg)](https://codecov.io/gh/jupyterhub/dockerspawner)
[![Issue tracking - GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/dockerspawner/issues)
[![Help forum - Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub)

The **dockerspawner** (also known as JupyterHub Docker Spawner), enables
[JupyterHub](https://github.com/jupyterhub/jupyterhub) to spawn single user
Expand Down
87 changes: 39 additions & 48 deletions RELEASE.md
@@ -1,69 +1,60 @@
# How to make a release

`dockerspawner` is a package [available on
PyPI](https://pypi.org/project/dockerspawner/).
The PyPI release is done automatically by TravisCI when a tag
is pushed.
`dockerspawner` is a package available on [PyPI] and [conda-forge].

For you to follow along according to these instructions, you need
to have push rights to the [dockerspawner GitHub
repository](https://github.com/jupyterhub/dockerspawner).
These are the instructions on how to make a release.

## Pre-requisites

- Push rights to this GitHub repository

## Steps to make a release

1. Checkout main and make sure it is up to date.
1. Create a PR updating `docs/source/changelog.md` with [github-activity] and
continue when its merged.

```bash
ORIGIN=${ORIGIN:-origin} # set to the canonical remote, e.g. 'upstream' if 'origin' is not the official repo
git checkout main
git fetch $ORIGIN main
git reset --hard $ORIGIN/main
# WARNING! This next command deletes any untracked files in the repo
git clean -xfd
```
Advice on this procedure can be found in [this team compass
issue](https://github.com/jupyterhub/team-compass/issues/563).

1. Update [docs/source/changelog.md](docs/source/changelog.md) and add it to
the working tree.
2. Checkout main and make sure it is up to date.

```bash
git add docs/source/changelog.md
```shell
git checkout main
git fetch origin main
git reset --hard origin/main
```

Tip: Identifying the changes can be made easier with the help of the
[executablebooks/github-activity](https://github.com/executablebooks/github-activity)
utility.
3. Update the version, make commits, and push a git tag with `tbump`.

1. Set the `version_info` variable in [\_version.py](dockerspawner/_version.py)
appropriately and make a commit.

```bash
git add dockerspawner/_version.py
VERSION=... # e.g. 1.2.3
git commit -m "release $VERSION"
```shell
pip install tbump
```

Tip: You can get the current project version by checking the [latest
tag on GitHub](https://github.com/jupyterhub/dockerspawner/tags).

1. Create a git tag for the release commit.
`tbump` will ask for confirmation before doing anything.

```bash
git tag -a $VERSION -m "release $VERSION"
# then verify you tagged the right commit
git log
```shell
# Example versions to set: 1.0.0, 1.0.0b1
VERSION=
tbump ${VERSION}
```

1. Reset the `version_info` variable in
[\_version.py](dockerspawner/_version.py) appropriately with an incremented
patch version and a `dev` element, then make a commit.
Following this, the [CI system] will build and publish a release.

```bash
git add dockerspawner/_version.py
git commit -m "back to dev"
4. Reset the version back to dev, e.g. `1.0.1.dev` after releasing `1.0.0`.

```shell
# Example version to set: 1.0.1.dev
NEXT_VERSION=
tbump --no-tag ${NEXT_VERSION}.dev
```

1. Push your two commits.
5. Following the release to PyPI, an automated PR should arrive within 24 hours
to [conda-forge/dockerspawner-feedstock] with instructions on releasing to
conda-forge. You are welcome to volunteer doing this, but aren't required as
part of making this release to PyPI.

```bash
git push $ORIGIN main --follow-tags
```
[github-activity]: https://github.com/executablebooks/github-activity
[pypi]: https://pypi.org/project/dockerspawner/
[conda-forge]: https://anaconda.org/conda-forge/dockerspawner
[conda-forge/dockerspawner-feedstock]: https://github.com/conda-forge/dockerspawner-feedstock
[ci system]: https://github.com/jupyterhub/dockerspawner/actions/workflows/release.yaml
19 changes: 6 additions & 13 deletions dockerspawner/_version.py
@@ -1,14 +1,7 @@
"""dockerspawner version info"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
# __version__ should be updated using tbump, based on configuration in
# pyproject.toml, according to instructions in RELEASE.md.
#
__version__ = "12.2.0.dev"

version_info = (
12,
2,
0,
'dev', # comment-out this line for a release
)
__version__ = '.'.join(map(str, version_info[:3]))

if len(version_info) > 3:
__version__ = '%s%s' % (__version__, version_info[3])
# version_info looks like (1, 2, 3, "dev") if __version__ is 1.2.3.dev
version_info = tuple(int(p) if p.isdigit() else p for p in __version__.split("."))
32 changes: 32 additions & 0 deletions pyproject.toml
Expand Up @@ -37,3 +37,35 @@ markers = [
"group",
"services",
]


# tbump is used to simplify and standardize the release process when updating
# the version, making a git commit and tag, and pushing changes.
#
# ref: https://github.com/your-tools/tbump#readme
#
[tool.tbump]
github_url = "https://github.com/jupyterhub/dockerspawner"

[tool.tbump.version]
current = "12.2.0.dev"
regex = '''
(?P<major>\d+)
\.
(?P<minor>\d+)
\.
(?P<patch>\d+)
(?P<pre>((a|b|rc)\d+)|)
\.?
(?P<dev>(?<=\.)dev\d*|)
'''

[tool.tbump.git]
message_template = "Bump to {new_version}"
tag_template = "{new_version}"

[[tool.tbump.file]]
src = "setup.py"

[[tool.tbump.file]]
src = "dockerspawner/_version.py"
7 changes: 1 addition & 6 deletions setup.py
Expand Up @@ -21,11 +21,6 @@
pjoin = os.path.join
here = os.path.abspath(os.path.dirname(__file__))

# Get the current package version.
version_ns = {}
with open(pjoin(here, 'dockerspawner', '_version.py')) as f:
exec(f.read(), {}, version_ns)

install_requires = []
with open('requirements.txt') as f:
for line in f.readlines():
Expand Down Expand Up @@ -53,7 +48,7 @@ def run(self):
setup_args = dict(
name='dockerspawner',
packages=['dockerspawner'],
version=version_ns['__version__'],
version="12.2.0.dev",
description="""Dockerspawner: A custom spawner for Jupyterhub.""",
long_description="Spawn single-user servers with Docker.",
author="Jupyter Development Team",
Expand Down

0 comments on commit 3317c81

Please sign in to comment.