Skip to content

Commit 2cb5bb5

Browse files
committed
ci: update release
1 parent 4afa561 commit 2cb5bb5

1 file changed

Lines changed: 69 additions & 63 deletions

File tree

.github/workflows/dev-commandkit.yaml

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,88 +12,94 @@ on:
1212
- 'packages/redis/**'
1313
- 'packages/i18n/**'
1414
- 'packages/devtools/**'
15-
- 'packages/devtools-ui/**' # not a package but devtools depends on it
15+
- 'packages/devtools-ui/**' # this is not a package we want to publish, but devtools depends on it
1616
- 'packages/cache/**'
1717

1818
jobs:
19-
release:
20-
name: 🚀 Publish Dev Build
19+
publish:
20+
name: 🚀 Publish Dev Builds
2121
runs-on: macos-latest
22-
timeout-minutes: 7
23-
strategy:
24-
matrix:
25-
package:
26-
[
27-
commandkit,
28-
create-commandkit,
29-
'@commandkit/legacy',
30-
'@commandkit/redis',
31-
'@commandkit/i18n',
32-
'@commandkit/devtools',
33-
'@commandkit/cache',
34-
]
35-
include:
36-
- package: commandkit
37-
path: packages/commandkit
38-
- package: create-commandkit
39-
path: packages/create-commandkit
40-
- package: '@commandkit/legacy'
41-
path: packages/legacy
42-
- package: '@commandkit/redis'
43-
path: packages/redis
44-
- package: '@commandkit/i18n'
45-
path: packages/i18n
46-
- package: '@commandkit/devtools'
47-
path: packages/devtools
48-
- package: '@commandkit/cache'
49-
path: packages/cache
50-
fail-fast: false
22+
timeout-minutes: 10
5123
steps:
5224
- uses: pnpm/action-setup@v2
5325
with:
5426
version: '9.15.0'
5527

56-
- name: 📚 Checkout
57-
uses: actions/checkout@v3
28+
- uses: actions/checkout@v3
5829

59-
- name: 🟢 Node
60-
uses: actions/setup-node@v2
30+
- uses: actions/setup-node@v2
6131
with:
6232
node-version: 22
6333
registry-url: https://registry.npmjs.org
6434

65-
- name: 🍳 Prepare
35+
- name: 🍳 Install dependencies
6636
run: pnpm install
6737

68-
- name: 🔢 Update Version
38+
- name: 🔢 Set version suffix
39+
id: version
40+
run: echo "suffix=-dev.$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
41+
42+
- name: 📝 Update package versions
6943
run: |
70-
cd ${{ matrix.path }}
71-
node -e "const pkg = require('./package.json'); \
72-
const newVersion = pkg.version + '-dev.' + new Date().toISOString().replace(/[:\-T]/g, '').substr(0,14); \
73-
pkg.version = newVersion; \
74-
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2));"
75-
env:
76-
DEBIAN_FRONTEND: noninteractive
44+
suffix="${{ steps.version.outputs.suffix }}"
45+
for dir in packages/*; do
46+
[ -f "$dir/package.json" ] || continue
47+
node -e "
48+
const fs = require('fs');
49+
const path = '$dir/package.json';
50+
const pkg = require(path);
51+
pkg.version += '$suffix';
52+
fs.writeFileSync(path, JSON.stringify(pkg, null, 2));
53+
"
54+
done
7755
78-
- name: 🧱 Build
79-
run: pnpm run build
56+
- name: 🧱 Build packages
57+
run: pnpm build
8058

81-
- name: 🚚 Publish
82-
run: pnpm --filter=${{ matrix.package }} publish --no-git-checks --access public --tag dev
59+
- name: 🚀 Publish each package
8360
env:
84-
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
85-
86-
- name: 🚫 Deprecate Previous Dev Version
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
8762
run: |
88-
PACKAGE_NAME=${{ matrix.package }}
89-
ALL_VERSIONS=$(npm info $PACKAGE_NAME versions -json)
90-
VERSION_TO_DEPRECATE=$(echo $ALL_VERSIONS | node -e "
91-
const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf-8'));
92-
const devVersions = versions.filter(v => v.includes('-dev.'));
93-
const versionToDeprecate = devVersions[devVersions.length - 2];
94-
console.log(versionToDeprecate);
95-
")
96-
echo Deprecating version $VERSION_TO_DEPRECATE
97-
npm deprecate $PACKAGE_NAME@$VERSION_TO_DEPRECATE "Deprecated dev version."
63+
PACKAGES=(
64+
"commandkit:packages/commandkit"
65+
"create-commandkit:packages/create-commandkit"
66+
"@commandkit/legacy:packages/legacy"
67+
"@commandkit/redis:packages/redis"
68+
"@commandkit/i18n:packages/i18n"
69+
"@commandkit/devtools:packages/devtools"
70+
"@commandkit/cache:packages/cache"
71+
)
72+
73+
for entry in "${PACKAGES[@]}"; do
74+
IFS=":" read -r name path <<< "$entry"
75+
echo "📦 Publishing $name..."
76+
(pnpm --filter="$name" publish --no-git-checks --access public --tag dev && echo "✅ Published $name") || echo "❌ Failed to publish $name"
77+
done
78+
79+
- name: 🚫 Deprecate previous dev versions
9880
env:
99-
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
81+
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
82+
run: |
83+
PACKAGES=(
84+
"commandkit"
85+
"create-commandkit"
86+
"@commandkit/legacy"
87+
"@commandkit/redis"
88+
"@commandkit/i18n"
89+
"@commandkit/devtools"
90+
"@commandkit/cache"
91+
)
92+
93+
for pkg in "${PACKAGES[@]}"; do
94+
echo "📉 Deprecating previous dev version of $pkg..."
95+
(
96+
ALL_VERSIONS=$(npm info "$pkg" versions -json)
97+
VERSION_TO_DEPRECATE=$(echo "$ALL_VERSIONS" | node -e "
98+
const versions = JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf-8'));
99+
const devVersions = versions.filter(v => v.includes('-dev.'));
100+
const versionToDeprecate = devVersions[devVersions.length - 2];
101+
console.log(versionToDeprecate);
102+
")
103+
[ -n "$VERSION_TO_DEPRECATE" ] && npm deprecate "$pkg@$VERSION_TO_DEPRECATE" "Deprecated dev version." && echo "✅ Deprecated $VERSION_TO_DEPRECATE"
104+
) || echo "⚠️ Skipped deprecation for $pkg (maybe not enough dev versions)"
105+
done

0 commit comments

Comments
 (0)