fix: publish ghostty native runtime package #195
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| permissions: | |
| actions: read | |
| contents: read | |
| concurrency: | |
| group: ci-oss-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [22] | |
| env: | |
| ADHDEV_SKIP_GHOSTTY_VT_BUILD: '1' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Compute ghostty triplet | |
| run: echo "GHOSTTY_TRIPLET=linux-x64-node$(node -p 'process.versions.modules')" >> "$GITHUB_ENV" | |
| - name: Download latest ghostty prebuilt artifact | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p "packages/ghostty-vt-node/prebuilt/${GHOSTTY_TRIPLET}" | |
| run_id="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/ghostty-vt-node.yml/runs?branch=main&event=push&per_page=20" --jq '.workflow_runs[] | select(.conclusion == "success") | .id' | head -n 1 || true)" | |
| if [ -z "${run_id}" ]; then | |
| echo "No successful Ghostty VT Native run found on main; continuing without prebuilt artifact." | |
| exit 0 | |
| fi | |
| gh run download "${run_id}" \ | |
| --repo "${GITHUB_REPOSITORY}" \ | |
| --name "ghostty-vt-node-${GHOSTTY_TRIPLET}" \ | |
| --dir "packages/ghostty-vt-node/prebuilt/${GHOSTTY_TRIPLET}" || { | |
| echo "Ghostty prebuilt artifact download failed; continuing without it." | |
| exit 0 | |
| } | |
| find "packages/ghostty-vt-node/prebuilt/${GHOSTTY_TRIPLET}" -mindepth 2 -maxdepth 2 -type f -exec mv {} "packages/ghostty-vt-node/prebuilt/${GHOSTTY_TRIPLET}/" \; | |
| find "packages/ghostty-vt-node/prebuilt/${GHOSTTY_TRIPLET}" -mindepth 1 -type d -empty -delete | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build all packages | |
| run: npm run build | |
| - name: Verify shebang | |
| run: head -1 packages/daemon-standalone/dist/index.js | grep '#!/usr/bin/env node' | |
| - name: Upload publish artifacts | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: publish-artifacts | |
| path: | | |
| packages/session-host-core/dist | |
| packages/session-host-daemon/dist | |
| packages/daemon-core/dist | |
| packages/daemon-standalone/dist | |
| packages/web-standalone/dist | |
| if-no-files-found: error | |
| publish: | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| env: | |
| ADHDEV_SKIP_GHOSTTY_VT_BUILD: '1' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js 22 | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Download release ghostty prebuilt artifacts | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| triplets=( | |
| "linux-x64-node$(node -p 'process.versions.modules')" | |
| "darwin-arm64-node$(node -p 'process.versions.modules')" | |
| ) | |
| run_id="" | |
| for attempt in $(seq 1 30); do | |
| run_id="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/ghostty-vt-node.yml/runs?per_page=30" --jq '.workflow_runs[] | select(.head_sha == "'"${GITHUB_SHA}"'" and .conclusion == "success") | .id' | head -n 1 || true)" | |
| if [ -n "${run_id}" ]; then | |
| break | |
| fi | |
| pending_run="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/ghostty-vt-node.yml/runs?per_page=30" --jq '.workflow_runs[] | select(.head_sha == "'"${GITHUB_SHA}"'" and (.status == "queued" or .status == "in_progress" or .status == "pending" or .status == "waiting")) | .id' | head -n 1 || true)" | |
| if [ -z "${pending_run}" ]; then | |
| echo "No successful Ghostty VT Native run found for ${GITHUB_SHA}." | |
| exit 1 | |
| fi | |
| echo "Waiting for Ghostty VT Native run ${pending_run} to finish..." | |
| sleep 10 | |
| done | |
| if [ -z "${run_id}" ]; then | |
| echo "Timed out waiting for Ghostty VT Native run on ${GITHUB_SHA}." | |
| exit 1 | |
| fi | |
| for triplet in "${triplets[@]}"; do | |
| mkdir -p "packages/ghostty-vt-node/prebuilt/${triplet}" | |
| gh run download "${run_id}" \ | |
| --repo "${GITHUB_REPOSITORY}" \ | |
| --name "ghostty-vt-node-${triplet}" \ | |
| --dir "packages/ghostty-vt-node/prebuilt/${triplet}" | |
| find "packages/ghostty-vt-node/prebuilt/${triplet}" -mindepth 2 -maxdepth 2 -type f -exec mv {} "packages/ghostty-vt-node/prebuilt/${triplet}/" \; | |
| find "packages/ghostty-vt-node/prebuilt/${triplet}" -mindepth 1 -type d -empty -delete | |
| done | |
| find packages/ghostty-vt-node/prebuilt -maxdepth 2 -type f -name 'ghostty_vt_node.node' -print | |
| - name: Download publish artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: publish-artifacts | |
| path: packages | |
| - name: Bundle web into daemon-standalone | |
| run: npm run bundle:web -w packages/daemon-standalone | |
| - name: Bundle vendored runtime deps into daemon-standalone | |
| run: npm run bundle:vendor -w packages/daemon-standalone | |
| - name: Publish @adhdev/session-host-core | |
| if: env.NODE_AUTH_TOKEN != '' | |
| run: cd packages/session-host-core && npm publish --access public --ignore-scripts || echo '⚠️ session-host-core publish skipped (version may already exist)' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish @adhdev/ghostty-vt-node | |
| if: env.NODE_AUTH_TOKEN != '' | |
| run: cd packages/ghostty-vt-node && npm publish --access public --ignore-scripts || echo '⚠️ ghostty-vt-node publish skipped (version may already exist)' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Vendor session-host-core into daemon-core | |
| run: | | |
| set -euo pipefail | |
| target="packages/daemon-core/node_modules/@adhdev/session-host-core" | |
| rm -rf "${target}" | |
| mkdir -p "${target}" | |
| cp packages/session-host-core/package.json "${target}/package.json" | |
| cp -R packages/session-host-core/dist "${target}/dist" | |
| - name: Publish @adhdev/daemon-core | |
| if: env.NODE_AUTH_TOKEN != '' | |
| run: cd packages/daemon-core && npm publish --access public --ignore-scripts || echo '⚠️ daemon-core publish skipped (version may already exist)' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish @adhdev/daemon-standalone | |
| if: env.NODE_AUTH_TOKEN != '' | |
| run: cd packages/daemon-standalone && npm publish --access public --ignore-scripts || echo '⚠️ daemon-standalone publish skipped (version may already exist)' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |