forked from better-auth/better-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.53 KB
/
release.yml
File metadata and controls
79 lines (66 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM || github.repository_owner }}
TURBO_CACHE: remote:rw
TURBO_FORCE: true
BETTER_AUTH_TELEMETRY_ENDPOINT: ${{ vars.BETTER_AUTH_TELEMETRY_ENDPOINT }}
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: '.nvmrc'
- run: npx changelogithub
continue-on-error: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- run: pnpm install
- name: Build
run: pnpm build
- name: Determine npm tag
id: determine_npm_tag
shell: bash
run: |
TAG="${GITHUB_REF#refs/tags/}"
if [[ "$TAG" =~ -(next|canary|beta|rc) ]]; then
# Extract pre-release tag (e.g., beta, rc)
NPM_TAG=${BASH_REMATCH[1]}
else
# Check if the commit is on the main branch or a version branch
git fetch origin main
CURRENT_BRANCH=$(git branch -r --contains "$GITHUB_SHA" | grep -E 'origin/(main|v[0-9]+\.[0-9]+\.x-latest)' | head -1 | sed 's/.*origin\///')
if [[ "$CURRENT_BRANCH" == "main" ]]; then
NPM_TAG="latest"
elif [[ "$CURRENT_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x-latest$ ]]; then
# For version branches like v1.3.x-latest, v1.4.x-latest, use "latest" tag
NPM_TAG="latest"
else
echo "The tagged commit is not on the main branch or a version branch (v*.*.x-latest)."
echo "::error ::Releases with the 'latest' npm tag must be on the main branch or a version branch."
exit 1
fi
fi
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "Using npm tag: $NPM_TAG"
- name: Publish to npm
run: pnpm -r publish --access public --no-git-checks --tag ${{ steps.determine_npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true