From dc3d11cd27d0f41b80dec38adf5449aa53d80fb3 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 00:55:00 +0900 Subject: [PATCH 1/9] Add pkg.pr.new workflow --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4beafce16..4cdf30faf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -550,13 +550,37 @@ jobs: shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} - publish: + publish-pr: needs: [package, installationTest] + if: github.event_name == 'pull_request' + runs-on: ubuntu-24.04-arm + steps: + - name: Checkout + uses: actions/checkout@v4 - if: startsWith(github.ref, 'refs/tags/v') + - name: Use Node.js + uses: actions/setup-node@v4 + with: + cache: yarn + node-version-file: .nvmrc - runs-on: ubuntu-24.04-arm + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: npm-packages + + - name: Move artifacts into packages + run: .github/workflows/moveArtifacts.sh + shell: bash + - name: Publish packages to pkg.pr.new + run: | + yarn dlx pkg-pr-new publish "." "./packages/@rescript/*" + + publish: + needs: [package, installationTest] + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-24.04-arm steps: - name: Checkout uses: actions/checkout@v4 From 36eecb1df73044447e6c88247b208d7c00d34538 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 01:01:10 +0900 Subject: [PATCH 2/9] fix artifacts source --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cdf30faf0..0c45f583ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -567,7 +567,7 @@ 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 From edf2ac5cad644d6859f6b92ec0470b0cbb607b41 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 02:40:03 +0900 Subject: [PATCH 3/9] update CONTRIBUTING.md --- CONTRIBUTING.md | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 960f78d4ef..9862d5b24e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 /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": "/npm-packages/rescript-linux-x64.tgz", - "@rescript/linux-arm64": "/npm-packages/rescript-linux-arm64.tgz", - "@rescript/darwin-x64": "/npm-packages/rescript-darwin-x64.tgz", - "@rescript/darwin-arm64": "/npm-packages/rescript-darwin-arm64.tgz", - "@rescript/win32-x64": "/npm-packages/rescript-win32-x64.tgz" - } -} +# Use Yarn +yarn add "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 From 0929b3eb440cb0fd13fcb350699daabcd2397e58 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 03:24:53 +0900 Subject: [PATCH 4/9] completely remove npm-pacakges --- .github/workflows/ci.yml | 96 ++++++++-------------------------------- 1 file changed, 18 insertions(+), 78 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c45f583ef..00c729ce7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -439,13 +439,10 @@ jobs: name: lib-ocaml path: lib/ocaml - package: - needs: - - build-compiler - - build-rewatch - + pkg-pr-new: + needs: [build-rewatch, build-compiler] + if: github.event_name == 'pull_request' runs-on: ubuntu-24.04-arm - steps: - name: Checkout uses: actions/checkout@v4 @@ -453,6 +450,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: + cache: yarn node-version-file: .nvmrc - name: Download artifacts @@ -464,34 +462,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] + if: github.event_name == 'pull_request' strategy: fail-fast: false matrix: @@ -506,9 +483,7 @@ jobs: node-target: linux-arm64 - os: windows-latest node-target: win32-x64 - runs-on: ${{ matrix.os }} - steps: - name: Checkout uses: actions/checkout@v4 @@ -531,17 +506,10 @@ 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="$(git rev-parse --short HEAD)" + npm i --no-audit "https://pkg.pr.new/rescript-lang/rescript@$COMMIT_SHA" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} @@ -550,9 +518,9 @@ jobs: shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} - publish-pr: - needs: [package, installationTest] - if: github.event_name == 'pull_request' + publish: + needs: [build-rewatch, build-compiler] + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -563,6 +531,7 @@ jobs: with: cache: yarn node-version-file: .nvmrc + registry-url: https://registry.npmjs.org # Needed to make auth work for publishing - name: Download artifacts uses: actions/download-artifact@v4 @@ -573,41 +542,12 @@ jobs: run: .github/workflows/moveArtifacts.sh shell: bash - - name: Publish packages to pkg.pr.new - run: | - yarn dlx pkg-pr-new publish "." "./packages/@rescript/*" - - publish: - needs: [package, installationTest] - if: startsWith(github.ref, 'refs/tags/v') - 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 - registry-url: https://registry.npmjs.org # Needed to make auth work for publishing - - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: npm-packages - - 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: From eb45ca1355a58149076c585f9c7e9a2003ef1f77 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 03:28:57 +0900 Subject: [PATCH 5/9] allow pkg-pr-new on master --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00c729ce7e..aeb9a5f84a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -440,8 +440,9 @@ jobs: path: lib/ocaml pkg-pr-new: - needs: [build-rewatch, build-compiler] - if: github.event_name == 'pull_request' + needs: + - build-rewatch + - build-compiler runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -467,8 +468,8 @@ jobs: yarn dlx pkg-pr-new publish "." "./packages/@rescript/*" installationTest: - needs: [pkg-pr-new] - if: github.event_name == 'pull_request' + needs: + - pkg-pr-new strategy: fail-fast: false matrix: @@ -519,7 +520,10 @@ jobs: working-directory: ${{ steps.tmp-dir.outputs.path }} publish: - needs: [build-rewatch, build-compiler] + needs: + - build-rewatch + - build-compiler + - installationTest if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-24.04-arm steps: From 5a8eaf97f8090efe9f0480a2a63d9645cb796317 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 03:40:02 +0900 Subject: [PATCH 6/9] fix retreiving short sha --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aeb9a5f84a..7e29aec8c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -487,6 +487,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Checkout + id: checkout uses: actions/checkout@v4 - name: Use Node.js @@ -509,8 +510,8 @@ jobs: - name: Install ReScript package run: | - COMMIT_SHA="$(git rev-parse --short HEAD)" - npm i --no-audit "https://pkg.pr.new/rescript-lang/rescript@$COMMIT_SHA" + COMMIT_SHA="${{ steps.checkout.outputs.commit }}" + npm i --no-audit "https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} From 2b45e055e6525a43382a4531ac7c083910a60d01 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 04:37:16 +0900 Subject: [PATCH 7/9] why not --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e29aec8c6..979cf1e6eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -510,8 +510,8 @@ jobs: - name: Install ReScript package run: | - COMMIT_SHA="${{ steps.checkout.outputs.commit }}" - npm i --no-audit "https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}" + npm i --no-audit \ + "https://pkg.pr.new/rescript-lang/rescript@${GITHUB_SHA::7}" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} From 999f664a55cc62caefc42c585b16f14103178171 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 04:42:50 +0900 Subject: [PATCH 8/9] well, ChatGPT said --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 979cf1e6eb..7c1c4828a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -510,8 +510,9 @@ jobs: - name: Install ReScript package run: | + COMMIT_SHA="${{ github.event.pull_request.head.sha || github.sha }}" npm i --no-audit \ - "https://pkg.pr.new/rescript-lang/rescript@${GITHUB_SHA::7}" + "https://pkg.pr.new/rescript-lang/rescript@${COMMIT_SHA::7}" shell: bash working-directory: ${{ steps.tmp-dir.outputs.path }} From 4eb3bc06543bb1026991f752a339aeda2a78310f Mon Sep 17 00:00:00 2001 From: Hyeseong Kim Date: Thu, 1 May 2025 17:22:47 +0900 Subject: [PATCH 9/9] Update CONTRIBUTING.md Co-authored-by: Christoph Knittel --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9862d5b24e..6613c99474 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -406,7 +406,7 @@ Follow the instructions from the comment, which are like: npm i "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}" # Use Yarn -yarn add "https://pkg.pr.new/rescript-lang/rescript@${PR_NUMBER}" +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}"