mirror of
https://github.com/anomalyco/opentui.git
synced 2026-09-19 01:26:03 +08:00
fa14b96ad4
Keep 26.4.0 as the minimum supported version while allowing later releases.
201 lines
6.3 KiB
YAML
201 lines
6.3 KiB
YAML
name: NPM Publish
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
version:
|
|
description: "Version being published"
|
|
required: true
|
|
type: string
|
|
isDryRun:
|
|
description: "Whether this is a dry run (npm publish --dry-run)"
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
prepareVersion:
|
|
description: "Optional package version to prepare before publishing"
|
|
required: false
|
|
type: string
|
|
default: ""
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
env:
|
|
NODE_VERSION: 26.7.0
|
|
|
|
jobs:
|
|
publish:
|
|
# npm Trusted Publishing rejects third-party/self-hosted runners.
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
registry-url: https://registry.npmjs.org
|
|
|
|
- name: Setup npm with Trusted Publishing support
|
|
run: npm install --global npm@^11.15.0
|
|
|
|
- name: Setup Bun
|
|
uses: oven-sh/setup-bun@v2
|
|
with:
|
|
bun-version: 1.3.14
|
|
|
|
- name: Prepare release versions
|
|
if: ${{ inputs.prepareVersion != '' }}
|
|
run: bun run prepare-release "${{ inputs.prepareVersion }}" --no-install
|
|
|
|
- name: Install dependencies
|
|
run: bun install
|
|
|
|
- name: Download npm packages artifact
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: npm-packages-${{ inputs.version }}
|
|
|
|
- name: Extract npm packages
|
|
run: |
|
|
echo "Extracting npm packages..."
|
|
unzip -q npm-packages.zip
|
|
|
|
# Copy core dist
|
|
if [ -d "npm-packages/core-dist" ]; then
|
|
cp -r npm-packages/core-dist packages/core/dist
|
|
echo "Copied core dist"
|
|
fi
|
|
|
|
if [ -d "npm-packages/three-dist" ]; then
|
|
cp -r npm-packages/three-dist packages/three/dist
|
|
echo "Copied three dist"
|
|
fi
|
|
|
|
if [ -d "npm-packages/qrcode-dist" ]; then
|
|
cp -r npm-packages/qrcode-dist packages/qrcode/dist
|
|
echo "Copied qrcode dist"
|
|
fi
|
|
|
|
# Copy native packages to core's node_modules
|
|
if [ -d "npm-packages/core-native-packages" ]; then
|
|
mkdir -p packages/core/node_modules/@opentui
|
|
|
|
# Replace Bun-managed symlinks with the packaged native directories.
|
|
rm -rf packages/core/node_modules/@opentui/core-darwin-x64
|
|
rm -rf packages/core/node_modules/@opentui/core-darwin-arm64
|
|
rm -rf packages/core/node_modules/@opentui/core-linux-x64
|
|
rm -rf packages/core/node_modules/@opentui/core-linux-arm64
|
|
rm -rf packages/core/node_modules/@opentui/core-linux-x64-musl
|
|
rm -rf packages/core/node_modules/@opentui/core-linux-arm64-musl
|
|
rm -rf packages/core/node_modules/@opentui/core-win32-x64
|
|
rm -rf packages/core/node_modules/@opentui/core-win32-arm64
|
|
|
|
cp -r npm-packages/core-native-packages/* packages/core/node_modules/@opentui/
|
|
echo "Copied native packages"
|
|
fi
|
|
|
|
# Copy other package dists
|
|
if [ -d "npm-packages/react-dist" ]; then
|
|
cp -r npm-packages/react-dist packages/react/dist
|
|
echo "Copied react dist"
|
|
fi
|
|
|
|
if [ -d "npm-packages/solid-dist" ]; then
|
|
cp -r npm-packages/solid-dist packages/solid/dist
|
|
echo "Copied solid dist"
|
|
fi
|
|
|
|
if [ -d "npm-packages/keymap-dist" ]; then
|
|
cp -r npm-packages/keymap-dist packages/keymap/dist
|
|
echo "Copied keymap dist"
|
|
fi
|
|
|
|
if [ -d "npm-packages/ssh-dist" ]; then
|
|
cp -r npm-packages/ssh-dist packages/ssh/dist
|
|
echo "Copied ssh dist"
|
|
fi
|
|
|
|
echo "Package extraction complete"
|
|
|
|
- name: Run packed Node smoke tests
|
|
run: |
|
|
cd packages/core
|
|
bun run test:dist --skip-build
|
|
cd ../solid
|
|
bun run test:dist --skip-build
|
|
cd ../keymap
|
|
bun run test:dist --skip-build
|
|
cd ../ssh
|
|
bun run test:dist --skip-build
|
|
|
|
- name: Publish packages (dry-run)
|
|
if: ${{ inputs.isDryRun }}
|
|
run: |
|
|
echo "=========================================="
|
|
echo "DRY RUN MODE - Not publishing to npm"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Skipping pre-publish validation (npm version check would fail for dry-runs)"
|
|
echo ""
|
|
|
|
# Show what would be published (just check if packages can be packed)
|
|
echo "Packages that would be published:"
|
|
echo ""
|
|
|
|
echo "📦 Checking @opentui/core..."
|
|
cd packages/core/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/three..."
|
|
cd ../../three/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/qrcode..."
|
|
cd ../../qrcode/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/react..."
|
|
cd ../../react/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/solid..."
|
|
cd ../../solid/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/keymap..."
|
|
cd ../../keymap/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "📦 Checking @opentui/ssh..."
|
|
cd ../../ssh/dist && npm pack --dry-run
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "DRY RUN COMPLETE - All packages validated"
|
|
echo "=========================================="
|
|
env:
|
|
CI: true
|
|
|
|
- name: Publish packages (production)
|
|
if: ${{ !inputs.isDryRun }}
|
|
run: |
|
|
echo "=========================================="
|
|
echo "PRODUCTION MODE - Publishing to npm"
|
|
echo "=========================================="
|
|
|
|
# The publish script runs pre-publish validation before publishing.
|
|
bun run publish
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "PUBLISH COMPLETE"
|
|
echo "=========================================="
|
|
env:
|
|
CI: true
|