Skip to content

Commit

Permalink
feat(main): add update version scripts (#54)
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <[email protected]>
  • Loading branch information
cuisongliu authored Oct 17, 2024
1 parent 4a72280 commit d3ddc75
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ Dockerfile.cross
artifacts

config/kubeconfigs
replace_content.txt
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,19 @@ sealos run labring/kafka-ui:v0.7.1
#### For release version

1. Using sealos images install operator

<!--automq-operator release sealos begin-->
```shell
sealos run ghcr.io/cuisongliu/automq-operator-sealos:v0.0.4
```

<!--automq-operator release sealos end-->
2. Using helm chart install operator

<!--automq-operator release begin-->
```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
```

<!--automq-operator release sealos end-->
### Install AutoMQ

```shell
Expand Down
21 changes: 17 additions & 4 deletions gen/version/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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")
}

Expand Down
25 changes: 25 additions & 0 deletions scripts/release_tag.sh
Original file line number Diff line number Diff line change
@@ -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="<!--automq-operator release begin-->"
END_MARKER="<!--automq-operator release end-->"


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
23 changes: 23 additions & 0 deletions scripts/release_tag_sealos.sh
Original file line number Diff line number Diff line change
@@ -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="<!--automq-operator release sealos begin-->"
END_MARKER="<!--automq-operator release sealos end-->"


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

0 comments on commit d3ddc75

Please sign in to comment.