Skip to content

1.3.0

1.3.0 #1

Workflow file for this run

name: Publish
on:
push:
tags:
- "*"
permissions:
contents: read
id-token: write
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 24
uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- name: Upgrade npm for trusted publishing
run: npm install --global npm@^11.5.1
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.3.1
- name: Validate release tag
id: version
run: |
version="$(node -p "require('./package.json').version")"
tag="${GITHUB_REF_NAME}"
if [ "$tag" != "$version" ] && [ "$tag" != "v$version" ]; then
echo "Tag '$tag' does not match package.json version '$version'." >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Determine npm dist-tag
id: dist_tag
run: |
node <<'NODE' >> "$GITHUB_OUTPUT"
const {version} = require("./package.json")
const prerelease = version.split("-")[1]
const distTag = prerelease ? prerelease.split(".")[0] : "latest"
console.log(`dist_tag=${distTag}`)
NODE
- name: Install dependencies
run: npm ci
- name: Build generated artifacts
run: |
bun run res:build
bun run build:resx-client
- name: Verify generated artifacts are committed
run: git diff --exit-code
- name: Run tests
run: bun run test
- name: Check whether this version is already published
id: already_published
run: |
if npm view "rescript-x@${{ steps.version.outputs.version }}" version >/dev/null 2>&1; then
echo "published=true" >> "$GITHUB_OUTPUT"
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
- name: Show packed contents
if: steps.already_published.outputs.published != 'true'
run: npm pack --dry-run
- name: Publish to npm
if: steps.already_published.outputs.published != 'true'
run: npm publish --tag "${{ steps.dist_tag.outputs.dist_tag }}"
- name: Skip duplicate publish
if: steps.already_published.outputs.published == 'true'
run: echo "rescript-x@${{ steps.version.outputs.version }} is already published, skipping."