Check for latest JupyterLab releases #4
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
name: Check for new JupyterLab releases | |
on: | |
schedule: | |
- cron: 30 17 * * * | |
workflow_dispatch: | |
inputs: | |
branchname: | |
description: 'Branch name' | |
default: main | |
required: true | |
type: string | |
version: | |
description: 'latest or prerelease' | |
default: latest | |
required: true | |
type: string | |
env: | |
branch: 'main' | |
version: 'latest' | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
check_for_lab_updates: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install tbump | |
python -m pip install pre-commit | |
- name: Install Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20.x' | |
- name: Install npm dependencies | |
run: | | |
npm install --global yarn | |
yarn install | |
- name: Check for new releases | |
shell: bash | |
working-directory: ./ | |
run: | | |
set -eux | |
for version in ${{ inputs.version || env.version }} | |
do | |
export LATEST=$(python scripts/get_latest_lab_version.py --set-release version) | |
done | |
echo "latest=${LATEST}" >> $GITHUB_ENV | |
python scripts/upgrade_lab_dependencies.py --set-version ${LATEST} | |
if [[ ! -z "$(git status --porcelain package.json)" ]]; then | |
tbump --only-patch ${LATEST}-1 --non-interactive | |
yarn install | |
fi | |
- name: Create a PR if needed | |
shell: bash | |
env: | |
GITHUB_USER: itsmevichu | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -eux | |
# if resulted in any change: | |
export LATEST=${{ env.latest }} | |
if [[ ! -z "$(git status --porcelain package.json)" ]]; then | |
export BRANCH_NAME=update-to-v${LATEST} | |
# this will fail if the branch already exists which means we won't have duplicate PRs | |
git checkout -b "${BRANCH_NAME}" | |
git config user.name "JupyterLab Desktop Bot" | |
git config user.email '[email protected]' | |
pre-commit run | |
git commit . -m "Update to JupyterLab v${LATEST}" | |
git push --set-upstream origin "${BRANCH_NAME}" | |
hub pull-request -m "Update to JupyterLab v${LATEST}" \ | |
-m "New JupyterLab release [v${LATEST}](https://github.com/jupyterlab/jupyterlab/releases/tag/v${LATEST}) is available. Please review the lock file carefully.". | |
fi |