Publish latest builds #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish latest builds | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 1.2.3)' | |
| required: true | |
| type: string | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| publish: | |
| name: Publish latest 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 version input | |
| run: | | |
| if ! [[ "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "❌ Version must be in semantic version format (e.g., 1.2.3)" | |
| exit 1 | |
| fi | |
| - name: Update package versions | |
| run: | | |
| target_version="${{ github.event.inputs.version }}" | |
| echo "Setting version to: $target_version" | |
| 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 = '$target_version'; | |
| 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 | |
| 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 --access public; then | |
| echo "✅ Published $name@$VERSION" | |
| 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 |