name: Publish to NPM
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (leave empty for current package.json version)'
required: false
type: string
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
- name: Build project
run: npm run build
- name: Test binary installation
run: |
npm pack
npm install -g yt-transcript-dl-mcp-*.tgz
yt-transcript-dl-mcp --help
publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Update version (if specified)
if: github.event.inputs.version != ''
run: npm version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Get package version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create GitHub Release (if manual trigger)
if: github.event_name == 'workflow_dispatch'
run: |
gh release create v${{ steps.version.outputs.version }} \
--title "Release v${{ steps.version.outputs.version }}" \
--notes "## Changes
Automated release for version ${{ steps.version.outputs.version }}
## Installation
\`\`\`bash
npm install -g yt-transcript-dl-mcp
\`\`\`
## Usage
\`\`\`bash
# Start single transport mode
yt-transcript-dl-mcp
# Start multi-transport mode
yt-transcript-dl-mcp --multi-transport
\`\`\`"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get package version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }}
type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=YouTube Transcript MCP Server
org.opencontainers.image.description=MCP server for YouTube transcript extraction with multi-transport support
org.opencontainers.image.vendor=Claude Code
org.opencontainers.image.licenses=MIT
org.opencontainers.image.version=${{ steps.version.outputs.version }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }}
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/main/README.md
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
post-publish:
needs: [publish, docker]
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get package version
id: version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Verify NPM publication
run: |
# Wait for NPM to propagate
sleep 30
# Check if package is available
npm view yt-transcript-dl-mcp version
# Test installation from NPM
npm install -g yt-transcript-dl-mcp
# Verify binary works
yt-transcript-dl-mcp --help
- name: Test Docker image from GHCR
run: |
# Wait for GHCR to propagate
sleep 30
# Pull and test the published image
docker pull ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
docker run --rm ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} --help
- name: Notify success
run: |
echo "✅ Package successfully published!"
echo "📦 NPM: https://www.npmjs.com/package/yt-transcript-dl-mcp"
echo "🐳 Docker: ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}"
echo "📚 Docs: ${{ github.server_url }}/${{ github.repository }}"