Skip to content
Open
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
43 changes: 4 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ on:

permissions:
contents: read
pages: write
id-token: write

jobs:
build:
Expand All @@ -24,8 +22,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
registry-url: https://registry.npmjs.org # Needed to make auth work for publishing
node-version: "24"

- name: Install dependencies
run: npm ci
Expand All @@ -51,44 +48,12 @@ jobs:
with:
path: ./dist

- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1

- name: Get short commit hash
id: vars
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Update package version to -<commit-hash>
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-experimental-${{ env.COMMIT_HASH }}
run: |
node <<'NODE'
const fs = require("node:fs");
const packageJsonPath = "package.json";
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
packageJson.version = process.env.PACKAGE_VERSION;
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
NODE

- name: Package npm package
run: npm pack

- name: Upload npm package artifact
uses: actions/upload-artifact@v7
with:
name: npm-packages
path: "*.tgz"

- name: Publish npm package
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
run: npm publish --access public --tag experimental

deploy-docs:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Release

on:
pull_request:
branches:
- main
workflow_dispatch:
Comment on lines +3 to +7

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Trigger alpha publishing after main pushes

This workflow is triggered only for pull requests and manual dispatches. Since the same change removes the publishing steps from the main-push CI workflow, merging to main no longer publishes the commit-specific alpha release; releases occur only when someone manually dispatches this workflow, contrary to the restored main-branch release flow.

Useful? React with 👍 / 👎.

inputs:
dry_run:
description: Run npm publish without publishing the package
required: true
default: true
type: boolean

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
Comment on lines +19 to +20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate real publishes on successful validation

This standalone publish job installs dependencies and immediately packages the selected commit without running the repository's formatting, build, feature, test, or documentation checks, and it has no dependency on the CI workflow. A manual run with dry_run=false can therefore publish an alpha while CI is still running or after it has failed; run the validation steps here or trigger publishing only from a successful CI run.

Useful? React with 👍 / 👎.

permissions:
contents: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v7

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: "24"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Install an npm version that supports trusted publishing

node-version: "24" constrains Node.js but does not guarantee a compatible npm CLI. This workflow removes NODE_AUTH_TOKEN and relies entirely on npm trusted publishing, which requires npm 11.5.1 or later; with an older bundled npm, such as npm 11.4.2 in the inspected Node 24.15.0 toolchain, npm publish does not exchange the OIDC token and exits with ENEEDAUTH. Explicitly install or pin a supported npm version before publishing.

Useful? React with 👍 / 👎.

registry-url: https://registry.npmjs.org
package-manager-cache: false

- name: Install dependencies
run: npm ci

- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1

- name: Get short commit hash
id: vars
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Update package version to -<commit-hash>
env:
PACKAGE_VERSION: ${{ steps.package-version.outputs.current-version }}-alpha-${{ env.COMMIT_HASH }}
run: |
node <<'NODE'
const fs = require("node:fs");
const packageJsonPath = "package.json";
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
packageJson.version = process.env.PACKAGE_VERSION;
fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`);
NODE

- name: Package npm package
run: npm pack

- name: Dry-run npm publish
if: github.event_name == 'pull_request' || inputs.dry_run
run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha --dry-run

- name: Publish npm package
if: github.event_name == 'workflow_dispatch' && !inputs.dry_run

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restrict manual publishing to the main branch

When a caller dispatches this workflow with dry_run=false, they can select a feature-branch or tag ref, and checkout will package that selected ref. Because this condition checks only the event and input, such a run publishes that non-main code under the shared alpha tag; add an explicit main-ref restriction if releases are intended to remain main-branch-only.

Useful? React with 👍 / 👎.

run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![NPM Version](https://img.shields.io/npm/v/@rescript/webapi/experimental)](https://www.npmjs.com/package/@rescript/webapi)
[![NPM Version](https://img.shields.io/npm/v/@rescript/webapi/alpha)](https://www.npmjs.com/package/@rescript/webapi)

# experimental-rescript-webapi

Expand All @@ -9,7 +9,7 @@ Experimental successor to [rescript-webapi](https://github.com/TheSpyder/rescrip
Install the package using your favorite package manager:

```shell
npm i @rescript/webapi@experimental
npm i @rescript/webapi@alpha
```

and add `@rescript/webapi` to your `rescript.json`:
Expand Down
6 changes: 3 additions & 3 deletions docs/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ tableOfContents: false

import { Tabs, TabItem, Code } from "@astrojs/starlight/components";

[![NPM Version](https://img.shields.io/npm/v/@rescript/webapi/experimental)](https://www.npmjs.com/package/@rescript/webapi)
[![NPM Version](https://img.shields.io/npm/v/@rescript/webapi/alpha)](https://www.npmjs.com/package/@rescript/webapi)

## Installation

Install the package using your favorite package manager:

<Tabs syncKey="package manager">
<TabItem label="npm">
<Code lang="shell" frame="none" code="npm i @rescript/webapi@experimental" />
<Code lang="shell" frame="none" code="npm i @rescript/webapi@alpha" />
</TabItem>
<TabItem label="bun">
<Code lang="shell" frame="none" code="bun i @rescript/webapi@experimental" />
<Code lang="shell" frame="none" code="bun i @rescript/webapi@alpha" />
</TabItem>
</Tabs>

Expand Down
4 changes: 2 additions & 2 deletions docs/llm.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ files.sort();

const pages = await Promise.all(files.map(processFile));
const packageJson = await fs.readFile(path.join(import.meta.dirname, "../package.json"), "utf-8");
let version = JSON.parse(packageJson).version;
const version = JSON.parse(packageJson).version;
const sha = await execAsync("git rev-parse --short HEAD").then(({ stdout }) => stdout.trim());
const fullVersion = `${version}-experimental-${sha}`;
const fullVersion = `${version}-alpha-${sha}`;
const header = `Experimental ReScript WebAPI Documentation ${fullVersion}

This is the API documentation for the experimental WebAPI module version ${fullVersion}.
Expand Down