Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,83 @@ jobs:
if: steps.check-exists.outputs.exists == 'true' && steps.detect.outputs.is_tag != 'true'
run: |
echo "⏭️ Pre-release version already exists, skipping"

publish-demo:
name: publish @ghostty-web/demo to npm
runs-on: ubuntu-latest
needs: publish
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0

- name: Setup Node.js for npm
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- run: npm install -g npm@latest

- name: Detect trigger type
id: detect
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "is_tag=true" >> $GITHUB_OUTPUT
echo "trigger_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "is_tag=false" >> $GITHUB_OUTPUT
echo "trigger_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
fi

- name: Generate demo version
id: version
working-directory: demo
run: |
BASE_VERSION=$(jq -r .version package.json)

if [[ "${{ steps.detect.outputs.is_tag }}" == "true" ]]; then
NPM_VERSION="${BASE_VERSION}"
NPM_TAG="latest"
GHOSTTY_WEB_DEP="latest"
else
GIT_COMMIT=$(git rev-parse --short HEAD)
COMMITS_SINCE_TAG=$(git rev-list --count HEAD ^$(git describe --tags --abbrev=0 2>/dev/null || echo HEAD) 2>/dev/null || echo "0")
NPM_VERSION="${BASE_VERSION}-next.${COMMITS_SINCE_TAG}.g${GIT_COMMIT}"
NPM_TAG="next"
GHOSTTY_WEB_DEP="next"
fi

echo "version=${NPM_VERSION}" >> $GITHUB_OUTPUT
echo "tag=${NPM_TAG}" >> $GITHUB_OUTPUT

# Update version and ghostty-web dependency
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json'));
pkg.version = '${NPM_VERSION}';
pkg.dependencies['ghostty-web'] = '${GHOSTTY_WEB_DEP}';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
echo "Updated demo package.json: version=${NPM_VERSION}, ghostty-web=${GHOSTTY_WEB_DEP}"

- name: Check if demo version exists
id: check-exists
working-directory: demo
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
VERSION="${{ steps.version.outputs.version }}"

if npm view "${PACKAGE_NAME}@${VERSION}" version &>/dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi

- name: Publish demo to npm
if: steps.check-exists.outputs.exists == 'false'
working-directory: demo
run: npm publish --tag ${{ steps.version.outputs.tag }} --provenance --access public
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@ cases it is a drop-in replacement for xterm.js.

## Live Demo

You can try ghostty-web yourself:
Try ghostty-web instantly with:

```bash
npx @ghostty-web/demo
```

This starts a local demo server with a real shell session. Works on Linux, macOS, and Windows.

<details>
<summary>Development setup (building from source)</summary>

> [!NOTE]
> Requires Zig and Bun, see [Development](#development)
Expand All @@ -21,14 +30,16 @@ bun install
bun run build # Builds the WASM module and library

# Terminal 1: Start PTY Server
cd demo/server
cd demo
bun install
bun run start
bun run dev

# Terminal 2: Start web server
bun dev # http://localhost:8000/demo/
bun run dev # http://localhost:8000/demo/
```

</details>

## Getting Started

Install the module via npm
Expand Down
Loading