From 5c6928cdbb147b945c2d1179bb01df45c9a2ebb6 Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Tue, 25 May 2021 13:17:40 +0100 Subject: [PATCH] Use Jupyter releaser --- .github/workflows/tests.yml | 52 +++++++++++++++++++++++++-- .gitignore | 2 ++ CHANGELOG.md | 11 +++--- CONTRIBUTING.md | 2 +- RELEASE.md | 21 +++++++++-- package.json | 16 +++++++-- packages/datagrid/src/textrenderer.ts | 8 ++--- scripts/format-changelog.js | 41 +++++++++++++++++++++ scripts/tag-versions.js | 16 +++++++++ 9 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 scripts/format-changelog.js create mode 100644 scripts/tag-versions.js diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 24e52d669..00f656909 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,12 +69,60 @@ jobs: if: ${{ matrix.os == 'ubuntu-latest' }} run: | set -eux - git checkout -b release npm install -g verdaccio verdaccio --config .github/scripts/verdaccio.yml & npm set registry http://localhost:4873/ yarn config set registry http://localhost:4873/ git config --global user.email "you@example.com" git config --global user.name "Your Name" - yarn run version patch --no-push --yes + yarn run update:versions patch --yes + git commit -a -m "Update versions" yarn run publish + + check_release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Node + uses: actions/setup-node@v1 + with: + node-version: '14.x' + + # Cache yarn + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Cache yarn + uses: actions/cache@v2 + id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + shell: bash + run: | + set -eux + npm install -g yarn + yarn + + - name: Cache checked links + uses: actions/cache@v2 + with: + path: ~/.cache/pytest-link-check + key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links + restore-keys: | + ${{ runner.os }}-linkcheck- + + - name: Install Dependencies + run: | + yarn + + - name: Check Release + uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index efd4a3ac2..963051068 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ docs/api *.code-workspace .history .vscode + +.jupyter_releaser_checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index d1db0026a..5e19ee2d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog + + ## 2021-5-20 ([Full Changelog](https://github.com/jupyterlab/lumino/compare/2021.5.10...e2b775392b42e98d5c58b9afdc74e92b1631739b)) @@ -20,13 +22,14 @@ - Fix changelog formatting for 2021-5-10 entry [#185](https://github.com/jupyterlab/lumino/pull/185) ([@blink1073](https://github.com/blink1073)) - Add changelog entry for 2021.5.10 [#184](https://github.com/jupyterlab/lumino/pull/184) ([@blink1073](https://github.com/blink1073)) - ### Contributors to this release ([GitHub contributors page for this release](https://github.com/jupyterlab/lumino/graphs/contributors?from=2021-05-10&to=2021-05-20&type=c)) [@blink1073](https://github.com/search?q=repo%3Ajupyterlab%2Flumino+involves%3Ablink1073+updated%3A2021-05-10..2021-05-20&type=Issues) | [@dependabot](https://github.com/search?q=repo%3Ajupyterlab%2Flumino+involves%3Adependabot+updated%3A2021-05-10..2021-05-20&type=Issues) | [@ibdafna](https://github.com/search?q=repo%3Ajupyterlab%2Flumino+involves%3Aibdafna+updated%3A2021-05-10..2021-05-20&type=Issues) + + ## 2021-5-10 ([Full Changelog](https://github.com/jupyterlab/lumino/compare/2021.4.27...f8466b274fe801bb06931572893fb938808eb2b8)) @@ -428,8 +431,8 @@ @lumino/application@1.10.1 @lumino/algorithm@1.3.1 -- fix columnCount signature [#82](https://github.com/jupyterlab/lumino/pull/82) ([@mbektasbbg](https://github.com/mbektasbbg)) -- unsubscribe from grid wheel events on editor dispose [#80](https://github.com/jupyterlab/lumino/pull/80) ([@mbektasbbg](https://github.com/mbektasbbg)) +- fix columnCount signature [#82](https://github.com/jupyterlab/lumino/pull/82) ([@mbektas](https://github.com/mbektas)) +- unsubscribe from grid wheel events on editor dispose [#80](https://github.com/jupyterlab/lumino/pull/80) ([@mbektas](https://github.com/mbektas)) - chore(build): Bump Typescript to 3.9.2 [#75](https://github.com/jupyterlab/lumino/pull/75) ([@GordonSmith](https://github.com/GordonSmith)) ## 2020-5-23 @@ -582,7 +585,7 @@ - Remove 'sourceMap' from tsconfig in `@lumino/virtualdom` [#41](https://github.com/jupyterlab/lumino/pull/41) ([@zemeolotu](https://github.com/zemeolotu)) - Start a change log [#38](https://github.com/jupyterlab/lumino/pull/38) ([@blink1073](https://github.com/blink1073)) -- DataGrid Cell Editing [#14](https://github.com/jupyterlab/lumino/pull/14) ([@mbektasbbg](https://github.com/mbektasbbg)) +- DataGrid Cell Editing [#14](https://github.com/jupyterlab/lumino/pull/14) ([@mbektas](https://github.com/mbektas)) ## 2020-1-8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 582748c45..950e19dff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ Lumino is a subproject of Project Jupyter and subject to the [Jupyter governance ## General Guidelines -For general documentation about contributing to Jupyter projects, see the [Project Jupyter Contributor Documentation](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html). +For general documentation about contributing to Jupyter projects, see the [Project Jupyter Contributor Documentation](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html). ## Setting up a development environment diff --git a/RELEASE.md b/RELEASE.md index 8d889cb46..0cb73ae6d 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,5 +1,22 @@ # Release instructions for Lumino +## Using `jupyter_releaser` + +The recommended way to make a release is to use [`jupyter_releaser`](https://github.com/jupyter-server/jupyter_releaser#checklist-for-adoption). + +Because `lumino` uses independent versions, the versioning must be +done manually as follows: + +```bash +yarn +yarn run update:versions +git push origin +``` + +## Manual Release + +To create a manual release, perform the following steps: + Check for releases since the last published version to determine appropriate patch/minor/major version changes. If a dependent package moves by minor/major, then that package needs to jump @@ -8,8 +25,8 @@ minor/major as well. ```bash git clean -dfx yarn -yarn run version -# Update the changelog with published packages (minor or higher) and included PRs. +yarn run update:versions +# Update the changelog with changed packages (minor or higher) and included PRs. # Tag the release with the date, e.g. 2021.4.9 # yarn run publish diff --git a/package.json b/package.json index ca295aa97..8b78e4d93 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { - "version": "0.0.0", + "version": "2021.4.27", + "name": "lumino-top-level", "private": true, "workspaces": [ "examples/*", @@ -20,7 +21,7 @@ "docs": "rimraf docs/api && lerna run build:src --concurrency 1 && lerna run docs", "get:dependency": "get-dependency", "minimize": "lerna run minimize", - "publish": "npm run clean && npm run build:dist && lerna publish --yes -m \"Publish\" from-package", + "publish": "npm run clean && npm run build:dist && node scripts/tag-versions.js && lerna publish --yes -m \"Publish\" from-package", "remove:dependency": "remove-dependency", "test": "lerna run test --scope \"@lumino/!(example-)*\"", "test:examples": "lerna run test --scope \"@lumino/example-*\"", @@ -28,12 +29,21 @@ "test:firefox": "lerna run test:firefox", "test:ie": "lerna run test:ie --concurrency 1", "update:dependency": "update-dependency --lerna", - "version": "lerna version" + "update:versions": "lerna version --no-push --no-git-tag-version" }, "dependencies": {}, "devDependencies": { "@jupyterlab/buildutils": "^1.0.0", "lerna": "^3.19.0", "typedoc": "^0.20.32" + }, + "jupyter-releaser": { + "options": { + "ignore-links": ["./api/index.html"] + }, + "hooks": { + "after-build-changelog": "node scripts/format-changelog.js", + "before-build-npm": ["yarn build:dist", "node scripts/tag-versions.js"] + } } } diff --git a/packages/datagrid/src/textrenderer.ts b/packages/datagrid/src/textrenderer.ts index c2180acfe..f7dad7b63 100644 --- a/packages/datagrid/src/textrenderer.ts +++ b/packages/datagrid/src/textrenderer.ts @@ -263,8 +263,8 @@ class TextRenderer extends CellRenderer { } } } - - // Multiple words in column header. Fitting maximum + + // Multiple words in column header. Fitting maximum // number of words possible per line (box width). else { while (wordsInColumn.length !== 0) { @@ -282,7 +282,7 @@ class TextRenderer extends CellRenderer { gc.fillText(textInCurrentLine, textX, curY); curY += textHeight; textInCurrentLine = curWord!; - } + } else { // The combined text hasd a width less than the box width. We // set the the current line text to be the new combined text. @@ -310,7 +310,7 @@ class TextRenderer extends CellRenderer { text = text.substring(0, text.length - 2) + elide; } textWidth = gc.measureText(text).width; - } + } } else { while ((textWidth > boxWidth) && (text.length > 1)) { if (text.length > 4 && textWidth >= 2 * boxWidth) { diff --git a/scripts/format-changelog.js b/scripts/format-changelog.js new file mode 100644 index 000000000..f24131866 --- /dev/null +++ b/scripts/format-changelog.js @@ -0,0 +1,41 @@ +const path = require('path'); +const fs = require('fs'); +const utils = require('@jupyterlab/buildutils'); + +// Add version changes to the changelog entry +const package = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf-8' })); +const versions = []; + +let changelog = fs.readFileSync('CHANGELOG.md', { encoding: 'utf-8' }); +const firstIndex = changelog.indexOf(''); +const lastIndex = changelog.indexOf(''); +const entry = changelog.slice(firstIndex, lastIndex); + +// For each package, compare the local version to the published version +fs.readdirSync('packages').forEach(pkgName => { + const localPath = path.join('packages', pkgName, 'package.json'); + const localPackage = JSON.parse(fs.readFileSync(localPath, { encoding: 'utf-8' })); + const name = localPackage.name; + const version = localPackage.version; + const remoteVersion = utils.run(`npm info ${name} version`, { stdio: 'pipe' }, true); + if (version !== remoteVersion) { + versions.push(` ${name}: ${remoteVersion} => ${version}`); + } +}); + +// Splice the entry +if (versions) { + const lines = entry.split('\n'); + let index = -1; + lines.forEach((line, i) => { + if (line.startsWith('([Full Changelog]')) { + index = i + 1; + } + }); + if (index != -1) { + const newEntry = lines.slice(0, index).concat([''], versions, lines.slice(index, -1), ['']); + changelog = changelog.replace(entry, newEntry.join('\n')); + } +} + +fs.writeFileSync('CHANGELOG.md', changelog, { encoding: 'utf-8' }); diff --git a/scripts/tag-versions.js b/scripts/tag-versions.js new file mode 100644 index 000000000..0531e53c7 --- /dev/null +++ b/scripts/tag-versions.js @@ -0,0 +1,16 @@ +const path = require('path'); +const fs = require('fs'); +const utils = require('@jupyterlab/buildutils'); + +// Get the list of tags +const tags = utils.run('git tag', { stdio: 'pipe' }, true).split('\n'); + +// For each package, compare the local version to the published version +fs.readdirSync('packages').forEach(pkgName => { + const localPath = path.join('packages', pkgName, 'package.json'); + const localPackage = JSON.parse(fs.readFileSync(localPath, { encoding: 'utf-8' })); + const tag = `${localPackage.name}@${localPackage.version}`; + if (tags.indexOf(tag) === -1) { + utils.run(`git tag ${tag} -a -m "Release ${tag}"`) + } +});