diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f16210c6..36bdcda9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -190,3 +190,23 @@ jobs: platforms: linux/amd64 push: true tags: ${{ join(fromJson(steps.demotags.outputs.tags)) }} + + # jupyterhub/singleuser + - name: Get list of jupyterhub/singleuser tags + id: singleusertags + uses: jupyterhub/action-major-minor-tag-calculator@v2 + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + prefix: "${{ env.REGISTRY }}jupyterhub/singleuser:" + defaultTag: "${{ env.REGISTRY }}jupyterhub/singleuser:noref" + branchRegex: ^\w[\w-.]*$ + + - name: Build and push jupyterhub/singleuser + uses: docker/build-push-action@e1b7f96249f2e4c8e4ac1519b9608c0d48944a1f # associated tag: v2.4.0 + with: + build-args: | + JUPYTERHUB_VERSION=${{ github.ref_type == 'tag' && github.ref_name || format('git:{0}', github.sha) }} + context: singleuser + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ join(fromJson(steps.singleusertags.outputs.tags)) }} diff --git a/singleuser/Dockerfile b/singleuser/Dockerfile index 8b060684..ef7090ae 100644 --- a/singleuser/Dockerfile +++ b/singleuser/Dockerfile @@ -6,7 +6,6 @@ FROM $BASE_IMAGE MAINTAINER Project Jupyter ADD install_jupyterhub /tmp/install_jupyterhub -ARG JUPYTERHUB_VERSION=main -# install pinned jupyterhub and ensure jupyterlab is installed -RUN python3 /tmp/install_jupyterhub && \ - python3 -m pip install jupyterlab +ARG JUPYTERHUB_VERSION=git:HEAD +# install pinned jupyterhub +RUN python3 /tmp/install_jupyterhub diff --git a/singleuser/hooks/build b/singleuser/hooks/build deleted file mode 100644 index 7f8bb861..00000000 --- a/singleuser/hooks/build +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -ex - -docker build --build-arg JUPYTERHUB_VERSION=$DOCKER_TAG -t $DOCKER_REPO:$DOCKER_TAG . diff --git a/singleuser/hooks/post_push b/singleuser/hooks/post_push deleted file mode 100644 index 91db9e4c..00000000 --- a/singleuser/hooks/post_push +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -ex - -function get_hub_version() { - rm -f hub_version - V=$1 - docker run --rm -v $PWD:/version -u $(id -u) -i $DOCKER_REPO:$DOCKER_TAG sh -c 'jupyterhub --version > /version/hub_version' - hub_xyz=$(cat hub_version) - split=( ${hub_xyz//./ } ) - hub_xy="${split[0]}.${split[1]}" - # add .dev on hub_xy so it's 1.0.dev - if [[ ! -z "${split[3]:-}" ]]; then - hub_xy="${hub_xy}.${split[3]}" - fi -} -# tag e.g. 0.9 with main -get_hub_version -docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:$hub_xy -docker push $DOCKER_REPO:$hub_xy -docker tag $DOCKER_REPO:$DOCKER_TAG $DOCKER_REPO:$hub_xyz -docker push $DOCKER_REPO:$hub_xyz diff --git a/singleuser/install_jupyterhub b/singleuser/install_jupyterhub index b76c4237..cf20bff2 100644 --- a/singleuser/install_jupyterhub +++ b/singleuser/install_jupyterhub @@ -3,19 +3,22 @@ import os from subprocess import check_call import sys -V = os.environ['JUPYTERHUB_VERSION'] +version = os.environ['JUPYTERHUB_VERSION'] pip_install = [ - sys.executable, '-m', 'pip', 'install', '--no-cache', '--upgrade', - '--upgrade-strategy', 'only-if-needed', + sys.executable, + '-m', + 'pip', + 'install', + '--no-cache', + '--upgrade', + '--upgrade-strategy', + 'only-if-needed', ] -if V in {'main', 'HEAD'}: - req = 'https://github.com/jupyterhub/jupyterhub/archive/HEAD.tar.gz' +if version.startswith("git:"): + ref = version.partition(":")[-1] + req = f"https://github.com/jupyterhub/jupyterhub/archive/{ref}.tar.gz" else: - version_info = [ int(part) for part in V.split('.') ] - version_info[-1] += 1 - upper_bound = '.'.join(map(str, version_info)) - vs = '>=%s,<%s' % (V, upper_bound) - req = 'jupyterhub%s' % vs + req = f"jupyterhub=={version}" check_call(pip_install + [req])