Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 5 additions & 70 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,16 @@
name: Release

on:
push:
tags:
- 'v*'
pull_request:
types: [closed]

permissions: {}

concurrency:
group: release-${{ github.ref_name }}
cancel-in-progress: false

jobs:
release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
# No git push in this job, so don't persist the token in .git/config.
persist-credentials: false

- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: '.nvmrc'

- run: npx changelogithub@14
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'

- run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build

- name: Determine npm tag
id: determine_npm_tag
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"

# The published version must equal the tag, so a tag can't ship a
# different (e.g. stable) version under a pre-release dist-tag.
PKG_VERSION="$(node -p 'require("./package.json").version')"
if [ "$VERSION" != "$PKG_VERSION" ]; then
echo "::error ::Tag $TAG does not match package.json version $PKG_VERSION."
exit 1
fi

# Anchor to the semver pre-release identifier (e.g. 1.2.3-beta.0) so a
# version like 1.0.0-rchurn does not falsely match '-rc'.
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-(next|canary|beta|rc)(\.|$) ]]; then
# Pre-releases may be cut from any branch.
NPM_TAG="${BASH_REMATCH[1]}"
else
# Stable (latest) releases must be cut from main.
git fetch origin main
if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
echo "::error ::Stable releases must be on the main branch."
exit 1
fi
NPM_TAG="latest"
fi
echo "npm_tag=$NPM_TAG" >> "$GITHUB_OUTPUT"
echo "Using npm tag: $NPM_TAG"

- name: Publish to npm
run: pnpm -r publish --provenance --access public --no-git-checks --tag ${{ steps.determine_npm_tag.outputs.npm_tag }}
uses: better-auth/shared-workflows/.github/workflows/release-bumpp-library.yml@b574d729adc6831942ea65d4bcf991f0af4f2705
with:
version-file: package.json
15 changes: 15 additions & 0 deletions bump.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from "bumpp";

export const releaseConfig = {
branch: "main",
npmTag: "latest",
} as const;

export default defineConfig({
commit: "chore: release {tag}",
pr: {
base: releaseConfig.branch,
branch: "release/v{version}",
title: "chore: release {tag}",
},
Comment thread
bytaesu marked this conversation as resolved.
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@types/node": "^22.10.1",
"bumpp": "^9.9.0",
"bumpp": "^12.2.2",
"happy-dom": "^15.11.7",
"lefthook": "^2.1.4",
"tsdown": "0.22.9",
Expand Down
Loading