Skip to content

Commit

Permalink
Add setting version script
Browse files Browse the repository at this point in the history
  • Loading branch information
norseto committed Nov 3, 2023
1 parent 0479329 commit 66d71c9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ Dockerfile.cross
*.swp
*.swo
*~

*.bak
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ resources:
images:
- name: controller
newName: norseto/taint-remover
newTag: v0.1.0-alpha.1
newTag: v0.1.0-beta.1
21 changes: 21 additions & 0 deletions hack/set-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -xe

if [ $# -lt 1 ]; then
echo "Usage: $0 NEW_VERSION" 1>&2
exit 1
fi

VERSION=$(grep 'RELEASE_VERSION\s*=' version.go | awk -F= '{print $2}' | sed -e 's_"__g' -e 's/\s//g')

NEW_VERSION=$1
if [[ ! "${NEW_VERSION}" =~ ^([0-9]+[.][0-9]+)[.]([0-9]+)(-(alpha|beta)[.]([0-9]+))?$ ]]; then
echo "New version ${VERSION} must be 'X.Y.Z', 'X.Y.Z-alpha.N', or 'X.Y.Z-beta.N'"
exit 1
fi

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
BASE_DIR=${SCRIPT_DIR}/..

sed -i.bak -e "s@newTag:\s*v${VERSION}@newTag: v${NEW_VERSION}@g" ${BASE_DIR}/config/manager/kustomization.yaml
sed -i.bak -e "s@RELEASE_VERSION\s*=\s*\"${VERSION}\"@RELEASE_VERSION = \"${NEW_VERSION}\"@g" ${BASE_DIR}/version.go

2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package taintremover
var Version = RELEASE_VERSION

const (
RELEASE_VERSION = "0.1.0-alpha.1"
RELEASE_VERSION = "0.1.0-beta.1"
)

var GitVersion = ""

0 comments on commit 66d71c9

Please sign in to comment.