-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/scripts #3
base: develop
Are you sure you want to change the base?
Changes from 7 commits
6bd99ed
5982f7b
4862f46
7bddf71
df5d973
0eda78e
1cec2e1
a53a416
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,6 @@ | |
# Others | ||
starter/ | ||
.github/ | ||
scripts/ | ||
gcloud_auth_key.json | ||
create.sh | ||
README.md |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
printusage() { | ||
echo "Usage: bump-version.sh [patch|minor|major]" | ||
} | ||
|
||
ROOT_PATH=$(dirname "$0")/.. | ||
|
||
if [[ $# -eq 0 ]] | ||
then | ||
printusage | ||
exit 1 | ||
fi | ||
|
||
UPDATED_PART=$1 | ||
if [[ ! ($UPDATED_PART == "patch" || $UPDATED_PART == "minor" || $UPDATED_PART == "major") ]] | ||
then | ||
printusage | ||
exit 1 | ||
fi | ||
|
||
CURRENT_VERSION=$(sed -ne 's/^version: \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)$/\1/p' $ROOT_PATH/Chart.yaml) | ||
MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d '.' -f 1) | ||
MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d '.' -f 2) | ||
PATCH_VERSION=$(echo $CURRENT_VERSION | cut -d '.' -f 3) | ||
|
||
if [[ $UPDATED_PART = 'patch' ]] | ||
then | ||
(( PATCH_VERSION++ )) | ||
elif [[ $UPDATED_PART = 'minor' ]] | ||
then | ||
(( MINOR_VERSION++ )) | ||
PATCH_VERSION=0 | ||
elif [[ $UPDATED_PART = 'major' ]] | ||
then | ||
(( MAJOR_VERSION ++ )) | ||
MINOR_VERSION=0 | ||
PATCH_VERSION=0 | ||
fi | ||
|
||
NEW_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION | ||
echo "Bumping Version $CURRENT_VERSION => $NEW_VERSION..." | ||
|
||
echo "Updating starter/Chart.yaml..." | ||
sed -i "" "s/^ version: \"$CURRENT_VERSION\"$/ version: \"$NEW_VERSION\"/" $ROOT_PATH/starter/Chart.yaml | ||
|
||
echo "Updating README.md..." | ||
sed -i "" "/^### Adding Dependency$/,/^### Using Starter$/s;version: $CURRENT_VERSION;version: $NEW_VERSION;" $ROOT_PATH/README.md | ||
|
||
echo "Updating Chart.yaml..." | ||
sed -i "" "s/^version: $CURRENT_VERSION$/version: $NEW_VERSION/" $ROOT_PATH/Chart.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
if [[ $# -eq 0 ]] | ||
then | ||
echo "Usage: create-chart.sh <chartname>" | ||
exit 1 | ||
fi | ||
|
||
CHART_NAME=$1 | ||
|
||
echo "Creating chart..." | ||
mkdir "$CHART_NAME" | ||
curl --proto '=https' --tlsv1.2 -sSf https://codeload.github.com/hahow/common-chart/tar.gz/master | \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. codeload.github.com 是最後 redirect 到的網址沒錯吧?我不確定他不是不是 public facing 的網址,以後可能會被改掉? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 確實有可能以後會改,但目前看來這個網址是滿普遍的用法,等被改掉再換? |
||
tar -xz -C "$CHART_NAME" --strip=2 common-chart-master/starter | ||
find "$CHART_NAME" -type f | xargs sed -i "" "s/<CHARTNAME>/$CHART_NAME/g" | ||
|
||
echo "Building dependencies..." | ||
helm dep build "$CHART_NAME" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
想問
scripts/bump-version.sh
會是誰在用?更改 chart 的人?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yap,之後看能不能透過 CD 自動升(但要配合一套完整的 git branching 流程