diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5d266eb..c6d08393 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,6 @@ on: permissions: contents: read - pages: write - id-token: write jobs: build: @@ -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 @@ -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 - - 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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..407b5389 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,68 @@ +name: Release + +on: + pull_request: + branches: + - main + workflow_dispatch: + 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 + 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" + 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 - + 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 + run: npm publish ./rescript-webapi-*.tgz --access public --tag alpha diff --git a/README.md b/README.md index 18f37ad5..d19fa525 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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`: diff --git a/docs/content/docs/index.mdx b/docs/content/docs/index.mdx index 19242735..d02839a2 100644 --- a/docs/content/docs/index.mdx +++ b/docs/content/docs/index.mdx @@ -19,7 +19,7 @@ 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 @@ -27,10 +27,10 @@ Install the package using your favorite package manager: - + - + diff --git a/docs/llm.js b/docs/llm.js index 045342da..4e957660 100644 --- a/docs/llm.js +++ b/docs/llm.js @@ -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}.