release.yml•5.99 kB
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v1.0.0)'
required: true
type: string
env:
DOCKER_REGISTRY: docker.io
DOCKER_USERNAME: antobrugnot
IMAGE_NAME: qrcode-mcp-server
jobs:
validate-release:
name: Validate Release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="${GITHUB_REF#refs/tags/}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Releasing version: ${VERSION}"
- name: Validate version format
run: |
VERSION="${{ steps.version.outputs.version }}"
if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format: $VERSION"
echo "Expected format: vX.Y.Z (e.g., v1.0.0)"
exit 1
fi
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run tests and build
run: |
npx tsc --noEmit
npm run build
build-release:
name: Build Release Docker Image
runs-on: ubuntu-latest
needs: validate-release
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ needs.validate-release.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.validate-release.outputs.version }}
type=semver,pattern={{major}},value=${{ needs.validate-release.outputs.version }}
type=raw,value=latest
- name: Build and push release image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [validate-release, build-release]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate changelog
id: changelog
run: |
VERSION="${{ needs.validate-release.outputs.version }}"
VERSION=${VERSION#v}
# Get the previous tag to generate diff
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
echo "## 🚀 Release ${VERSION}" > CHANGELOG.md
echo "" >> CHANGELOG.md
# Add commits section
echo "### 📝 Changes in this Release" >> CHANGELOG.md
echo "" >> CHANGELOG.md
if [ -n "$PREVIOUS_TAG" ]; then
echo "**Commits since ${PREVIOUS_TAG}:**" >> CHANGELOG.md
echo "" >> CHANGELOG.md
# Get commits between previous tag and current commit
git log --pretty=format:"- %s (%h) - %an" ${PREVIOUS_TAG}..HEAD >> CHANGELOG.md
else
echo "**All commits in this release:**" >> CHANGELOG.md
echo "" >> CHANGELOG.md
# Get all commits if no previous tag
git log --pretty=format:"- %s (%h) - %an" >> CHANGELOG.md
fi
echo "" >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo "### 🐳 Docker Image" >> CHANGELOG.md
echo "- \`docker pull antobrugnot/qrcode-mcp-server:${VERSION}\`" >> CHANGELOG.md
echo "- \`docker pull antobrugnot/qrcode-mcp-server:latest\`" >> CHANGELOG.md
echo "" >> CHANGELOG.md
echo "### 🔧 Usage with Claude Desktop" >> CHANGELOG.md
echo "\`\`\`json" >> CHANGELOG.md
echo "{" >> CHANGELOG.md
echo " \"mcpServers\": {" >> CHANGELOG.md
echo " \"qrcode-generator\": {" >> CHANGELOG.md
echo " \"command\": \"docker\"," >> CHANGELOG.md
echo " \"args\": [\"run\", \"-i\", \"--rm\", \"antobrugnot/qrcode-mcp-server:${VERSION}\"]" >> CHANGELOG.md
echo " }" >> CHANGELOG.md
echo " }" >> CHANGELOG.md
echo "}" >> CHANGELOG.md
echo "\`\`\`" >> CHANGELOG.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.validate-release.outputs.version }}
name: Release ${{ needs.validate-release.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
notify-success:
name: Notify Success
runs-on: ubuntu-latest
needs: [validate-release, build-release, github-release]
if: success()
steps:
- name: Success notification
run: |
echo "🎉 Release ${{ needs.validate-release.outputs.version }} completed successfully!"
echo "✅ Docker image: antobrugnot/qrcode-mcp-server:${{ needs.validate-release.outputs.version }}"
echo "✅ GitHub release: https://github.com/${{ github.repository }}/releases/tag/${{ needs.validate-release.outputs.version }}"