Skip to content

Commit

Permalink
fix release for new
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Sep 30, 2024
1 parent dbfc2a3 commit 4ba5fb3
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update_version_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
run: |
cat << EOF > .tagpr
[tagpr]
vPrefix = false
vPrefix = true
releaseBranch = main
versionFile = .tagpr,Makefile,deploy/charts/automq-operator/Chart.yaml
command = IMG=ghcr.io/cuisongliu/automq-operator:v${{ github.event.inputs.version }} VERSION=${{ github.event.inputs.version }} make pre-deploy
command = go run gen.go ghcr.io/cuisongliu/automq-operator:${{ github.event.inputs.version }} && make check
release = false
changelog = true
EOF
Expand Down
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,7 @@ $(ENVTEST): $(LOCALBIN)
crd: manifests kustomize ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
@cp -rf config/crd/bases/* deploy/charts/automq-operator/crds/

VERSION ?= v0.0.1
.PHONY: pre-deploy
pre-deploy:
@mkdir -p deploy/images/shim
@rm -f deploy/images/shim/image.txt
@echo "${IMG}" > deploy/images/shim/image.txt
@sed -i '/#replace_by_makefile/!b;n;c\image: ${IMG}' deploy/charts/automq-operator/values.yaml
@sed -i '/#replace_by_makefile/!b;n;c\version: ${VERSION}' deploy/charts/automq-operator/Chart.yaml
info:
@cat deploy/charts/automq-operator/values.yaml
@cat deploy/charts/automq-operator/Chart.yaml
@cat deploy/images/shim/image.txt
60 changes: 60 additions & 0 deletions gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright 2023 [email protected].
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"
"os"
"os/exec"
"strings"
)

func main() {
if len(os.Args) != 1 {
fmt.Printf("Usage: %s IMAGE_NAME\n", os.Args[0])
os.Exit(1)
}
imageName := os.Args[1]
fmt.Printf("image name is %s", imageName)
_ = os.MkdirAll("deploy/images/shim", 0755)
_ = os.WriteFile("deploy/images/shim/image.txt", []byte(imageName), 0755)
cmd1 := fmt.Sprintf("sed -i '/#replace_by_makefile/!b;n;c\\image: %s' deploy/charts/automq-operator/values.yaml", imageName)
if err := execCmd("bash", "-c", cmd1); err != nil {
fmt.Printf("execCmd error %v", err)
os.Exit(1)
}
version := strings.Split(imageName, ":")
if len(version) != 2 {
fmt.Printf("image name error")
os.Exit(1)
}
shotVersion := strings.ReplaceAll(version[1], "v", "")
cmd2 := fmt.Sprintf("sed -i '/#replace_by_makefile/!b;n;c\\version: %s' deploy/charts/automq-operator/Chart.yaml", shotVersion)
if err := execCmd("bash", "-c", cmd2); err != nil {
fmt.Printf("execCmd error %v", err)
os.Exit(1)
}
}

func execCmd(command string, args ...string) error {
cmd := exec.Command(command, args...)
cmd.Stdin = os.Stdin
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout

return cmd.Run()
}

0 comments on commit 4ba5fb3

Please sign in to comment.