Skip to content

Publish release candidate builds #11

Publish release candidate builds

Publish release candidate builds #11

Workflow file for this run

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
jobs:
publish:
name: Publish release candidate builds
runs-on: ubuntu-latest
steps:
- uses: pnpm/action-setup@v4
with:
version: '10.15.0'
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- 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 }}
run: |
PACKAGES=(
"commandkit:packages/commandkit"
"create-commandkit:packages/create-commandkit"
"@commandkit/legacy:packages/legacy"
"@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"
)
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 --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/legacy"
"@commandkit/redis"
"@commandkit/i18n"
"@commandkit/devtools"
"@commandkit/cache"
"@commandkit/analytics"
"@commandkit/ai"
"@commandkit/queue"
"@commandkit/tasks"
)
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 }}"