-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (135 loc) · 4.63 KB
/
release.yml
File metadata and controls
161 lines (135 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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"