diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 952c86525..4ac753d3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,17 +84,25 @@ jobs: python setup.py sdist bdist_wheel - name: Build npm distributions run: | + mkdir pkgs jlpm lerna exec -- npm pack - cp packages/*/*.tgz dist + cp packages/*/*.tgz pkgs - name: Build checksum file run: | cd dist sha256sum * | tee SHA256SUMS + cd ../pkgs + sha256sum * | tee SHA256SUMS - name: Upload distributions uses: actions/upload-artifact@v2 with: name: dist ${{ github.run_number }} path: ./dist + - name: Upload distributions + uses: actions/upload-artifact@v2 + with: + name: pkgs ${{ github.run_number }} + path: ./pkgs install: runs-on: ${{ matrix.os }}-latest diff --git a/.github/workflows/buildutils.yml b/.github/workflows/buildutils.yml index 0dc761a75..073ea60bc 100644 --- a/.github/workflows/buildutils.yml +++ b/.github/workflows/buildutils.yml @@ -11,7 +11,7 @@ defaults: shell: bash -l {0} jobs: - scripts: + versioning: runs-on: ubuntu-latest steps: - name: Checkout @@ -59,3 +59,25 @@ jobs: - name: Major Release run: | jlpm release:bump major --force + + npm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + architecture: 'x64' + - name: Install dependencies + run: | + python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip + jlpm + jlpm run build + - name: Publish to npm in dry-run mode + run: | + mkdir dist + jlpm lerna exec -- npm pack + cp packages/*/*.tgz dist + jlpm release:npm --dist ./dist --dry-run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d660606eb..3dd94e9a6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,17 +84,25 @@ jobs: python setup.py sdist bdist_wheel - name: Build npm distributions run: | + mkdir pkgs jlpm lerna exec -- npm pack - cp packages/*/*.tgz dist + cp packages/*/*.tgz pkgs - name: Build checksum file run: | cd dist sha256sum * | tee SHA256SUMS + cd ../pkgs + sha256sum * | tee SHA256SUMS - name: Upload distributions uses: actions/upload-artifact@v2 with: name: dist ${{ github.run_number }} path: ./dist + - name: Upload distributions + uses: actions/upload-artifact@v2 + with: + name: pkgs ${{ github.run_number }} + path: ./pkgs install: runs-on: ${{ matrix.os }}-latest @@ -156,29 +164,39 @@ jobs: - uses: actions/download-artifact@v2 with: name: dist ${{ github.run_number }} - path: ./tmp - - name: Copy to ./dist + path: ./dist + - name: Cleanup dist run: | - mkdir dist/ - cp ./tmp/jupyterlab-classic*.tar.gz ./tmp/jupyterlab_classic*.whl dist - ls dist + rm dist/SHA256SUMS - name: Publish a Python distribution to PyPI uses: pypa/gh-action-pypi-publish@master with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} - skip_existing: true + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + architecture: 'x64' + - name: Install dependencies + run: | + python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9 pip + jlpm + jlpm run build - uses: actions/setup-node@v2 with: node-version: '14.x' registry-url: 'https://registry.npmjs.org' + - uses: actions/download-artifact@v2 + with: + name: pkgs ${{ github.run_number }} + path: ./pkgs - name: Publish to npm env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} - # jlpm - # jlpm run lerna publish from-package --yes --registry "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" + jlpm release:npm --dist ./pkgs - name: Get the current tag id: current_tag run: | diff --git a/buildutils/src/release-npm.ts b/buildutils/src/release-npm.ts new file mode 100644 index 000000000..108f31414 --- /dev/null +++ b/buildutils/src/release-npm.ts @@ -0,0 +1,29 @@ +import { readdirSync } from 'fs'; + +import { resolve } from 'path'; + +import { run } from '@jupyterlab/buildutils'; + +import commander from 'commander'; + +commander + .description('Publish packages to npm') + .option( + '--dist ', + 'The path to the directory with the package tarballs' + ) + .option('--dry-run', 'Run in dry-run mode') + .action((options: any) => { + const dryRun = options.dryRun ?? false; + const distDir = resolve(options.dist); + const files = readdirSync(distDir); + files.forEach(file => { + if (!file.endsWith('.tgz')) { + return; + } + const tarball = resolve(distDir, file); + run(`npm publish ${tarball} ${dryRun ? '--dry-run' : ''}`); + }); + }); + +commander.parse(process.argv); diff --git a/package.json b/package.json index a3861302c..750c843a9 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "prettier:check": "prettier --list-different \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", "publish": "yarn run clean && yarn run build && lerna publish", "release:bump": "node ./buildutils/lib/release-bump.js", + "release:npm": "node ./buildutils/lib/release-npm.js", "release:patch": "node ./buildutils/lib/release-patch.js", "test": "lerna run test", "update:dependency": "node ./node_modules/@jupyterlab/buildutils/lib/update-dependency.js --lerna"