Skip to content

Commit 9a8f133

Browse files
cometkimcknitt
andauthored
Add pkg.pr.new workflow (#7412)
* Add pkg.pr.new workflow * fix artifacts source * update CONTRIBUTING.md * completely remove npm-pacakges * allow pkg-pr-new on master * Update CONTRIBUTING.md --------- Co-authored-by: Christoph Knittel <[email protected]>
1 parent b9bff84 commit 9a8f133

File tree

2 files changed

+37
-76
lines changed

2 files changed

+37
-76
lines changed

.github/workflows/ci.yml

+25-55
Original file line numberDiff line numberDiff line change
@@ -439,20 +439,19 @@ jobs:
439439
name: lib-ocaml
440440
path: lib/ocaml
441441

442-
package:
443-
needs:
444-
- build-compiler
442+
pkg-pr-new:
443+
needs:
445444
- build-rewatch
446-
445+
- build-compiler
447446
runs-on: ubuntu-24.04-arm
448-
449447
steps:
450448
- name: Checkout
451449
uses: actions/checkout@v4
452450

453451
- name: Use Node.js
454452
uses: actions/setup-node@v4
455453
with:
454+
cache: yarn
456455
node-version-file: .nvmrc
457456

458457
- name: Download artifacts
@@ -464,34 +463,13 @@ jobs:
464463
run: .github/workflows/moveArtifacts.sh
465464
shell: bash
466465

467-
- name: Check artifact list
468-
run: node ./scripts/npmPack.js
469-
470-
- name: yarn pack @rescript/* subpackages
471-
run: yarn workspaces foreach -W --no-private --exclude rescript pack
472-
473-
- name: Prepare package upload
474-
# For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
475-
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
476-
477-
- name: "Upload artifact: npm packages"
478-
uses: actions/upload-artifact@v4
479-
with:
480-
name: npm-packages
481-
path: |
482-
rescript-${{ env.rescript_version }}.tgz
483-
rescript-std-${{ env.rescript_version }}.tgz
484-
rescript-linux-x64-${{ env.rescript_version }}.tgz
485-
rescript-linux-arm64-${{ env.rescript_version }}.tgz
486-
rescript-darwin-x64-${{ env.rescript_version }}.tgz
487-
rescript-darwin-arm64-${{ env.rescript_version }}.tgz
488-
rescript-win32-x64-${{ env.rescript_version }}.tgz
489-
490-
outputs:
491-
rescript_version: ${{ env.rescript_version }}
466+
- name: Publish packages to pkg.pr.new
467+
run: |
468+
yarn dlx pkg-pr-new publish "." "./packages/@rescript/*"
492469
493470
installationTest:
494-
needs: package
471+
needs:
472+
- pkg-pr-new
495473
strategy:
496474
fail-fast: false
497475
matrix:
@@ -506,11 +484,10 @@ jobs:
506484
node-target: linux-arm64
507485
- os: windows-latest
508486
node-target: win32-x64
509-
510487
runs-on: ${{ matrix.os }}
511-
512488
steps:
513489
- name: Checkout
490+
id: checkout
514491
uses: actions/checkout@v4
515492

516493
- name: Use Node.js
@@ -531,17 +508,11 @@ jobs:
531508
echo "path=$dir" >> "$GITHUB_OUTPUT"
532509
cp -r tests/package_tests/installation_test/* "$dir"
533510
534-
- name: Download artifacts
535-
uses: actions/download-artifact@v4
536-
with:
537-
name: npm-packages
538-
path: ${{ steps.tmp-dir.outputs.path }}
539-
540511
- name: Install ReScript package
541512
run: |
542-
npm i --ignore-scripts --no-audit \
543-
rescript-${{ needs.package.outputs.rescript_version }}.tgz \
544-
rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz
513+
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
514+
npm i --no-audit \
515+
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}"
545516
shell: bash
546517
working-directory: ${{ steps.tmp-dir.outputs.path }}
547518

@@ -551,12 +522,12 @@ jobs:
551522
working-directory: ${{ steps.tmp-dir.outputs.path }}
552523

553524
publish:
554-
needs: [package, installationTest]
555-
525+
needs:
526+
- build-rewatch
527+
- build-compiler
528+
- installationTest
556529
if: startsWith(github.ref, 'refs/tags/v')
557-
558530
runs-on: ubuntu-24.04-arm
559-
560531
steps:
561532
- name: Checkout
562533
uses: actions/checkout@v4
@@ -571,19 +542,18 @@ jobs:
571542
- name: Download artifacts
572543
uses: actions/download-artifact@v4
573544
with:
574-
name: npm-packages
545+
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"
546+
547+
- name: Move artifacts into packages
548+
run: .github/workflows/moveArtifacts.sh
549+
shell: bash
575550

576551
- name: Publish packages on npm with tag "ci"
577552
env:
578-
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
553+
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
579554
run: |
580-
npm publish --tag ci rescript-${{ needs.package.outputs.rescript_version }}.tgz
581-
npm publish --tag ci rescript-std-${{ needs.package.outputs.rescript_version }}.tgz
582-
npm publish --tag ci rescript-linux-x64-${{ needs.package.outputs.rescript_version }}.tgz
583-
npm publish --tag ci rescript-linux-arm64-${{ needs.package.outputs.rescript_version }}.tgz
584-
npm publish --tag ci rescript-darwin-x64-${{ needs.package.outputs.rescript_version }}.tgz
585-
npm publish --tag ci rescript-darwin-arm64-{{ needs.package.outputs.rescript_version }}.tgz
586-
npm publish --tag ci rescript-win32-x64-${{ needs.package.outputs.rescript_version }}.tgz
555+
yarn workspaces foreach -W --no-private \
556+
npm publish --tag ci
587557
588558
- name: Update Website Playground
589559
env:

CONTRIBUTING.md

+12-21
Original file line numberDiff line numberDiff line change
@@ -395,33 +395,24 @@ To build a new version and release it on NPM, follow these steps:
395395

396396
## Debugging issues from CI builds
397397

398-
To reproduce issues, it can be helpful to the team to install a specific version of the compiler. To do so:
398+
To reproduce issues, it can be helpful to the team to install a specific version of the compiler.
399399

400-
1. Go to [Actions CI for master](https://github.com/rescript-lang/rescript-compiler/actions/workflows/ci.yml?query=branch%3Amaster)
401-
- If you need a specific branch, select a different one to filter to in the GitHub UI.
402-
1. Select a specific run (likely the latest)
403-
1. Under "Artifacts", download the `npm-packages` artifact and extract it to a folder.
404-
1. In your repository run:
400+
ReScript uses [pkg.pr.new](https://github.com/stackblitz-labs/pkg.pr.new) for continuous releases. Once tests are passed successfully, the bot comment is available.
405401

406-
```console
407-
npm i <path_to_download>/npm-packages/rescript-*.tgz
408-
```
402+
Follow the instructions from the comment, which are like:
409403

410-
If you use Yarn or pnpm, you should override platform package resolutions by [`resolutions`](https://yarnpkg.com/configuration/manifest#resolutions) in Yarn or [`overrides`](https://pnpm.io/settings#overrides) in Pnpm.
404+
```bash
405+
# Use NPM
406+
npm i "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"
411407

412-
```
413-
{
414-
"resolutions": {
415-
"@rescript/linux-x64": "<path_to_download>/npm-packages/rescript-linux-x64.tgz",
416-
"@rescript/linux-arm64": "<path_to_download>/npm-packages/rescript-linux-arm64.tgz",
417-
"@rescript/darwin-x64": "<path_to_download>/npm-packages/rescript-darwin-x64.tgz",
418-
"@rescript/darwin-arm64": "<path_to_download>/npm-packages/rescript-darwin-arm64.tgz",
419-
"@rescript/win32-x64": "<path_to_download>/npm-packages/rescript-win32-x64.tgz"
420-
}
421-
}
408+
# Use Yarn
409+
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"
410+
411+
# Use pnpm
412+
pnpm add "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"
422413
```
423414

424-
1. Then attempt to rebuild your project as you would normally.
415+
Then attempt to rebuild your project as you would normally.
425416

426417
## Contribution Licensing
427418

0 commit comments

Comments
 (0)