Skip to content

Merge pull request #36 from Countly/ar2rsawseen/main #3

Merge pull request #36 from Countly/ar2rsawseen/main

Merge pull request #36 from Countly/ar2rsawseen/main #3

Workflow file for this run

name: Release (npm & Docker)
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.1)'
required: true
type: string
publish-npm:
description: 'Publish to npm'
required: false
type: boolean
default: true
publish-docker:
description: 'Publish to Docker Hub'
required: false
type: boolean
default: true
env:
DOCKER_IMAGE: countly/countly-mcp-server
DOCKERHUB_USERNAME: countly
permissions:
id-token: write # Required for npm OIDC
contents: read
jobs:
test-and-build:
runs-on: ubuntu-latest
name: Test & Build
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run tests (with transport integration tests)
run: npm run test:ci
env:
COUNTLY_SERVER_URL: https://test.count.ly
COUNTLY_AUTH_TOKEN: test-token-for-ci
- name: Upload build artifacts
uses: actions/upload-artifact@v5
with:
name: build
path: build/
retention-days: 1
publish-npm:
runs-on: ubuntu-latest
needs: test-and-build
name: Publish to npm
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish-npm)
permissions:
contents: read
id-token: write # Required for npm OIDC publish
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: npm ci
- name: Download build artifacts
uses: actions/download-artifact@v6
with:
name: build
path: build/
- name: Update package.json version (manual trigger only)
if: github.event_name == 'workflow_dispatch'
run: npm version ${{ inputs.version }} --no-git-tag-version
- name: Publish to npm (via OIDC trusted publisher)
run: npm publish --access public
publish-docker:
runs-on: ubuntu-latest
needs: test-and-build
name: Build & Push Docker Image
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.publish-docker)
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract version from tag or input
id: meta
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
VERSION="${{ inputs.version }}"
elif [[ "$GITHUB_REF" == refs/tags/v* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION="dev-${GITHUB_SHA::8}"
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building version: $VERSION"
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
${{ env.DOCKER_IMAGE }}:latest
cache-from: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.DOCKER_IMAGE }}:buildcache,mode=max
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKER_IMAGE }}
readme-filepath: ./DOCKER.md
short-description: "MCP server for Countly Analytics - Access 40+ analytics tools via Model Context Protocol"