diff --git a/.github/scripts/changeset-version.js b/.github/scripts/changeset-version.js new file mode 100644 index 0000000..fb32328 --- /dev/null +++ b/.github/scripts/changeset-version.js @@ -0,0 +1,12 @@ +// WITH THANKS TO SHADCN, ORIGINALLY FROM CLOUDFLARE WRANGLER: +// https://github.com/cloudflare/wrangler2/blob/main/.github/changeset-version.js + +import { exec } from "child_process" + +// This script is used by the `release.yml` workflow to update the version of the packages being released. +// The standard step is only to run `changeset version` but this does not update the package-lock.json file. +// So we also run `npm install`, which does this update. +// This is a workaround until this is handled automatically by `changeset version`. +// See https://github.com/changesets/changesets/issues/421. +exec("npx changeset version") +exec("npm install") diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..fc99095 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +# Adapted from shadcn/ui + +name: Release + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use PNPM + uses: pnpm/action-setup@v4 + with: + version: 9.0.6 + + - name: Use node.js 18 + uses: actions/setup-node@v4 + with: + node-version: 18 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Create publish PR or publish directly + id: changesets + uses: changesets/action@v1.4.1 + with: + commit: "chore(release): version release" + title: "chore(release): version release" + version: node .github/scripts/changeset-version.js + publish: npx changeset publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_ENV: production