Skip to content

Commit 53df277

Browse files
authored
Merge branch 'main' into fix_ci
2 parents 85948fd + 28f8eaf commit 53df277

35 files changed

+5949
-23
lines changed

.github/ko-ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ builds:
1919

2020
- id: thv-proxyrunner
2121
dir: ./cmd/thv-proxyrunner
22+
ldflags:
23+
- -s -w
24+
- -X github.com/stacklok/toolhive/pkg/versions.Version={{.Env.VERSION}}
25+
- -X github.com/stacklok/toolhive/pkg/versions.Commit={{.Env.COMMIT}}
26+
- -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.Env.BUILD_DATE}}
27+
- -X github.com/stacklok/toolhive/pkg/versions.BuildType=release
28+
29+
- id: vmcp
30+
dir: ./cmd/vmcp
2231
ldflags:
2332
- -s -w
2433
- -X github.com/stacklok/toolhive/pkg/versions.Version={{.Env.VERSION}}

.github/workflows/image-build-and-publish.yml

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ jobs:
5050
run: |
5151
TAG=${{ steps.version-string.outputs.tag }}
5252
TAGS="-t $TAG"
53-
53+
5454
# Add latest tag only if building from a tag
5555
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
5656
TAGS="$TAGS -t latest"
5757
fi
58-
58+
5959
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/thv \
6060
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive",org.opencontainers.image.vendor=Stacklok
6161
@@ -66,7 +66,7 @@ jobs:
6666
TAG=${{ steps.version-string.outputs.tag }}
6767
# Sign the ko image
6868
cosign sign -y $BASE_REPO:$TAG
69-
69+
7070
# Sign the latest tag if building from a tag
7171
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
7272
cosign sign -y $BASE_REPO:latest
@@ -204,12 +204,12 @@ jobs:
204204
run: |
205205
TAG=${{ steps.version-string.outputs.tag }}
206206
TAGS="-t $TAG"
207-
207+
208208
# Add latest tag only if building from a tag
209209
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
210210
TAGS="$TAGS -t latest"
211211
fi
212-
212+
213213
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/thv-operator \
214214
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive-operator",org.opencontainers.image.vendor=Stacklok
215215
@@ -236,7 +236,7 @@ jobs:
236236
# Sign the ko image
237237
cosign sign -y $BASE_REPO:$TAG
238238
cosign sign -y $BASE_REPO:$UBI_TAG
239-
239+
240240
# Sign the latest tag if building from a tag
241241
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
242242
cosign sign -y $BASE_REPO:latest
@@ -303,12 +303,10 @@ jobs:
303303
run: |
304304
TAG=${{ steps.version-string.outputs.tag }}
305305
TAGS="-t $TAG"
306-
307306
# Add latest tag only if building from a tag
308307
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
309308
TAGS="$TAGS -t latest"
310309
fi
311-
312310
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/thv-proxyrunner \
313311
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive-proxyrunner",org.opencontainers.image.vendor=Stacklok
314312
@@ -335,7 +333,87 @@ jobs:
335333
# Sign the ko image
336334
cosign sign -y $BASE_REPO:$TAG
337335
cosign sign -y $BASE_REPO:$UBI_TAG
338-
336+
337+
# Sign the latest tag if building from a tag
338+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
339+
cosign sign -y $BASE_REPO:latest
340+
fi
341+
342+
vmcp-image-build-and-publish:
343+
name: Build and Publish Virtual MCP Server Image
344+
runs-on: ubuntu-latest
345+
permissions:
346+
contents: write
347+
packages: write
348+
id-token: write
349+
350+
env:
351+
BASE_REPO: "ghcr.io/stacklok/toolhive/vmcp"
352+
353+
steps:
354+
- name: Checkout repository
355+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
356+
357+
- name: Set up Go
358+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6
359+
with:
360+
go-version-file: go.mod
361+
362+
- name: Compute version number
363+
id: version-string
364+
run: |
365+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
366+
# For main branch, use semver with -dev suffix
367+
echo "tag=0.0.1-dev.$GITHUB_RUN_NUMBER+$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
368+
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
369+
# For tags, use the tag as is (assuming it's semver)
370+
TAG="${{ github.ref_name }}"
371+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
372+
else
373+
# For other branches, use branch name and run number
374+
BRANCH="${{ github.ref_name }}"
375+
echo "tag=0.0.1-$BRANCH.$GITHUB_RUN_NUMBER+$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
376+
fi
377+
378+
- name: Login to GitHub Container Registry
379+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
380+
with:
381+
registry: ghcr.io
382+
username: ${{ github.actor }}
383+
password: ${{ secrets.GITHUB_TOKEN }}
384+
385+
- name: Setup ko
386+
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
387+
388+
- name: Install Cosign
389+
uses: sigstore/cosign-installer@7e8b541eb2e61bf99390e1afd4be13a184e9ebc5 # v3.10.1
390+
391+
- name: Build and Push Image to GHCR
392+
env:
393+
VERSION: ${{ steps.version-string.outputs.tag }}
394+
COMMIT: ${{ github.sha }}
395+
BUILD_DATE: ${{ github.event.head_commit.timestamp }}
396+
KO_CONFIG_PATH: ${{ github.workspace }}/.github/ko-ci.yml
397+
run: |
398+
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
399+
TAGS="-t $TAG"
400+
401+
# Add latest tag only if building from a tag
402+
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
403+
TAGS="$TAGS -t latest"
404+
fi
405+
406+
KO_DOCKER_REPO=$BASE_REPO ko build --platform=linux/amd64,linux/arm64 --bare $TAGS ./cmd/vmcp \
407+
--image-label=org.opencontainers.image.source=https://github.com/stacklok/toolhive,org.opencontainers.image.title="toolhive-vmcp",org.opencontainers.image.vendor=Stacklok
408+
409+
- name: Sign Image with Cosign
410+
# This step uses the identity token to provision an ephemeral certificate
411+
# against the sigstore community Fulcio instance.
412+
run: |
413+
TAG=$(echo "${{ steps.version-string.outputs.tag }}" | sed 's/+/_/g')
414+
# Sign the ko image
415+
cosign sign -y $BASE_REPO:$TAG
416+
339417
# Sign the latest tag if building from a tag
340418
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
341419
cosign sign -y $BASE_REPO:latest

