Skip to content

Commit 0f28b2d

Browse files
committed
add releasing to tag target
1 parent 308b8ac commit 0f28b2d

File tree

3 files changed

+102
-41
lines changed

3 files changed

+102
-41
lines changed

.github/workflows/tag.yaml

+61-37
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Tag and Push
22

33
on:
4-
release:
5-
types: [created]
4+
push:
5+
tags:
6+
- "v*.*.*"
67
workflow_dispatch:
78
inputs:
89
version:
@@ -18,48 +19,71 @@ jobs:
1819
contents: read
1920
packages: write
2021
steps:
21-
- name: 'Checkout GitHub Action'
22-
uses: actions/checkout@main
22+
- name: 'Checkout GitHub Action'
23+
uses: actions/checkout@main
2324

24-
- name: Login to GitHub Container Registry
25-
uses: docker/login-action@v3
26-
with:
27-
registry: ghcr.io
28-
username: ${{ github.actor }}
29-
password: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Login to GitHub Container Registry
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
3031

31-
- name: 'Build Images'
32-
run: |
33-
# if workflow_dispatch is used, use the version input
34-
if [ -n "${{ github.event.inputs.version }}" ]; then
35-
export VERSION=${{ github.event.inputs.version }}
36-
else
37-
export VERSION=$(echo "$GITHUB_REF" | cut -c8-)
38-
fi
39-
make build
40-
make push
32+
- name: 'Build Images'
33+
run: |
34+
# if workflow_dispatch is used, use the version input
35+
if [ -n "${{ github.event.inputs.version }}" ]; then
36+
export VERSION=${{ github.event.inputs.version }}
37+
else
38+
export VERSION=$(echo "$GITHUB_REF" | cut -c8-)
39+
fi
40+
make build
41+
make push
4142
push-helm-chart:
4243
runs-on: ubuntu-latest
4344
permissions:
4445
contents: read
4546
packages: write
4647
steps:
47-
- name: 'Checkout GitHub Action'
48-
uses: actions/checkout@main
48+
- name: 'Checkout GitHub Action'
49+
uses: actions/checkout@main
4950

50-
- name: Login to GitHub Container Registry
51-
uses: docker/login-action@v3
52-
with:
53-
registry: ghcr.io
54-
username: ${{ github.actor }}
55-
password: ${{ secrets.GITHUB_TOKEN }}
51+
- name: Login to GitHub Container Registry
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
5657

57-
- name: 'Build Image'
58-
run: |
59-
# if workflow_dispatch is used, use the version input
60-
if [ -n "${{ github.event.inputs.version }}" ]; then
61-
export VERSION=${{ github.event.inputs.version }}
62-
else
63-
export VERSION=$(echo "$GITHUB_REF" | cut -c8-)
64-
fi
65-
make helm-publish
58+
- name: 'Build Image'
59+
run: |
60+
# if workflow_dispatch is used, use the version input
61+
if [ -n "${{ github.event.inputs.version }}" ]; then
62+
export VERSION=${{ github.event.inputs.version }}
63+
else
64+
export VERSION=$(echo "$GITHUB_REF" | cut -c8-)
65+
fi
66+
make helm-publish
67+
release:
68+
runs-on: ubuntu-latest
69+
permissions:
70+
contents: write
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@v4
74+
- name: Build
75+
run: |
76+
# if workflow_dispatch is used, use the version input
77+
if [ -n "${{ github.event.inputs.version }}" ]; then
78+
export VERSION=${{ github.event.inputs.version }}
79+
else
80+
export VERSION=$(echo "$GITHUB_REF" | cut -c8-)
81+
fi
82+
make build-cli
83+
- name: Release
84+
uses: softprops/action-gh-release@v2
85+
if: startsWith(github.ref, 'refs/tags/')
86+
with:
87+
files: |
88+
go/bin/kagent-*
89+
helm/kagent-*.tgz

Makefile

+16-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ APP_IMAGE_TAG ?= $(VERSION)
99
CONTROLLER_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(CONTROLLER_IMAGE_NAME):$(CONTROLLER_IMAGE_TAG)
1010
APP_IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_IMAGE_NAME):$(APP_IMAGE_TAG)
1111

12+
# Check if OPENAI_API_KEY is set
1213
check-openai-key:
1314
@if [ -z "$(OPENAI_API_KEY)" ]; then \
1415
echo "Error: OPENAI_API_KEY environment variable is not set"; \
@@ -17,37 +18,50 @@ check-openai-key:
1718
fi
1819

