Skip to content

Add pkg.pr.new workflow #7412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 25 additions & 55 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -439,20 +439,19 @@ jobs:
name: lib-ocaml
path: lib/ocaml

package:
needs:
- build-compiler
pkg-pr-new:
needs:
- build-rewatch

- build-compiler
runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: yarn
node-version-file: .nvmrc

- name: Download artifacts
Expand All @@ -464,34 +463,13 @@ jobs:
run: .github/workflows/moveArtifacts.sh
shell: bash

- name: Check artifact list
run: node ./scripts/npmPack.js

- name: yarn pack @rescript/* subpackages
run: yarn workspaces foreach -W --no-private --exclude rescript pack

- name: Prepare package upload
# For pull requests, pass the correct commit SHA explicitly as GITHUB_SHA points to the wrong commit.
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}

- name: "Upload artifact: npm packages"
uses: actions/upload-artifact@v4
with:
name: npm-packages
path: |
rescript-${{ env.rescript_version }}.tgz
rescript-std-${{ env.rescript_version }}.tgz
rescript-linux-x64-${{ env.rescript_version }}.tgz
rescript-linux-arm64-${{ env.rescript_version }}.tgz
rescript-darwin-x64-${{ env.rescript_version }}.tgz
rescript-darwin-arm64-${{ env.rescript_version }}.tgz
rescript-win32-x64-${{ env.rescript_version }}.tgz

outputs:
rescript_version: ${{ env.rescript_version }}
- name: Publish packages to pkg.pr.new
run: |
yarn dlx pkg-pr-new publish "." "./packages/@rescript/*"

installationTest:
needs: package
needs:
- pkg-pr-new
strategy:
fail-fast: false
matrix:
Expand All @@ -506,11 +484,10 @@ jobs:
node-target: linux-arm64
- os: windows-latest
node-target: win32-x64

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Use Node.js
Expand All @@ -531,17 +508,11 @@ jobs:
echo "path=$dir" >> "$GITHUB_OUTPUT"
cp -r tests/package_tests/installation_test/* "$dir"

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: npm-packages
path: ${{ steps.tmp-dir.outputs.path }}

- name: Install ReScript package
run: |
npm i --ignore-scripts --no-audit \
rescript-${{ needs.package.outputs.rescript_version }}.tgz \
rescript-${{ matrix.node-target }}-${{ needs.package.outputs.rescript_version }}.tgz
COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}"
npm i --no-audit \
"https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}"
shell: bash
working-directory: ${{ steps.tmp-dir.outputs.path }}

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

publish:
needs: [package, installationTest]

needs:
- build-rewatch
- build-compiler
- installationTest
if: startsWith(github.ref, 'refs/tags/v')

runs-on: ubuntu-24.04-arm

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -571,19 +542,18 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: npm-packages
pattern: "@(binaries-*|rewatch-*|lib-ocaml)"

- name: Move artifacts into packages
run: .github/workflows/moveArtifacts.sh
shell: bash

- name: Publish packages on npm with tag "ci"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
run: |
npm publish --tag ci rescript-${{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-std-${{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-linux-x64-${{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-linux-arm64-${{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-darwin-x64-${{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-darwin-arm64-{{ needs.package.outputs.rescript_version }}.tgz
npm publish --tag ci rescript-win32-x64-${{ needs.package.outputs.rescript_version }}.tgz
yarn workspaces foreach -W --no-private \
npm publish --tag ci

- name: Update Website Playground
env:
Expand Down
33 changes: 12 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,33 +395,24 @@ To build a new version and release it on NPM, follow these steps:

## Debugging issues from CI builds

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

1. Go to [Actions CI for master](https://github.com/rescript-lang/rescript-compiler/actions/workflows/ci.yml?query=branch%3Amaster)
- If you need a specific branch, select a different one to filter to in the GitHub UI.
1. Select a specific run (likely the latest)
1. Under "Artifacts", download the `npm-packages` artifact and extract it to a folder.
1. In your repository run:
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.

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

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.
```bash
# Use NPM
npm i "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"

```
{
"resolutions": {
"@rescript/linux-x64": "<path_to_download>/npm-packages/rescript-linux-x64.tgz",
"@rescript/linux-arm64": "<path_to_download>/npm-packages/rescript-linux-arm64.tgz",
"@rescript/darwin-x64": "<path_to_download>/npm-packages/rescript-darwin-x64.tgz",
"@rescript/darwin-arm64": "<path_to_download>/npm-packages/rescript-darwin-arm64.tgz",
"@rescript/win32-x64": "<path_to_download>/npm-packages/rescript-win32-x64.tgz"
}
}
# Use Yarn
yarn add "rescript@https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"

# Use pnpm
pnpm add "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}"
```

1. Then attempt to rebuild your project as you would normally.
Then attempt to rebuild your project as you would normally.

## Contribution Licensing

Expand Down