-
Notifications
You must be signed in to change notification settings - Fork 43
97 lines (87 loc) · 2.68 KB
/
release.yml
File metadata and controls
97 lines (87 loc) · 2.68 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version to publish (e.g. 0.1.0-rc.2)"
required: true
type: string
npm-tag:
description: "npm dist-tag"
required: true
type: choice
options:
- latest
- rc
concurrency:
group: release
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: v${{ inputs.version }}
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 8.15.6
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Type check
run: pnpm turbo check-types
- name: Build
run: pnpm turbo build
- name: Publish to npm
run: |
FAILURES=""
for dir in $(pnpm -r ls --json --depth -1 | jq -r '.[] | select(.private != true) | .path'); do
# Skip the root package
if [ "$dir" = "$(pwd)" ]; then
continue
fi
NAME=$(jq -r .name "$dir/package.json")
VERSION="${{ inputs.version }}"
# Skip if already published
if npm view "${NAME}@${VERSION}" version >/dev/null 2>&1; then
echo "⏭ ${NAME}@${VERSION} already published, skipping."
continue
fi
echo "Publishing ${NAME}@${VERSION}..."
if ! (cd "$dir" && pnpm publish --access public --tag ${{ inputs.npm-tag }} --no-git-checks); then
FAILURES="${FAILURES} ${NAME}"
fi
done
if [ -n "$FAILURES" ]; then
echo "::error::Failed to publish:${FAILURES}"
exit 1
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub release
run: |
if gh release view "v${{ inputs.version }}" >/dev/null 2>&1; then
echo "GitHub release v${{ inputs.version }} already exists, skipping."
else
PRERELEASE=""
if [ "${{ inputs.npm-tag }}" = "rc" ]; then
PRERELEASE="--prerelease"
fi
gh release create "v${{ inputs.version }}" \
--title "v${{ inputs.version }}" \
--generate-notes \
$PRERELEASE
fi
env:
GH_TOKEN: ${{ github.token }}