Skip to content

1.0.7 (#29)

1.0.7 (#29) #16

Workflow file for this run

name: Release and Publish Docker Image
on:
push:
branches:
- main
paths:
- 'package.json'
- 'src/**'
- 'Dockerfile'
- 'tsconfig.json'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: read
jobs:
check-version:
name: Check Version Change
runs-on: ubuntu-latest
outputs:
version_changed: ${{ steps.version_check.outputs.changed }}
current_version: ${{ steps.version_check.outputs.version }}
should_build: ${{ steps.version_check.outputs.should_build }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check version change
id: version_check
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Always build on manual trigger (workflow_dispatch)
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "should_build=true" >> $GITHUB_OUTPUT
echo "🚀 Manual trigger - building version $CURRENT_VERSION"
exit 0
fi
# For push events, check if we have a parent commit
if ! git rev-parse HEAD^ >/dev/null 2>&1; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "should_build=true" >> $GITHUB_OUTPUT
echo "🎉 Initial commit - building version $CURRENT_VERSION"
exit 0
fi
# Check if package.json changed in this push
if git diff HEAD^ HEAD --name-only | grep -q "package.json"; then
PREV_VERSION=$(git show HEAD^:package.json | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin', 'utf8')).version")
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "should_build=true" >> $GITHUB_OUTPUT
echo "✅ Version changed from $PREV_VERSION to $CURRENT_VERSION"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "should_build=false" >> $GITHUB_OUTPUT
echo "ℹ️ Version unchanged: $CURRENT_VERSION"
fi
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "should_build=false" >> $GITHUB_OUTPUT
echo "ℹ️ package.json not modified in this push"
fi
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: check-version
if: needs.check-version.outputs.should_build == 'true'
permissions:
contents: write # Required for creating releases
packages: write # Required for pushing to GHCR
id-token: write # Required for OIDC authentication
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: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ needs.check-version.outputs.current_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.check-version.outputs.current_version }}
type=semver,pattern={{major}},value=${{ needs.check-version.outputs.current_version }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=Komodo MCP Server
org.opencontainers.image.description=Model Context Protocol server for Komodo Container Manager
org.opencontainers.image.version=${{ needs.check-version.outputs.current_version }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
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
build-args: |
VERSION=${{ needs.check-version.outputs.current_version }}
- name: Generate release notes
id: release_notes
run: |
VERSION="${{ needs.check-version.outputs.current_version }}"
# Initialize release notes file
echo "# 🦎 Komodo MCP Server - ${VERSION}" > release_notes.md
echo "" >> release_notes.md
# 1. Extract Changelog for this version
echo "## 📝 Changelog" >> release_notes.md
echo "" >> release_notes.md
# Extract content between current version header and the next header (or EOF)
# Matches lines starting with "## [VERSION]" until the next "## ["
if grep -q "^## \[${VERSION}\]" CHANGELOG.md; then
sed -n "/^## \[${VERSION}\]/,/^## \[/p" CHANGELOG.md | sed '1d;$d' | sed '$d' >> release_notes.md
else
echo "⚠️ No changelog entry found for version ${VERSION}." >> release_notes.md
echo "" >> release_notes.md
echo "#### Commits" >> release_notes.md
git log $(git describe --tags --abbrev=0 2>/dev/null || echo "")..HEAD --pretty=format:"- %s (%h)" >> release_notes.md
fi
echo "" >> release_notes.md
# 2. Docker Info
echo "## 🐳 Docker Images" >> release_notes.md
echo "" >> release_notes.md
# Tags
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f1,2)
echo "### 🏷️ Available Tags" >> release_notes.md
echo "> \`latest\`, \`${VERSION}\`, \`${MINOR}\`, \`${MAJOR}\`" >> release_notes.md
echo "" >> release_notes.md
echo '```bash' >> release_notes.md
echo "# Pull image" >> release_notes.md
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> release_notes.md
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}" >> release_notes.md
echo '```' >> release_notes.md
echo "" >> release_notes.md
echo "## 💡 Examples" >> release_notes.md
echo "Check out the [examples](https://github.com/${{ github.repository }}/tree/main/examples) for integration guides with Claude Desktop, n8n, and more." >> release_notes.md
# 3. Useful Links
echo "" >> release_notes.md
echo "---" >> release_notes.md
echo "📄 [Full Changelog](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) | 🐛 [Report Bug](https://github.com/${{ github.repository }}/issues)" >> release_notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.check-version.outputs.current_version }}
name: Komodo MCP Server - ${{ needs.check-version.outputs.current_version }}
body_path: release_notes.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify:
name: Notify Release
runs-on: ubuntu-latest
needs: [check-version, build-and-push]
if: needs.check-version.outputs.should_build == 'true'
steps:
- name: Summary
run: |
echo "## ✅ Release ${{ needs.check-version.outputs.current_version }} Published!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🐳 Docker Images" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.check-version.outputs.current_version }}\`" >> $GITHUB_STEP_SUMMARY
echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 🔗 Links" >> $GITHUB_STEP_SUMMARY
echo "- [Docker Image](${{ env.REGISTRY }}/${{ env.IMAGE_NAME }})" >> $GITHUB_STEP_SUMMARY
echo "- [Release](https://github.com/${{ github.repository }}/releases/tag/${{ needs.check-version.outputs.current_version }})" >> $GITHUB_STEP_SUMMARY