Taskfile.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,37 @@ tasks:
171171
cmds:
172172
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/thv
173173

174+
build-vmcp:
175+
desc: Build the vmcp binary
176+
deps: [gen]
177+
vars:
178+
VERSION:
179+
sh: git describe --tags --always --dirty --match "v*" || echo "dev"
180+
COMMIT:
181+
sh: git rev-parse --short HEAD || echo "unknown"
182+
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
183+
cmds:
184+
- cmd: mkdir -p bin
185+
platforms: [linux, darwin]
186+
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp ./cmd/vmcp
187+
platforms: [linux, darwin]
188+
- cmd: cmd.exe /c mkdir bin
189+
platforms: [windows]
190+
ignore_error: true
191+
- cmd: go build -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -o bin/vmcp.exe ./cmd/vmcp
192+
platforms: [windows]
193+
194+
install-vmcp:
195+
desc: Install the vmcp binary to GOPATH/bin
196+
vars:
197+
VERSION:
198+
sh: git describe --tags --always --dirty --match "v*" || echo "dev"
199+
COMMIT:
200+
sh: git rev-parse --short HEAD || echo "unknown"
201+
BUILD_DATE: '{{dateInZone "2006-01-02T15:04:05Z" (now) "UTC"}}'
202+
cmds:
203+
- go install -ldflags "-s -w -X github.com/stacklok/toolhive/pkg/versions.Version={{.VERSION}} -X github.com/stacklok/toolhive/pkg/versions.Commit={{.COMMIT}} -X github.com/stacklok/toolhive/pkg/versions.BuildDate={{.BUILD_DATE}}" -v ./cmd/vmcp
204+
174205
all:
175206
desc: Run linting, tests, and build
176207
deps: [lint, test, build]
@@ -186,12 +217,18 @@ tasks:
186217
cmds:
187218
- ko build --local --bare ./cmd/thv
188219

220+
build-vmcp-image:
221+
desc: Build the vmcp image with ko
222+
env:
223+
KO_DOCKER_REPO: ghcr.io/stacklok/toolhive/vmcp
224+
cmds:
225+
- ko build --local --bare ./cmd/vmcp
189226

190227
build-egress-proxy:
191228
desc: Build the egress proxy container image
192229
cmds:
193230
- docker build --load -t ghcr.io/stacklok/toolhive/egress-proxy:local containers/egress-proxy/
194231

195232
build-all-images:
196-
desc: Build all container images (main app and egress proxy)
197-
deps: [build-image, build-egress-proxy]
233+
desc: Build all container images (main app, vmcp, and egress proxy)
234+
deps: [build-image, build-vmcp-image, build-egress-proxy]

0 commit comments

Comments
 (0)