Skip to content

fix(ci): update build path from cmd/mcpserver to cmd/tooltrust-mcp #4

fix(ci): update build path from cmd/mcpserver to cmd/tooltrust-mcp

fix(ci): update build path from cmd/mcpserver to cmd/tooltrust-mcp #4

Workflow file for this run

name: Release
on:
push:
tags:
- "v*.*.*" # triggers on v1.0.0, v0.2.1-beta, etc.
permissions:
contents: write # needed to create GitHub Releases and upload assets
packages: write # needed to push to GHCR
jobs:
# ── 1. Run tests before releasing ─────────────────────────────────────────
test:
name: Pre-release Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- run: go test -race -count=1 ./...
# ── 2. Cross-compile binaries for all target platforms ────────────────────
build:
name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
runs-on: ubuntu-latest
needs: [test]
strategy:
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
- goos: windows
goarch: amd64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # needed for `git describe`
- uses: actions/setup-go@v5
with:
go-version: "1.26"
cache: true
- name: Set version from tag
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Build binaries
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
run: |
SUFFIX=""
if [ "${{ matrix.goos }}" = "windows" ]; then SUFFIX=".exe"; fi
mkdir -p dist
go build \
-ldflags "-X main.version=${VERSION} -s -w" \
-o "dist/tooltrust-scanner_${{ matrix.goos }}_${{ matrix.goarch }}${SUFFIX}" \
./cmd/tooltrust-scanner/
go build \
-ldflags "-X main.version=${VERSION} -s -w" \
-o "dist/tooltrust-mcp_${{ matrix.goos }}_${{ matrix.goarch }}${SUFFIX}" \
./cmd/tooltrust-mcp/
- name: Generate checksums
run: |
cd dist
sha256sum tooltrust-scanner_* tooltrust-mcp_* > checksums_${{ matrix.goos }}_${{ matrix.goarch }}.txt
- name: Upload binary artifacts
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
path: dist/
retention-days: 1
# ── 3. Create GitHub Release ───────────────────────────────────────────────
release:
name: GitHub Release
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Download all binary artifacts
uses: actions/download-artifact@v4
with:
pattern: binaries-*
path: dist/
merge-multiple: true
- name: List release assets
run: ls -lh dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
dist/tooltrust-scanner_*
dist/tooltrust-mcp_*
dist/checksums_*
# ── 4. Build and push Docker image to GHCR ────────────────────────────────
docker:
name: Docker Image
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
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
build-args: |
VERSION=${{ github.ref_name }}