|
| 1 | +name: Publish release candidate builds |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + rc_version: |
| 7 | + description: 'Release candidate version number (e.g., 1 for -rc1, 2 for -rc2)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + publish: |
| 13 | + name: Publish release candidate builds |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: pnpm/action-setup@v4 |
| 17 | + with: |
| 18 | + version: '10.14.0' |
| 19 | + |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: 24 |
| 25 | + registry-url: https://registry.npmjs.org |
| 26 | + |
| 27 | + - name: Install dependencies |
| 28 | + run: pnpm install --frozen-lockfile |
| 29 | + |
| 30 | + - name: Validate RC version input |
| 31 | + run: | |
| 32 | + if ! [[ "${{ github.event.inputs.rc_version }}" =~ ^[0-9]+$ ]]; then |
| 33 | + echo "❌ RC version must be a positive integer" |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +
|
| 37 | + - name: Update package versions |
| 38 | + run: | |
| 39 | + rc_suffix="-rc${{ github.event.inputs.rc_version }}" |
| 40 | + echo "Adding suffix: $rc_suffix" |
| 41 | +
|
| 42 | + for dir in packages/*; do |
| 43 | + [ -f "$dir/package.json" ] || continue |
| 44 | + echo "Updating $dir/package.json..." |
| 45 | + node -e " |
| 46 | + const fs = require('fs'); |
| 47 | + const path = './$dir/package.json'; |
| 48 | + const pkg = require(path); |
| 49 | + pkg.version += '$rc_suffix'; |
| 50 | + fs.writeFileSync(path, JSON.stringify(pkg, null, 2)); |
| 51 | + console.log('Updated ' + pkg.name + ' to version ' + pkg.version); |
| 52 | + " |
| 53 | + done |
| 54 | +
|
| 55 | + - name: Build packages |
| 56 | + run: pnpm dlx turbo build --filter='./packages/*' |
| 57 | + |
| 58 | + - name: Publish packages |
| 59 | + env: |
| 60 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 61 | + run: | |
| 62 | + PACKAGES=( |
| 63 | + "commandkit:packages/commandkit" |
| 64 | + "create-commandkit:packages/create-commandkit" |
| 65 | + "@commandkit/legacy:packages/legacy" |
| 66 | + "@commandkit/redis:packages/redis" |
| 67 | + "@commandkit/i18n:packages/i18n" |
| 68 | + "@commandkit/devtools:packages/devtools" |
| 69 | + "@commandkit/cache:packages/cache" |
| 70 | + "@commandkit/analytics:packages/analytics" |
| 71 | + "@commandkit/ai:packages/ai" |
| 72 | + "@commandkit/queue:packages/queue" |
| 73 | + "@commandkit/tasks:packages/tasks" |
| 74 | + ) |
| 75 | +
|
| 76 | + for entry in "${PACKAGES[@]}"; do |
| 77 | + IFS=":" read -r name path <<< "$entry" |
| 78 | + echo "Publishing $name..." |
| 79 | + |
| 80 | + VERSION=$(node -p "require('./$path/package.json').version") |
| 81 | + |
| 82 | + if npm view "$name@$VERSION" version >/dev/null 2>&1; then |
| 83 | + echo "📦 $name@$VERSION already exists on npm, skipping..." |
| 84 | + else |
| 85 | + if pnpm --filter="$name" publish --no-git-checks --access public --tag next; then |
| 86 | + echo "✅ Published $name@$VERSION under 'next' tag" |
| 87 | + else |
| 88 | + if npm view "$name@$VERSION" version >/dev/null 2>&1; then |
| 89 | + echo "📦 $name@$VERSION was published by another process, skipping..." |
| 90 | + else |
| 91 | + echo "❌ Failed to publish $name@$VERSION" |
| 92 | + exit 1 |
| 93 | + fi |
| 94 | + fi |
| 95 | + fi |
| 96 | + done |
| 97 | +
|
| 98 | + - name: Summary |
| 99 | + run: | |
| 100 | + echo "🎉 Release candidate build completed!" |
| 101 | + echo "📋 Summary:" |
| 102 | + echo " RC Version: ${{ github.event.inputs.rc_version }}" |
| 103 | + echo " Tag: next" |
| 104 | + echo " Suffix: -rc${{ github.event.inputs.rc_version }}" |
0 commit comments