generated from IvanMurzak/Unity-Package-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 140
165 lines (140 loc) · 5.19 KB
/
deploy.yml
File metadata and controls
165 lines (140 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# ┌──────────────────────────────────────────────────────────────────┐
# │ Author: Ivan Murzak (https://github.com/IvanMurzak) │
# │ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
# │ Copyright (c) 2025 Ivan Murzak │
# │ Licensed under the Apache License, Version 2.0. │
# │ See the LICENSE file in the project root for more information. │
# └──────────────────────────────────────────────────────────────────┘
name: deploy
on:
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:
DOCKER_USERNAME: { required: true }
DOCKER_PASSWORD: { required: true }
jobs:
deploy-mcp-server-to-nuget:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
- 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@v5
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: NuGet login (Trusted Publishing)
uses: NuGet/login@v1
id: nuget-login
with:
user: IvanMurzak
- 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 ${{ steps.nuget-login.outputs.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@v6
- name: Extract version from tag
id: version
run: |
version=${{ inputs.version }}
echo "version=$version" >> $GITHUB_OUTPUT
echo "Extracted version: $version"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v7
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
deploy-cli-to-npm:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Extract version from tag
id: version
run: |
version=${{ inputs.version }}
echo "version=$version" >> $GITHUB_OUTPUT
echo "Extracted version: $version"
- name: Set package version
run: |
cd cli
npm version ${{ steps.version.outputs.version }} --no-git-tag-version --allow-same-version
- name: Install dependencies
run: |
cd cli
npm ci
- name: Build
run: |
cd cli
npm run build
- name: Test
run: |
cd cli
npm test
- name: Publish to npm with provenance
run: |
cd cli
npm publish --access public --provenance