Files
vercel__flags/.github/workflows/release.yml
Dominik Ferber 5838f58412 chore: upgrade Changesets to v3 (#478)
Changesets v3 is the first major release since v2. All packages are now ES
modules, and the dependency tree is smaller.

- @changesets/cli 2.31.0 -> 3.0.0
- @changesets/changelog-github ^0.7.0 -> ^1.0.0
- changesets/action v1.7.0 -> v2.1.0 (v1 supports only Changesets v2)
- root engines.node -> ^22.11 || ^24 || >=26, the requirement of the new CLI

Remove the onlyUpdatePeerDependentsWhenOutOfRange experimental option.
Changesets v3 gives a peer dependent a patch increase, and only when the new
version leaves the declared range. This makes the option redundant for the
release plan.

Empty the ignore list. Changesets v3 does not version private packages by
default, and every ignored package is private.

Set format to false. Changesets v3 no longer bundles Prettier, and it excludes
Biome from formatter auto-detection.

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Dominik Ferber <1765075+dferber90@users.noreply.github.com>
2026-08-17 14:06:45 +03:00

141 lines
5.0 KiB
YAML

name: Release
# This workflow handles two release modes:
#
# 1. Regular release (push to main): runs changesets/action, which either
# opens a "chore: release" PR with version bumps from queued changesets,
# or publishes the bumped versions to npm if the release PR has been
# merged.
#
# 2. Snapshot release (workflow_dispatch): publishes a one-off version for
# the current branch under the `snapshot` dist-tag, so changes can be
# previewed without entering changesets pre-release mode. See
# `.changeset/README.md` for usage.
#
# Both modes go through this single workflow file because npm Trusted
# Publishers (OIDC) bind publish authorization to one specific workflow
# filename per package. Renaming this file or moving the publish step
# elsewhere will break publishing until the npm-side configuration is
# updated to match.
#
# Configure a Trusted Publisher for each released package on npm.com:
# https://www.npmjs.com/package/<package> → Settings → Trusted Publishers
# Repository: vercel/flags
# Workflow: release.yml
#
# changesets/action pushes the release commit and the tags through the GitHub
# REST API, so GitHub signs them automatically — no GPG keys or bypass
# exceptions for commit-signature rules. This is the default behavior since
# changesets/action v2. Set `push-with-git-cli: true` to use the Git CLI again.
#
# See https://docs.npmjs.com/trusted-publishers for details.
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
on:
push:
branches:
- main
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
if: github.event_name == 'push'
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
# Node 24 (LTS) ships npm >= 11.12, which has Trusted Publisher OIDC
# authentication. Node 22's bundled npm 10.x can sign provenance
# attestations but cannot use OIDC tokens to authenticate the publish
# itself, leading to a confusing 404 after provenance signing succeeds.
- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@198f833dd7d863100ea6e28967bc9a9fdefadb0a # v2.1.0
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish-script: pnpm release
version-script: pnpm version-packages
env:
NPM_CONFIG_PROVENANCE: "true"
GLOBAL_CONFIG: ${{ secrets.GLOBAL_CONFIG }}
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
FLAGS: ${{ secrets.FLAGS }}
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
HAPPYKIT_ENV_KEY: ${{ secrets.HAPPYKIT_ENV_KEY }}
LAUNCHDARKLY_CLIENT_SIDE_ID: ${{ secrets.LAUNCHDARKLY_CLIENT_SIDE_ID }}
LAUNCHDARKLY_PROJECT_SLUG: ${{ secrets.LAUNCHDARKLY_PROJECT_SLUG }}
snapshot:
if: github.event_name == 'workflow_dispatch'
name: Release Snapshot
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
# Changesets v3 exits with code 1 if it finds no unreleased changesets.
# A snapshot needs a minimum of one changeset on the branch, so this step
# correctly stops the job. Look for "No unreleased changesets found" in
# the log if this step fails.
- name: Version Packages
run: pnpm changeset version --snapshot ${SHORT_SHA}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: pnpm turbo build --filter='./packages/*'
env:
GLOBAL_CONFIG: ${{ secrets.GLOBAL_CONFIG }}
FLAGS_SECRET: ${{ secrets.FLAGS_SECRET }}
FLAGS: ${{ secrets.FLAGS }}
HAPPYKIT_API_TOKEN: ${{ secrets.HAPPYKIT_API_TOKEN }}
HAPPYKIT_ENV_KEY: ${{ secrets.HAPPYKIT_ENV_KEY }}
LAUNCHDARKLY_CLIENT_SIDE_ID: ${{ secrets.LAUNCHDARKLY_CLIENT_SIDE_ID }}
LAUNCHDARKLY_PROJECT_SLUG: ${{ secrets.LAUNCHDARKLY_PROJECT_SLUG }}
- name: Publish Snapshot Release
run: pnpm changeset publish --no-git-tag --tag snapshot
env:
NPM_CONFIG_PROVENANCE: "true"