Skip to content

fix: update event file name check to use startsWith #100

fix: update event file name check to use startsWith

fix: update event file name check to use startsWith #100

name: (CommandKit) Publish Dev Builds
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'packages/commandkit/**'
- 'packages/create-commandkit/**'
- 'packages/legacy/**'
- 'packages/redis/**'
- 'packages/i18n/**'
jobs:
release:
name: πŸš€ Publish Dev Build
runs-on: macos-latest
timeout-minutes: 7
strategy:
matrix:
package:
[
commandkit,
create-commandkit,
'@commandkit/legacy',
'@commandkit/redis',
'@commandkit/i18n',
]
include:
- package: commandkit
path: packages/commandkit
- package: create-commandkit
path: packages/create-commandkit
- package: '@commandkit/legacy'
path: packages/legacy
- package: '@commandkit/redis'
path: packages/redis
- package: '@commandkit/i18n'
path: packages/i18n
fail-fast: false
steps:
- uses: pnpm/action-setup@v2
with:
version: '9.15.0'
- name: πŸ“š Checkout
uses: actions/checkout@v3
- name: 🟒 Node
uses: actions/setup-node@v2
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: 🍳 Prepare
run: pnpm install
- name: πŸ”’ Update Version
run: |
cd ${{ matrix.path }}
node -e "const pkg = require('./package.json'); \
const newVersion = pkg.version + '-dev.' + new Date().toISOString().replace(/[:\-T]/g, '').substr(0,14); \
pkg.version = newVersion; \
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));"
env:
DEBIAN_FRONTEND: noninteractive
- name: 🧱 Build
run: pnpm run build
- name: 🚚 Publish
run: pnpm --filter=${{ matrix.package }} publish --no-git-checks --access public --tag dev
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
- name: 🚫 Deprecate Previous Dev Version
run: |
PACKAGE_NAME=${{ matrix.package }}
ALL_VERSIONS=$(npm info $PACKAGE_NAME 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);
")
echo Deprecating version $VERSION_TO_DEPRECATE
npm deprecate $PACKAGE_NAME@$VERSION_TO_DEPRECATE "Deprecated dev version."
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}