Skip to content

fix: Correct version extraction in publish workflows (#29) #4

fix: Correct version extraction in publish workflows (#29)

fix: Correct version extraction in publish workflows (#29) #4

Workflow file for this run

name: Publish to Docker Hub
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: "Version (e.g., 1.0.0)"
required: true
type: string
env:
IMAGE_NAME: iexec/mcp-server
jobs:
publish-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
elif [ "${{ github.ref_type }}" = "tag" ]; then
VERSION=${GITHUB_REF_NAME#v}
else
echo "Error: This workflow should only run on tags or workflow_dispatch"
exit 1
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Building Docker image for version: $VERSION"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME}}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.IMAGE_NAME }}:${{ steps.version.outputs.version }}
${{ env.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Success notification
run: |
echo "✅ Docker image published: v${{ steps.version.outputs.version }}"
echo "🐳 https://hub.docker.com/r/${{ env.IMAGE_NAME }}"