diff --git a/.gitignore b/.gitignore index c2d1129..3c1c0cd 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ Dockerfile.cross artifacts config/kubeconfigs +replace_content.txt diff --git a/README.md b/README.md index 7561ec4..77e18e1 100644 --- a/README.md +++ b/README.md @@ -74,21 +74,19 @@ sealos run labring/kafka-ui:v0.7.1 #### For release version 1. Using sealos images install operator - + ```shell sealos run ghcr.io/cuisongliu/automq-operator-sealos:v0.0.4 ``` - + 2. Using helm chart install operator - + ```shell - wget https://github.com/cuisongliu/automq-operator/releases/download/v0.0.4/automq-operator-v0.0.4-sealos.tgz - mkdir -p automq-operator - tar -zxvf automq-operator-v0.0.4-sealos.tgz -C automq-operator - cd automq-operator/deploy - bash install.sh + wget -q https://github.com/cuisongliu/automq-operator/releases/download/v0.0.4/automq-operator-v0.0.4-sealos.tgz + mkdir -p automq-operator && tar -zxvf automq-operator-v0.0.4-sealos.tgz -C automq-operator + cd automq-operator/deploy && bash install.sh ``` - + ### Install AutoMQ ```shell diff --git a/gen/version/gen.go b/gen/version/gen.go index 2df2fdb..9a5f434 100644 --- a/gen/version/gen.go +++ b/gen/version/gen.go @@ -34,8 +34,8 @@ func main() { _ = os.MkdirAll("deploy/images/shim", 0755) _ = os.WriteFile("deploy/images/shim/image.txt", []byte(defaults.DefaultImageName), 0755) _ = os.WriteFile("deploy/images/shim/busybox.txt", []byte(defaults.BusyboxImageName), 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 { + cmdUpgradeImageName := fmt.Sprintf("sed -i '/#replace_by_makefile/!b;n;c\\image: %s' deploy/charts/automq-operator/values.yaml", imageName) + if err := execCmd("bash", "-c", cmdUpgradeImageName); err != nil { fmt.Printf("execCmd error %v", err) os.Exit(1) } @@ -48,11 +48,24 @@ func main() { if shotVersion == "latest" { shotVersion = "0.0.0" } - 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 { + cmdUpgradeChartVersion := fmt.Sprintf("sed -i '/#replace_by_makefile/!b;n;c\\version: %s' deploy/charts/automq-operator/Chart.yaml", shotVersion) + if err := execCmd("bash", "-c", cmdUpgradeChartVersion); err != nil { fmt.Printf("execCmd error %v", err) os.Exit(1) } + + cmdUpgradeReadme := fmt.Sprintf("scripts/release_tag.sh v%s", shotVersion) + if err := execCmd("bash", "-c", cmdUpgradeReadme); err != nil { + fmt.Printf("execCmd error %v", err) + os.Exit(1) + } + + cmdUpgradeReadmeSealos := fmt.Sprintf("scripts/release_tag_sealos.sh v%s", shotVersion) + if err := execCmd("bash", "-c", cmdUpgradeReadmeSealos); err != nil { + fmt.Printf("execCmd error %v", err) + os.Exit(1) + } + fmt.Printf("update image success") } diff --git a/scripts/release_tag.sh b/scripts/release_tag.sh new file mode 100755 index 0000000..e068f31 --- /dev/null +++ b/scripts/release_tag.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +TAG=${1} + +if [ -z "$TAG" ]; then + echo "Error: No version number provided." + exit 1 +fi +VERSION=${TAG##*v} + +START_MARKER="" +END_MARKER="" + + +echo " \`\`\`shell + wget -q https://github.com/cuisongliu/automq-operator/releases/download/v${VERSION}/automq-operator-v${VERSION}-sealos.tgz + mkdir -p automq-operator && tar -zxvf automq-operator-v${VERSION}-sealos.tgz -C automq-operator + cd automq-operator/deploy && bash install.sh + \`\`\`" > replace_content.txt + +awk -v start="$START_MARKER" -v end="$END_MARKER" -v newfile="replace_content.txt" ' +BEGIN {printing=1} +$0 ~ start {print;system("cat " newfile);printing=0} +$0 ~ end {printing=1} +printing' README.md > temp.txt && mv temp.txt README.md diff --git a/scripts/release_tag_sealos.sh b/scripts/release_tag_sealos.sh new file mode 100755 index 0000000..d324c2e --- /dev/null +++ b/scripts/release_tag_sealos.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +TAG=${1} + +if [ -z "$TAG" ]; then + echo "Error: No version number provided." + exit 1 +fi +VERSION=${TAG##*v} + +START_MARKER="" +END_MARKER="" + + +echo " \`\`\`shell + sealos run ghcr.io/cuisongliu/automq-operator-sealos:v${VERSION} + \`\`\`" > replace_content.txt + +awk -v start="$START_MARKER" -v end="$END_MARKER" -v newfile="replace_content.txt" ' +BEGIN {printing=1} +$0 ~ start {print;system("cat " newfile);printing=0} +$0 ~ end {printing=1} +printing' README.md > temp.txt && mv temp.txt README.md