Skip to content

Commit

Permalink
add scripts to change kmesh version automatically
Browse files Browse the repository at this point in the history
Signed-off-by: LiZhenCheng9527 <[email protected]>
  • Loading branch information
LiZhenCheng9527 committed Jan 14, 2025
1 parent e08a108 commit 1fa7f2f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: change kmesh version
env:
VERSION: ${{ github.ref_name }}
run: make update-version UPDATE_VERSION=${{ github.ref_name }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
with:
go-version: ${{ matrix.go-version }}

- name: change kmesh version
env:
VERSION: ${{ github.ref_name }}
run: make update-version UPDATE_VERSION=${{ github.ref_name }}

- name: Making and packaging
env:
GOOS: ${{ matrix.os }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ test:
./hack/run-ut.sh --local
endif

UPDATE_VERSION ?= ${VERSION}
.PHONY: update-version
update-version:
./hack/update-version.sh VERSION=${UPDATE_VERSION}

.PHONY: clean
clean:
$(QUIET) rm -rf ./out
Expand Down
20 changes: 20 additions & 0 deletions hack/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

# Check if a Makefile exists in the current directory
if [ ! -f "Makefile" ]; then
echo "Error: Makefile not found in the current directory."
exit 1
fi

# Check if the VERSION argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 VERSION=<value>"
exit 1
fi

# Extract the VERSION value from the argument
version=$(echo "$1" | sed 's/VERSION=//g')

# Update the VERSION parameter in the Makefile
sed -i "s/^VERSION.*$/VERSION ?= $version/" Makefile
sed -i "s/^CHART_VERSION.*$/CHART_VERSION ?= $version/" Makefile

0 comments on commit 1fa7f2f

Please sign in to comment.