Skip to content
Draft
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
122 changes: 122 additions & 0 deletions .github/actions/test-npm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: 'Test npm install'
description: 'Install and verify hookdeck-cli npm package'

inputs:
version:
description: 'Version to install (e.g., @beta, @latest, or specific version)'
required: true
platform:
description: 'Platform being tested (darwin, linux, win32)'
required: true

runs:
using: 'composite'
steps:
- name: Wait for npm registry propagation
shell: bash
run: |
VERSION="${{ inputs.version }}"

# If testing a specific version (not a tag), poll until available
if [[ "$VERSION" =~ ^[0-9] ]]; then
echo "Waiting for version $VERSION to be available on npm..."
MAX_ATTEMPTS=30
ATTEMPT=0

while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
if npm view "hookdeck-cli@$VERSION" version > /dev/null 2>&1; then
echo "✓ Version $VERSION is now available on npm"
break
fi

ATTEMPT=$((ATTEMPT + 1))
echo "Attempt $ATTEMPT/$MAX_ATTEMPTS: Version not yet available, waiting 10 seconds..."
sleep 10
done

if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
echo "✗ Version $VERSION not available after $MAX_ATTEMPTS attempts"
exit 1
fi
else
echo "Testing with npm tag: $VERSION (no polling needed)"
fi

- name: Install hookdeck-cli
shell: bash
run: |
VERSION="${{ inputs.version }}"
echo "Installing hookdeck-cli${VERSION}..."
npm install -g "hookdeck-cli${VERSION}"

- name: Verify installation
shell: bash
run: |
echo "Checking hookdeck binary location..."
which hookdeck || (echo "hookdeck not in PATH" && exit 1)

echo "Checking hookdeck version..."
hookdeck --version

- name: Test wrapper script
shell: bash
run: |
echo "Testing wrapper script execution..."
hookdeck --help > /dev/null
echo "✓ Wrapper script works"

- name: Verify package structure
shell: bash
run: |
HOOKDECK_PATH=$(which hookdeck)
HOOKDECK_DIR=$(dirname "$HOOKDECK_PATH")
PACKAGE_DIR=$(dirname "$HOOKDECK_DIR")

echo "Package directory: $PACKAGE_DIR"

echo "Checking for wrapper script..."
if [ -f "$PACKAGE_DIR/bin/hookdeck.js" ]; then
echo "✓ Wrapper script found"
else
echo "✗ Wrapper script not found"
exit 1
fi

echo "Checking for binaries directory..."
if [ -d "$PACKAGE_DIR/binaries" ]; then
echo "✓ Binaries directory found"
echo "Binaries included:"
ls -la "$PACKAGE_DIR/binaries" || true
else
echo "✗ Binaries directory not found"
exit 1
fi

# Check platform-specific binary
PLATFORM="${{ inputs.platform }}"
case "$PLATFORM" in
darwin)
if [ -f "$PACKAGE_DIR/binaries/darwin-amd64/hookdeck" ] || [ -f "$PACKAGE_DIR/binaries/darwin-arm64/hookdeck" ]; then
echo "✓ macOS binary found"
else
echo "✗ macOS binary not found"
exit 1
fi
;;
linux)
if [ -f "$PACKAGE_DIR/binaries/linux-amd64/hookdeck" ]; then
echo "✓ Linux binary found"
else
echo "✗ Linux binary not found"
exit 1
fi
;;
win32)
if [ -f "$PACKAGE_DIR/binaries/win32-amd64/hookdeck.exe" ]; then
echo "✓ Windows binary found"
else
echo "✗ Windows binary not found"
exit 1
fi
;;
esac
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ jobs:

- run: npm ci

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.9

- name: Install Windows cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-x86-64

- name: Build npm binaries with GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: v2.10.2
args: build -f .goreleaser/npm.yml --clean --skip validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Determine npm tag for pre-releases
id: npm_tag
run: |
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/test-npm-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: test-npm-build

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test-npm-build:
runs-on: ubuntu-latest
steps:
- name: Code checkout
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.9

- name: Install Windows cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y gcc-mingw-w64-x86-64

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: v2.10.2
install-only: true

