deploy.yml•3.33 kB
name: deploy
on:
release:
types: [released]
workflow_dispatch:
inputs:
version:
description: 'Deploy to NuGet and Docker Hub version (e.g., 1.0.0).'
required: true
type: string
workflow_call:
inputs:
version: { required: true, type: string }
secrets:
NUGET_API_KEY: { required: true }
DOCKER_USERNAME: { required: true }
DOCKER_PASSWORD: { required: true }
jobs:
deploy-mcp-server-to-nuget:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
version=${{ inputs.version || github.event.release.tag_name }}
echo "version=$version" >> $GITHUB_OUTPUT
echo "Extracted version: $version"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: |
cd Unity-MCP-Server
dotnet restore com.IvanMurzak.Unity.MCP.Server.csproj
- name: Build
run: |
cd Unity-MCP-Server
dotnet build com.IvanMurzak.Unity.MCP.Server.csproj --no-restore --configuration Release
- name: Test
run: |
cd Unity-MCP-Server
dotnet test com.IvanMurzak.Unity.MCP.Server.csproj --no-build --verbosity normal --configuration Release
- name: Pack NuGet package
run: |
cd Unity-MCP-Server
dotnet pack com.IvanMurzak.Unity.MCP.Server.csproj --no-build --configuration Release --output ./nupkg
- name: Deploy MCP Server NuGet package
run: |
cd Unity-MCP-Server
# Construct the expected .nupkg filename using the version
nupkg_file="./nupkg/com.IvanMurzak.Unity.MCP.Server.${{ steps.version.outputs.version }}.nupkg"
if [ ! -f "$nupkg_file" ]; then
echo "Error: Expected .nupkg file not found: $nupkg_file"
exit 1
fi
echo "Deploying NuGet package: $nupkg_file (version: ${{ steps.version.outputs.version }})"
dotnet nuget push "$nupkg_file" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
deploy-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: |
version=${{ inputs.version || github.event.release.tag_name }}
echo "version=$version" >> $GITHUB_OUTPUT
echo "Extracted version: $version"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./Unity-MCP-Server
push: true
tags: |
ivanmurzakdev/unity-mcp-server:${{ steps.version.outputs.version }}
ivanmurzakdev/unity-mcp-server:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max