1920
# Build targets
20-
.PHONY: create-kind-cluster build controller-manifests build-controller build-app kind-load-docker-images check-openai-key helm-install helm-publish push
2121

22+
.PHONY: create-kind-cluster
2223
create-kind-cluster:
2324
kind create cluster --name autogen
2425

26+
.PHONY: build
2527
build: build-controller build-app
2628

29+
.PHONY: build-cli
30+
build-cli:
31+
make -C go build
32+
33+
.PHONY: push
2734
push:
2835
docker push $(CONTROLLER_IMG)
2936
docker push $(APP_IMG)
3037

38+
.PHONY: controller-manifests
3139
controller-manifests:
3240
make -C go manifests
3341
cp go/config/crd/bases/* helm/crds/
3442

43+
.PHONY: build-controller
3544
build-controller: controller-manifests
3645
make -C go docker-build
3746

47+
.PHONY: build-app
3848
build-app:
3949
# Build the combined UI and backend image
4050
docker build -t $(APP_IMG) .
4151
# Tag with latest for convenience
4252
docker tag $(APP_IMG) $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(APP_IMAGE_NAME):latest
4353

54+
.PHONY: kind-load-docker-images
4455
kind-load-docker-images: build
4556
kind load docker-image --name autogen $(CONTROLLER_IMG)
4657
kind load docker-image --name autogen $(APP_IMG)
4758

59+
.PHONY: helm-version
4860
helm-version:
4961
VERSION=$(VERSION) envsubst < helm/Chart-template.yaml > helm/Chart.yaml
62+
helm package helm/
5063

64+
.PHONY: helm-install
5165
helm-install: helm-version check-openai-key kind-load-docker-images
5266
helm upgrade --install kagent helm/ \
5367
--namespace kagent \
@@ -56,6 +70,6 @@ helm-install: helm-version check-openai-key kind-load-docker-images
5670
--set app.image.tag=$(APP_IMAGE_TAG) \
5771
--set openai.apiKey=$(OPENAI_API_KEY)
5872

73+
.PHONY: helm-publish
5974
helm-publish: helm-version
60-
helm package helm/
6175
helm push kagent-$(VERSION).tgz oci://ghcr.io/kagent-dev/kagent/helm

go/Makefile

+25-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ VERSION ?= $(shell git describe --tags --always --dirty)
66
IMAGE_TAG ?= $(VERSION)
77
IMG ?= $(DOCKER_REGISTRY)/$(DOCKER_REPO)/$(IMAGE_NAME):$(IMAGE_TAG)
88

9+
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo "unknown")
10+
BUILD_DATE := $(shell date -u '+%Y-%m-%d')
11+
12+
LDFLAGS := -X github.com/kagent-dev/kagent/go/cli/internal/cli.Version=$(VERSION) \
13+
-X github.com/kagent-dev/kagent/go/cli/internal/cli.GitCommit=$(GIT_COMMIT) \
14+
-X github.com/kagent-dev/kagent/go/cli/internal/cli.BuildDate=$(BUILD_DATE)
15+
916
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
1017
ifeq (,$(shell go env GOBIN))
1118
GOBIN=$(shell go env GOPATH)/bin
@@ -91,9 +98,25 @@ lint-config: golangci-lint ## Verify golangci-lint linter configuration
9198

9299
##@ Build
93100

101+
bin/kagent-linux-amd64:
102+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-linux-amd64 ./cli/cmd/kagent
103+
104+
bin/kagent-linux-arm64:
105+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-linux-arm64 ./cli/cmd/kagent
106+
107+
bin/kagent-darwin-amd64:
108+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-darwin-amd64 ./cli/cmd/kagent
109+
110+
bin/kagent-darwin-arm64:
111+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-darwin-arm64 ./cli/cmd/kagent
112+
113+
bin/kagent-windows-amd64:
114+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o bin/kagent-windows-amd64.exe ./cli/cmd/kagent
115+
116+
117+
94118
.PHONY: build
95-
build: manifests generate fmt vet ## Build manager binary.
96-
go build -o bin/manager cmd/main.go
119+
build: bin/kagent-linux-amd64 bin/kagent-linux-arm64 bin/kagent-darwin-amd64 bin/kagent-darwin-arm64 bin/kagent-windows-amd64
97120

98121
.PHONY: run
99122
run: manifests generate fmt vet ## Run a controller from your host.

0 commit comments

Comments
 (0)