- name: Run npm build tests
run: |
chmod +x test-scripts/test-npm-build.sh
./test-scripts/test-npm-build.sh
128 changes: 128 additions & 0 deletions .github/workflows/test-npm-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: test-npm-install

on:
# Trigger after release workflow completes successfully
# This will trigger for releases from ANY branch (main, feature branches, etc.)
workflow_run:
workflows: ["release"]
types:
- completed
# Manual trigger for testing
workflow_dispatch:
inputs:
npm_version:
description: "npm version to test (e.g., @beta, @latest, or specific version like 1.6.1-beta.1)"
required: false
default: "@beta"
type: string

jobs:
determine-version:
runs-on: ubuntu-latest
# Always run, but only extract version if triggered by release workflow
if: always()
outputs:
version: ${{ steps.extract.outputs.version }}
npm_tag: ${{ steps.extract.outputs.npm_tag }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Extract version from tag
id: extract
run: |
# For manual dispatch, skip version extraction (will use input instead)
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo "Manual dispatch - version will be provided via input"
echo "version=" >> $GITHUB_OUTPUT
echo "npm_tag=" >> $GITHUB_OUTPUT
exit 0
fi

# For workflow_run, check if release workflow succeeded
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ] || [ "${{ github.event.workflow_run.event }}" != "push" ]; then
echo "Release workflow did not succeed or was not a tag push, skipping"
echo "version=" >> $GITHUB_OUTPUT
echo "npm_tag=" >> $GITHUB_OUTPUT
exit 0
fi

# Try to extract tag from workflow_run head_branch (for tag pushes, this should be refs/tags/v*)
TAG_REF="${{ github.event.workflow_run.head_branch }}"

# If head_branch contains a tag ref, extract it
if [[ "$TAG_REF" == refs/tags/v* ]]; then
TAG_VERSION=${TAG_REF#refs/tags/v}
echo "Extracted version from tag ref: $TAG_VERSION"
else
# Fallback: Query npm for the latest version in the beta tag
echo "Warning: Could not extract tag from head_branch: $TAG_REF"
echo "Attempting to determine version from npm registry..."

# Check beta tag first (most common for feature branch releases)
BETA_VERSION=$(npm view hookdeck-cli@beta version 2>/dev/null || echo "")
if [ -n "$BETA_VERSION" ]; then
TAG_VERSION="$BETA_VERSION"
echo "Using latest beta version: $TAG_VERSION"
else
# Fall back to latest
TAG_VERSION=$(npm view hookdeck-cli@latest version 2>/dev/null || echo "")
echo "Using latest version: $TAG_VERSION"
fi
fi

echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT

# Determine npm tag
NPM_TAG="latest"
if [[ "$TAG_VERSION" == *-* ]]; then
NPM_TAG=$(echo "$TAG_VERSION" | cut -d'-' -f2 | cut -d'.' -f1)
fi
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
echo "Final: version=$TAG_VERSION, npm tag=$NPM_TAG"

test-npm-install:
needs: [determine-version]
# Run if: manual dispatch OR (workflow_run trigger AND determine-version has version output)
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'workflow_run' && needs.determine-version.outputs.version != '')
strategy:
matrix:
include:
- os: macos-latest
platform: darwin
- os: ubuntu-latest
platform: linux
- os: windows-latest
platform: win32
runs-on: ${{ matrix.os }}
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: Determine version to test
id: version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.npm_version || '@beta' }}"
else
VERSION="${{ needs.determine-version.outputs.version }}"
NPM_TAG="${{ needs.determine-version.outputs.npm_tag }}"
# Use npm tag if it's a pre-release
if [ "$NPM_TAG" != "latest" ]; then
VERSION="@${NPM_TAG}"
fi
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Testing version: $VERSION"

- name: Test npm install
uses: ./.github/actions/test-npm-install
with:
version: ${{ steps.version.outputs.version }}
platform: ${{ matrix.platform }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

completions/
dist/
bin/
bin/*
!bin/hookdeck.js
binaries/
coverage.txt
/hookdeck
/hookdeck-darwin
Expand Down
Loading