Skip to content

Publish development builds #17

Publish development builds

Publish development builds #17

Workflow file for this run

name: Publish development builds
on:
schedule:
- cron: '0 */12 * * *'
workflow_dispatch:
jobs:
publish:
name: Publish development builds
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: pnpm/action-setup@v4
with:
version: '10.11.0'
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- 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 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"
)
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 development 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 development 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 development version." && echo "βœ… Deprecated $VERSION_TO_DEPRECATE"
) || echo "⚠️ Skipped deprecation for $pkg (maybe not enough development versions)"
done