Skip to content

Commit 1fadbd6

Browse files
committed
chore: add publish packages script
1 parent 36b8150 commit 1fadbd6

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: bun install
3131

3232
- name: Publish to npm
33-
run: bun publish --access public
33+
run: ./scripts/publish-packages.sh
3434
env:
3535
BUN_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
3636

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
4141
"changelog": "bunx changelogen --output CHANGELOG.md",
4242
"prepublishOnly": "bun --bun run build",
43-
"release": "bun run changelog && bunx bumpp package.json --all",
43+
"release": "bun run changelog && bunx bumpp package.json -r --all",
4444
"test": "bun test",
4545
"dev:docs": "bun --bun vitepress dev docs",
4646
"build:docs": "bun --bun vitepress build docs",

packages/ts-inputs/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ts-inputs",
33
"type": "module",
4-
"version": "0.0.0",
4+
"version": "0.1.0",
55
"description": "A collection of input components.",
66
"author": "Chris Breuer <chris@stacksjs.org>",
77
"license": "MIT",
@@ -42,8 +42,6 @@
4242
"build": "bun --bun build.ts && bun run typecheck",
4343
"lint": "bunx --bun eslint .",
4444
"lint:fix": "bunx --bun eslint . --fix",
45-
"prepublishOnly": "bun --bun run build",
46-
"release": "bun publish --access public",
4745
"test": "bun test",
4846
"typecheck": "bun --bun tsc --noEmit"
4947
},

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ts-inputs-vue",
33
"type": "module",
4-
"version": "0.0.1",
4+
"version": "0.1.0",
55
"description": "Vue components for ts-inputs - Modern & lightweight input masking",
66
"author": "Chris Breuer <chris@stacksjs.org>",
77
"license": "MIT",

scripts/publish-packages.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Exit on error
4+
set -e
5+
6+
# Enable debug if needed
7+
# set -x
8+
9+
echo "Publishing all packages..."
10+
11+
for dir in packages/*/ ; do
12+
if [ -d "$dir" ]; then
13+
package_name=$(basename "$dir")
14+
package_json="$dir/package.json"
15+
16+
echo "----------------------------------------"
17+
echo "Processing $package_name..."
18+
19+
# Check if package is private using Bun
20+
if command -v bun >/dev/null 2>&1; then
21+
is_private=$(bun --eval "try { const pkg = JSON.parse(require('fs').readFileSync('$package_json', 'utf8')); console.log(pkg.private === true ? 'true' : 'false'); } catch(e) { console.log('false'); }")
22+
# Then try jq as a fallback
23+
elif command -v jq >/dev/null 2>&1; then
24+
is_private=$(jq -r '.private // false' "$package_json")
25+
# Finally fall back to grep
26+
else
27+
private_check=$(grep -E '"private":\s*true' "$package_json" || echo "")
28+
if [ -n "$private_check" ]; then
29+
is_private="true"
30+
else
31+
is_private="false"
32+
fi
33+
fi
34+
35+
echo "Package $package_name private status: $is_private"
36+
37+
if [ "$is_private" = "true" ]; then
38+
echo "Skipping $package_name (private package)"
39+
else
40+
echo "Publishing $package_name..."
41+
cd "$dir"
42+
bun publish --access public
43+
cd - > /dev/null # Suppress the directory change message
44+
fi
45+
46+
echo "----------------------------------------"
47+
fi
48+
done
49+
50+
echo "All packages published successfully!"

0 commit comments

Comments
 (0)