chore: prettier #118
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: (CommandKit) Publish Dev Builds | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'packages/commandkit/**' | |
| - 'packages/create-commandkit/**' | |
| - 'packages/legacy/**' | |
| - 'packages/redis/**' | |
| - 'packages/i18n/**' | |
| - 'packages/devtools/**' | |
| - 'packages/devtools-ui/**' # this is not a package we want to publish, but devtools depends on it | |
| - 'packages/cache/**' | |
| jobs: | |
| publish: | |
| name: 🚀 Publish Dev Builds | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: pnpm/action-setup@v2 | |
| with: | |
| version: '9.15.0' | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v2 | |
| with: | |
| node-version: 22 | |
| registry-url: https://registry.npmjs.org | |
| - name: 💾 Cache pnpm store | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| - name: 🍳 Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: 🔢 Set version suffix | |
| id: version | |
| run: echo "suffix=-dev.$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
| - name: 📝 Update package versions | |
| run: | | |
| suffix="${{ steps.version.outputs.suffix }}" | |
| for dir in packages/*; do | |
| [ -f "$dir/package.json" ] || continue | |
| node -e " | |
| const fs = require('fs'); | |
| const path = './$dir/package.json'; | |
| const pkg = require(path); | |
| pkg.version += '$suffix'; | |
| fs.writeFileSync(path, JSON.stringify(pkg, null, 2)); | |
| " | |
| done | |
| - name: 🧱 Build packages | |
| run: pnpm build | |
| - name: 🚀 Publish each package | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| # NPM_CONFIG_PROVENANCE: true | |
| 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" | |
| ) | |
| for entry in "${PACKAGES[@]}"; do | |
| IFS=":" read -r name path <<< "$entry" | |
| echo "📦 Publishing $name..." | |
| (pnpm --filter="$name" publish --no-git-checks --access public --tag dev && echo "✅ Published $name") || echo "❌ Failed to publish $name" | |
| done | |
| - name: 🚫 Deprecate previous dev versions | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
| run: | | |
| PACKAGES=( | |
| "commandkit" | |
| "create-commandkit" | |
| "@commandkit/legacy" | |
| "@commandkit/redis" | |
| "@commandkit/i18n" | |
| "@commandkit/devtools" | |
| "@commandkit/cache" | |
| ) | |
| for pkg in "${PACKAGES[@]}"; do | |
| echo "📉 Deprecating previous dev 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 devVersions = versions.filter(v => v.includes('-dev.')); | |
| const versionToDeprecate = devVersions[devVersions.length - 2]; | |
| console.log(versionToDeprecate); | |
| ") | |
| [ -n "$VERSION_TO_DEPRECATE" ] && npm deprecate "$pkg@$VERSION_TO_DEPRECATE" "Deprecated dev version." && echo "✅ Deprecated $VERSION_TO_DEPRECATE" | |
| ) || echo "⚠️ Skipped deprecation for $pkg (maybe not enough dev versions)" | |
| done |