Skip to content

Commit 4ad1fd5

Browse files
chore: fix publish workflow for MCP registry
1 parent 3082fbf commit 4ad1fd5

File tree

3 files changed

+103
-27
lines changed

3 files changed

+103
-27
lines changed

.github/actions/docker-publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: Build and Push Docker Image
3+
on:
4+
workflow_call:
5+
secrets:
6+
DOCKERHUB_USERNAME:
7+
required: true
8+
DOCKERHUB_PASSWORD:
9+
required: true
10+
11+
jobs:
12+
build-push:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
17+
with:
18+
persist-credentials: false
19+
20+
- name: Get version and date
21+
id: release-meta
22+
run: |
23+
VERSION=$(npm pkg get version | tr -d '"')
24+
DATE=$(date +'%Y-%m-%d')
25+
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
26+
echo "DATE=${DATE}" >> "$GITHUB_OUTPUT"
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
30+
31+
- name: Login to Docker Hub
32+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
33+
with:
34+
username: "${{ secrets.DOCKERHUB_USERNAME }}"
35+
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
36+
37+
- name: Build and push image to dockerhub registry
38+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
39+
with:
40+
context: .
41+
platforms: linux/amd64,linux/arm64
42+
tags: ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:latest, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.release-meta.outputs.VERSION }}, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.release-meta.outputs.VERSION }}-${{ steps.release-meta.outputs.DATE }}
43+
file: Dockerfile
44+
push: true
45+
provenance: mode=max
46+
sbom: true
47+
build-args: |
48+
VERSION=${{ steps.release-meta.outputs.VERSION }}

.github/workflows/docker.yml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ permissions:
77
contents: read
88
issues: write
99
jobs:
10-
push:
10+
docker-push:
11+
uses: ./.github/actions/docker-publish.yml
12+
secrets:
13+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
14+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
15+
16+
handle-failure:
1117
runs-on: ubuntu-latest
18+
needs: docker-push
19+
if: ${{ failure() }}
1220
steps:
1321
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
1422
with:
@@ -17,43 +25,22 @@ jobs:
1725
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
1826
with:
1927
persist-credentials: false
20-
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
22-
- name: Login to Docker Hub
23-
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
24-
with:
25-
username: "${{ secrets.DOCKERHUB_USERNAME }}"
26-
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
27-
- name: Set date and version
28-
id: set-properties
28+
- name: Get version and date
29+
id: release-meta
2930
run: |
30-
DATE=$(date +'%Y-%m-%d')
3131
VERSION=$(npm pkg get version | tr -d '"')
32-
echo "DATE=${DATE}" >> "$GITHUB_OUTPUT"
32+
DATE=$(date +'%Y-%m-%d')
3333
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
34-
- name: Build and push image to dockerhub registry
35-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
36-
with:
37-
context: .
38-
platforms: linux/amd64,linux/arm64
39-
tags: ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:latest, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.set-properties.outputs.VERSION }}, ${{ vars.DOCKERHUB_IMAGE_REPOSITORY }}:${{ steps.set-properties.outputs.VERSION }}-${{ steps.set-properties.outputs.DATE }}
40-
file: Dockerfile
41-
push: true
42-
provenance: mode=max
43-
sbom: true
44-
build-args: |
45-
VERSION=${{ steps.set-properties.outputs.VERSION }}
34+
echo "DATE=${DATE}" >> "$GITHUB_OUTPUT"
4635
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
4736
id: app-token
48-
if: ${{ failure() }}
4937
with:
5038
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
5139
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
5240
- name: Create Issue
53-
if: ${{ failure() }}
5441
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
5542
with:
5643
token: ${{ steps.app-token.outputs.token }}
57-
title: Release Failure for Docker Image ${{ steps.set-properties.outputs.VERSION }}-${{ steps.set-properties.outputs.DATE }}
44+
title: Release Failure for Docker Image ${{ steps.release-meta.outputs.VERSION }}-${{ steps.release-meta.outputs.DATE }}
5845
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
5946
labels: "docker, release_failure"

.github/workflows/publish.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,47 @@ jobs:
101101
run: |
102102
gh release create ${{ needs.check.outputs.VERSION }} --title "${{ needs.check.outputs.VERSION }}" --generate-notes --target ${{ github.sha }} ${{ (needs.check.outputs.RELEASE_CHANNEL != 'latest' && '--prerelease') || ''}}
103103
104+
- name: Wait for package to be available on npm
105+
run: |
106+
PACKAGE_NAME=$(jq -r '.name' < package.json)
107+
VERSION="${{ needs.check.outputs.VERSION }}"
108+
MAX_ATTEMPTS=30
109+
SLEEP_SECONDS=10
110+
111+
echo "Waiting for ${PACKAGE_NAME}@${VERSION} to be available on npm..."
112+
113+
for i in $(seq 1 $MAX_ATTEMPTS); do
114+
if npm view "${PACKAGE_NAME}@${VERSION}" version >/dev/null 2>&1; then
115+
echo "✓ Package ${PACKAGE_NAME}@${VERSION} is now available on npm"
116+
exit 0
117+
fi
118+
echo "Attempt $i/$MAX_ATTEMPTS: Package not yet available, waiting ${SLEEP_SECONDS}s..."
119+
sleep $SLEEP_SECONDS
120+
done
121+
122+
echo "::error::Package ${PACKAGE_NAME}@${VERSION} did not become available after $((MAX_ATTEMPTS * SLEEP_SECONDS)) seconds"
123+
exit 1
124+
125+
docker-push:
126+
needs: [check, publish]
127+
uses: ./.github/actions/docker-publish.yml
128+
secrets:
129+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
130+
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
131+
132+
mcp-publish:
133+
runs-on: ubuntu-latest
134+
environment: Production
135+
permissions:
136+
id-token: write
137+
needs: [check, docker-build]
138+
if: needs.check.outputs.VERSION_EXISTS == 'false'
139+
steps:
140+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
141+
- uses: actions/checkout@v5
142+
with:
143+
persist-credentials: false
144+
104145
- name: Install MCP Publisher
105146
run: |
106147
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher

0 commit comments

Comments
 (0)