Files

87 lines
2.6 KiB
YAML

name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
deploy:
description: "Force Deploy to Vercel even if no packages were published"
type: boolean
default: true
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v7
with:
node-version: "24"
# Do not set registry-url: it writes
# //registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN} into the runner
# npmrc. Under OIDC trusted publishing there is no NODE_AUTH_TOKEN, so
# that line poisons anonymous `npm info` reads that changesets uses to
# decide what is already on the registry (empty stdout → treated as
# unpublished → republish of already-released versions).
# Pin npm 11.x: trusted publishing needs >=11.5.1, but npm 12 changed
# `npm info <pkg> --json` to return an array. @changesets/cli <2.31 reads
# `.versions` off the top-level object, sees none, and tries to republish
# every package on every main push.
- name: Update npm
run: npm install -g npm@11
- name: Install Dependencies
run: pnpm i
- name: Build Packages
run: pnpm build:packages
- name: Build Website
run: pnpm build --filter website
- name: Run Tests
run: pnpm test
- name: Check Linting and Formatting
run: pnpm check
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
version: pnpm changeset version
publish: pnpm changeset publish
# github-api creates verified commits (required by repo rules);
# git-cli commits are unsigned and get rejected on push.
commitMode: github-api
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: "" # Workaround for https://github.com/changesets/action/pull/545
- name: Deploy to Vercel
if: >-
steps.changesets.outputs.published == 'true' ||
(github.event_name == 'workflow_dispatch' && inputs.deploy)
run: npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }}
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}