Skip to content

Check for new JupyterLab releases #1501

Check for new JupyterLab releases

Check for new JupyterLab releases #1501

name: Check for new JupyterLab releases
on:
schedule:
- cron: 30 17 * * *
workflow_dispatch:
# Disable permissions for all of the available permissions.
permissions: {}
jobs:
check-latest-version:
runs-on: ubuntu-latest
environment: sync
permissions:
contents: read
outputs:
latest: ${{ steps.get-latest-jupyterlab-version.outputs.result }}
update_available: ${{ steps.check-update.outputs.update_available }}
steps:
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Install tbump
run: python -m pip install tbump==6.11.0
- name: Get latest JupyterLab version
id: get-latest-jupyterlab-version
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const releases = await github.rest.repos.listReleases({
owner: "jupyterlab",
repo: "jupyterlab"
})
const latestRelease = releases.data.find(release => release.tag_name.startsWith('v') && !(release.draft || release.prerelease))
return latestRelease ? latestRelease.tag_name.substring(1) : ''
result-encoding: string
- name: Check for new releases
id: check-update
run: |
set -eux
export LATEST=${{ steps.get-latest-jupyterlab-version.outputs.result }}
tbump --only-patch ${LATEST}-1 --non-interactive
if [[ ! -z "$(git status --porcelain package.json)" ]]; then
echo "update_available=true" >> $GITHUB_OUTPUT
else
echo "update_available=false" >> $GITHUB_OUTPUT
fi
- name: Upload updated version spec files
uses: actions/upload-artifact@v4
if: steps.check-update.outputs.update_available == 'true'
with:
name: updated-version-info
path: |
tbump.toml
package.json
env_installer/jlab_server.yaml
if-no-files-found: error
update-files:
needs: check-latest-version
if: needs.check-latest-version.outputs.update_available == 'true'
runs-on: macos-latest
defaults:
run:
# needed for conda to work
shell: bash -el {0}
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Download updated version info
uses: actions/download-artifact@v4
with:
name: updated-version-info
path: .
- name: Install Node
uses: actions/setup-node@v5
with:
node-version: '20.x'
- name: Install npm dependencies
run: |
npm install --global yarn
yarn install
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
auto-activate-base: true
channels: conda-forge
- name: Install conda dependencies
run: conda install -c conda-forge conda conda-lock -y
- name: Update conda lock files
run: yarn update_conda_lock
- name: Update binary sign list osx-64
run: |
yarn clean_env_installer && conda-lock install --no-validate-platform --prefix ./env_installer/jlab_server ./env_installer/conda-osx-64.lock
yarn update_binary_sign_list --platform osx-64
- name: Update binary sign list osx-arm64
run: |
yarn clean_env_installer && conda-lock install --no-validate-platform --prefix ./env_installer/jlab_server ./env_installer/conda-osx-arm64.lock
yarn update_binary_sign_list --platform osx-arm64
- name: Copy changed files to artifact directory
run: |
mkdir -p changed-files
changed_files=$(git diff --name-only)
echo "$changed_files" | while read file; do
if [ -f "$file" ]; then
mkdir -p "changed-files/$(dirname "$file")"
cp "$file" "changed-files/$file"
fi
done
- name: Upload updated repo as artifact
uses: actions/upload-artifact@v4
with:
name: updated-repo
path: changed-files/
if-no-files-found: error
push-and-pr:
needs: [check-latest-version, update-files]
if: needs.check-latest-version.outputs.update_available == 'true'
runs-on: ubuntu-latest
environment: sync
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Download updated lock files and sign lists
uses: actions/download-artifact@v4
with:
name: updated-repo
path: .
- name: Push changes & open PR
env:
LATEST: ${{ needs.check-latest-version.outputs.latest }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -eux
# this will fail if the branch already exists which means we won't have duplicate PRs
BRANCH_NAME="update-to-v${LATEST}"
git checkout -b "${BRANCH_NAME}"
git config user.name "JupyterLab Desktop Bot"
git config user.email '[email protected]'
git add .
git commit -m "Update to JupyterLab v${LATEST}"
git push --set-upstream origin "${BRANCH_NAME}"
gh pr create \
--title "Update to JupyterLab v${LATEST}" \
--body "New JupyterLab release [v${LATEST}](https://github.com/jupyterlab/jupyterlab/releases/tag/v${LATEST}) is available. Please review the lock file carefully."