Skip to content

Commit

Permalink
Improve update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Dec 21, 2024
1 parent 0d49b45 commit 8aadd90
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/upgrade-jupyterlab-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
default: main
required: false
type: string
target_repo:
description: 'Target repository'
required: false
default: jupyter/notebook
type: string

env:
version_tag: 'latest'
Expand Down Expand Up @@ -70,11 +75,14 @@ jobs:
if [[ ! -z "$(git status --porcelain package.json)" ]]; then
jlpm install
jlpm deduplicate
cd ui-tests
jlpm install
fi
- name: Create a PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
run: |
set -eux
Expand All @@ -95,9 +103,18 @@ jobs:
git commit . -m "Update to JupyterLab v${LATEST}"
git push --set-upstream origin "${BRANCH_NAME}"
gh pr create \
--base ${{ inputs.branch || 'main' }} \
--title "Update to JupyterLab v${LATEST}" \
PR_ARGS=(
--base "${{ inputs.branch || 'main' }}"
--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."
)
# Add --repo flag only if target_repo is specified
if [[ -n "${{ inputs.target_repo }}" ]]; then
PR_ARGS+=(--repo "${{ inputs.target_repo }}")
fi
gh pr create "${PR_ARGS[@]}"
fi
fi
11 changes: 11 additions & 0 deletions buildutils/src/upgrade-lab-dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const PACKAGE_JSON_PATHS: string[] = [
'packages/tree-extension/package.json',
'packages/tree/package.json',
'packages/ui-components/package.json',
'ui-tests/package.json',
];

const DEPENDENCY_GROUP = '@jupyterlab';
Expand Down Expand Up @@ -78,7 +79,16 @@ async function updatePackageJson(newVersion: string): Promise<void> {
throw new Error(errorMessage);
}

// fetch the new galata version
const galataUrl = `https://raw.githubusercontent.com/jupyterlab/jupyterlab/v${newVersion}/galata/package.json`;
const galataResponse = await fetch(galataUrl);
if (!galataResponse.ok) {
const errorMessage = `Failed to fetch galata/package.json from ${galataUrl}. HTTP status code: ${galataResponse.status}`;
throw new Error(errorMessage);
}

const newPackageJson = await response.json();
const galataPackageJson = await galataResponse.json();

for (const packageJsonPath of PACKAGE_JSON_PATHS) {
const filePath: string = path.resolve(packageJsonPath);
Expand All @@ -87,6 +97,7 @@ async function updatePackageJson(newVersion: string): Promise<void> {
const newDependencies = {
...newPackageJson.devDependencies,
...newPackageJson.resolutions,
'@jupyterlab/galata': galataPackageJson.version,
};

updateDependencyVersion(existingPackageJson, newDependencies);
Expand Down

0 comments on commit 8aadd90

Please sign in to comment.