forked from neplextech/commandkit
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (126 loc) · 4.98 KB
/
publish-rc.yaml
File metadata and controls
143 lines (126 loc) · 4.98 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Publish release candidate builds
on:
workflow_dispatch:
inputs:
rc_version:
description: 'Release candidate version number (e.g., 1 for -rc.1, 2 for -rc.2)'
required: true
type: string
permissions:
id-token: write
contents: read
jobs:
publish:
name: Publish release candidate builds
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: pnpm/action-setup@v4
with:
version: '10.30.3'
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate RC version input
run: |
if ! [[ "${{ github.event.inputs.rc_version }}" =~ ^[0-9]+$ ]]; then
echo "❌ RC version must be a positive integer"
exit 1
fi
- name: Update package versions
run: |
rc_suffix="-rc.${{ github.event.inputs.rc_version }}"
echo "Adding suffix: $rc_suffix"
for dir in packages/*; do
[ -f "$dir/package.json" ] || continue
echo "Updating $dir/package.json..."
node -e "
const fs = require('fs');
const path = './$dir/package.json';
const pkg = require(path);
pkg.version += '$rc_suffix';
fs.writeFileSync(path, JSON.stringify(pkg, null, 2));
console.log('Updated ' + pkg.name + ' to version ' + pkg.version);
"
done
- name: Build packages
run: pnpm dlx turbo build --filter='./packages/*'
- name: Publish packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NPM_CONFIG_PROVENANCE: true
run: |
PACKAGES=(
"commandkit:packages/commandkit"
"create-commandkit:packages/create-commandkit"
"@commandkit/redis:packages/redis"
"@commandkit/i18n:packages/i18n"
"@commandkit/devtools:packages/devtools"
"@commandkit/cache:packages/cache"
"@commandkit/analytics:packages/analytics"
"@commandkit/ai:packages/ai"
"@commandkit/queue:packages/queue"
"@commandkit/tasks:packages/tasks"
"@commandkit/workflow:packages/workflow"
)
for entry in "${PACKAGES[@]}"; do
IFS=":" read -r name path <<< "$entry"
echo "Publishing $name..."
VERSION=$(node -p "require('./$path/package.json').version")
if npm view "$name@$VERSION" version >/dev/null 2>&1; then
echo "📦 $name@$VERSION already exists on npm, skipping..."
else
if pnpm --filter="$name" publish --no-git-checks --provenance --access public --tag next; then
echo "✅ Published $name@$VERSION under 'next' tag"
else
if npm view "$name@$VERSION" version >/dev/null 2>&1; then
echo "📦 $name@$VERSION was published by another process, skipping..."
else
echo "❌ Failed to publish $name@$VERSION"
exit 1
fi
fi
fi
done
- name: Deprecate previous release candidate versions
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: |
PACKAGES=(
"commandkit"
"create-commandkit"
"@commandkit/redis"
"@commandkit/i18n"
"@commandkit/devtools"
"@commandkit/cache"
"@commandkit/analytics"
"@commandkit/ai"
"@commandkit/queue"
"@commandkit/tasks"
"@commandkit/workflow"
)
for pkg in "${PACKAGES[@]}"; do
echo "Deprecating previous release candidate version of $pkg..."
(
ALL_VERSIONS=$(npm info "$pkg" versions -json)
VERSION_TO_DEPRECATE=$(echo "$ALL_VERSIONS" | node -e "
const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf-8'));
const rcVersions = versions.filter(v => v.includes('-rc.'));
const versionToDeprecate = rcVersions[rcVersions.length - 2];
console.log(versionToDeprecate);
")
[ -n "$VERSION_TO_DEPRECATE" ] && npm deprecate "$pkg@$VERSION_TO_DEPRECATE" "Deprecated release candidate version." && echo "✅ Deprecated $VERSION_TO_DEPRECATE"
) || echo "⚠️ Skipped deprecation for $pkg (maybe not enough release candidate versions)"
done
- name: Summary
run: |
echo "🎉 Release candidate build completed!"
echo "📋 Summary:"
echo " RC Version: ${{ github.event.inputs.rc_version }}"
echo " Tag: next"
echo " Suffix: -rc.${{ github.event.inputs.rc_version }}"