Skip to content

Commit 2f2c6a3

Browse files
Code2Lifeclaude
andauthored
feat: make api/v1 independently importable as a Go sub-module (#571)
Extract api/v1 into a standalone Go module (api/go.mod) so external projects can `go get github.com/NexusGPU/tensor-fusion/api` without pulling the entire operator dependency tree (NVML, AWS SDK, gorm, etc.). - Add api/v1/constants.go with phase, condition, and domain constants - Remove pkg/constants dependency from all api/v1 type files - Add api/go.mod with minimal k8s v0.35.0 dependencies - Add replace directive in root go.mod for local development - Add release-api.yml workflow for automatic api module tagging Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 55025d4 commit 2f2c6a3

File tree

10 files changed

+415
-40
lines changed

10 files changed

+415
-40
lines changed

.github/workflows/release-api.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Release API Module
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- v1
8+
- release/**
9+
paths:
10+
- "api/**"
11+
workflow_dispatch:
12+
13+
jobs:
14+
release-api:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
fetch-tags: true
23+
24+
- name: Check for api/ changes
25+
id: changes
26+
env:
27+
EVENT_NAME: ${{ github.event_name }}
28+
run: |
29+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
30+
echo "changed=true" >> "$GITHUB_OUTPUT"
31+
exit 0
32+
fi
33+
# Compare with parent commit to see if api/ files changed
34+
if git diff --name-only HEAD~1 HEAD | grep -q '^api/'; then
35+
echo "changed=true" >> "$GITHUB_OUTPUT"
36+
else
37+
echo "changed=false" >> "$GITHUB_OUTPUT"
38+
fi
39+
40+
- name: Compute next api version
41+
if: steps.changes.outputs.changed == 'true'
42+
id: version
43+
run: |
44+
# Find latest api/v* tag
45+
LATEST=$(git tag -l 'api/v*' --sort=-v:refname | head -1)
46+
if [ -z "$LATEST" ]; then
47+
NEXT="api/v0.1.0"
48+
else
49+
# Strip api/v prefix, bump patch
50+
VER="${LATEST#api/v}"
51+
MAJOR=$(echo "$VER" | cut -d. -f1)
52+
MINOR=$(echo "$VER" | cut -d. -f2)
53+
PATCH=$(echo "$VER" | cut -d. -f3)
54+
PATCH=$((PATCH + 1))
55+
NEXT="api/v${MAJOR}.${MINOR}.${PATCH}"
56+
fi
57+
echo "tag=$NEXT" >> "$GITHUB_OUTPUT"
58+
echo "Next API version: $NEXT"
59+
60+
- name: Create and push tag
61+
if: steps.changes.outputs.changed == 'true'
62+
env:
63+
TAG: ${{ steps.version.outputs.tag }}
64+
run: |
65+
git tag "$TAG"
66+
git push origin "$TAG"
67+
68+
- name: Create GitHub release
69+
if: steps.changes.outputs.changed == 'true'
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
TAG: ${{ steps.version.outputs.tag }}
73+
COMMIT_SHA: ${{ github.sha }}
74+
run: |
75+
VER="${TAG#api/}"
76+
PREV=$(git tag -l 'api/v*' --sort=-v:refname | sed -n '2p')
77+
CHANGELOG=""
78+
if [ -n "$PREV" ]; then
79+
CHANGES=$(git log "${PREV}..${TAG}" --pretty=format:"- %s" -- api/)
80+
if [ -n "$CHANGES" ]; then
81+
CHANGELOG="### Changes
82+
${CHANGES}"
83+
fi
84+
fi
85+
gh release create "$TAG" \
86+
--title "API Module ${VER}" \
87+
--target "$COMMIT_SHA" \
88+
--notes "### Usage
89+
\`\`\`bash
90+
go get github.com/NexusGPU/tensor-fusion/api@${VER}
91+
\`\`\`
92+
93+
${CHANGELOG}"

api/go.mod

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
module github.com/NexusGPU/tensor-fusion/api
2+
3+
go 1.25.5
4+
5+
require (
6+
k8s.io/api v0.35.0
7+
k8s.io/apimachinery v0.35.0
8+
k8s.io/kube-scheduler v0.35.0
9+
sigs.k8s.io/controller-runtime v0.23.1
10+
)
11+
12+
require (
13+
cel.dev/expr v0.24.0 // indirect
14+
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
15+
github.com/beorn7/perks v1.0.1 // indirect
16+
github.com/blang/semver/v4 v4.0.0 // indirect
17+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
18+
github.com/davecgh/go-spew v1.1.1 // indirect
19+
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
20+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
21+
github.com/go-logr/logr v1.4.3 // indirect
22+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
23+
github.com/go-openapi/jsonreference v0.20.2 // indirect
24+
github.com/go-openapi/swag v0.23.0 // indirect
25+
github.com/google/cel-go v0.26.0 // indirect
26+
github.com/google/gnostic-models v0.7.0 // indirect
27+
github.com/google/go-cmp v0.7.0 // indirect
28+
github.com/google/uuid v1.6.0 // indirect
29+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
30+
github.com/josharian/intern v1.0.0 // indirect
31+
github.com/json-iterator/go v1.1.12 // indirect
32+
github.com/mailru/easyjson v0.7.7 // indirect
33+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
34+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
35+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
36+
github.com/pmezard/go-difflib v1.0.0 // indirect
37+
github.com/prometheus/client_golang v1.23.2 // indirect
38+
github.com/prometheus/client_model v0.6.2 // indirect
39+
github.com/prometheus/common v0.66.1 // indirect
40+
github.com/prometheus/procfs v0.16.1 // indirect
41+
github.com/spf13/cobra v1.10.0 // indirect
42+
github.com/spf13/pflag v1.0.9 // indirect
43+
github.com/stoewer/go-strcase v1.3.0 // indirect
44+
github.com/x448/float16 v0.8.4 // indirect
45+
go.opentelemetry.io/otel v1.36.0 // indirect
46+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
47+
go.yaml.in/yaml/v2 v2.4.3 // indirect
48+
go.yaml.in/yaml/v3 v3.0.4 // indirect
49+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
50+
golang.org/x/net v0.47.0 // indirect
51+
golang.org/x/oauth2 v0.30.0 // indirect
52+
golang.org/x/sync v0.18.0 // indirect
53+
golang.org/x/sys v0.38.0 // indirect
54+
golang.org/x/term v0.37.0 // indirect
55+
golang.org/x/text v0.31.0 // indirect
56+
golang.org/x/time v0.9.0 // indirect
57+
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
58+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
59+
google.golang.org/protobuf v1.36.8 // indirect
60+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
61+
gopkg.in/inf.v0 v0.9.1 // indirect
62+
gopkg.in/yaml.v3 v3.0.1 // indirect
63+
k8s.io/apiserver v0.35.0 // indirect
64+
k8s.io/client-go v0.35.0 // indirect
65+
k8s.io/component-base v0.35.0 // indirect
66+
k8s.io/component-helpers v0.35.0 // indirect
67+
k8s.io/dynamic-resource-allocation v0.35.0 // indirect
68+
k8s.io/klog/v2 v2.130.1 // indirect
69+
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
70+
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect
71+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
72+
sigs.k8s.io/randfill v1.0.0 // indirect
73+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2-0.20260122202528-d9cc6641c482 // indirect
74+
sigs.k8s.io/yaml v1.6.0 // indirect
75+
)

0 commit comments

Comments
 (0)