File tree Expand file tree Collapse file tree 3 files changed +32
-19
lines changed Expand file tree Collapse file tree 3 files changed +32
-19
lines changed Original file line number Diff line number Diff line change 29
29
run : script/test
30
30
31
31
- name : Prepare build_info files
32
- shell : bash
33
- run : |
34
- BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
35
- mkdir -p cmd/github-mcp-server/build_info
36
- echo "${{ github.sha }}" > cmd/github-mcp-server/build_info/commit.txt
37
- echo "$BUILD_DATE" > cmd/github-mcp-server/build_info/date.txt
38
- if [ "${{ github.event_name }}" = "push" ]; then
39
- echo "${{ github.ref_name }}" > cmd/github-mcp-server/build_info/version.txt
40
- else
41
- echo "pr-${{ github.event.pull_request.number }}" > cmd/github-mcp-server/build_info/version.txt
42
- fi
32
+ run : script/prepare-build-info
33
+
43
34
- name : Build
44
35
run : go build -v ./cmd/github-mcp-server
Original file line number Diff line number Diff line change 1
1
FROM golang:1.24.4-alpine AS build
2
- ARG VERSION="dev"
3
2
4
3
# Set the working directory
5
4
WORKDIR /build
@@ -8,18 +7,12 @@ WORKDIR /build
8
7
RUN --mount=type=cache,target=/var/cache/apk \
9
8
apk add git
10
9
11
- # Prepare build_info files
12
- RUN --mount=type=bind,target=. \
13
- mkdir -p cmd/github-mcp-server/build_info && \
14
- git rev-parse HEAD > cmd/github-mcp-server/build_info/commit.txt && \
15
- date -u +%Y-%m-%dT%H:%M:%SZ > cmd/github-mcp-server/build_info/date.txt && \
16
- echo "${VERSION}" > cmd/github-mcp-server/build_info/version.txt
17
-
18
10
# Build the server
19
11
# go build automatically download required module dependencies to /go/pkg/mod
20
12
RUN --mount=type=cache,target=/go/pkg/mod \
21
13
--mount=type=cache,target=/root/.cache/go-build \
22
14
--mount=type=bind,target=. \
15
+ script/prepare-build-info && \
23
16
CGO_ENABLED=0 go build -ldflags="-s -w" \
24
17
-o /bin/github-mcp-server cmd/github-mcp-server/main.go
25
18
Original file line number Diff line number Diff line change
1
+
2
+ #!/bin/sh
3
+ set -eu
4
+
5
+ mkdir -p cmd/github-mcp-server/build_info
6
+
7
+ BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
8
+
9
+ if [ -n "${GITHUB_ACTIONS:-}" ]; then
10
+ # GitHub Actions context
11
+ COMMIT="${GITHUB_SHA}"
12
+
13
+ if [ "${GITHUB_EVENT_NAME}" = "push" ] && [ "${GITHUB_REF_TYPE}" = "tag" ]; then
14
+ VERSION="${GITHUB_REF_NAME}"
15
+ elif [ "${GITHUB_EVENT_NAME}" = "push" ]; then
16
+ VERSION="${GITHUB_REF_NAME}-${GITHUB_SHA}"
17
+ else
18
+ VERSION="pr-${GITHUB_EVENT_PULL_REQUEST_NUMBER}"
19
+ fi
20
+ else
21
+ # Local/Docker context
22
+ COMMIT=$(git rev-parse HEAD 2>/dev/null || echo 'unknown')
23
+ VERSION="dev"
24
+ fi
25
+
26
+ # Write build info files
27
+ echo "${COMMIT}" > cmd/github-mcp-server/build_info/commit.txt
28
+ echo "${BUILD_DATE}" > cmd/github-mcp-server/build_info/date.txt
29
+ echo "${VERSION}" > cmd/github-mcp-server/build_info/version.txt
You can’t perform that action at this time.
0 commit comments