Skip to content

Commit

Permalink
feat(publish_chart): use latest tag + bump version in main branch
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
niladrih committed Sep 18, 2023
1 parent 4a921b8 commit 71b88c7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
50 changes: 46 additions & 4 deletions scripts/helm/publish-chart-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ die()

set -euo pipefail

# Get latest release tag (not un-released) for a GitHub repo using GitHub's api.
github_latest_version_tag() {
local github_org="$1"
local github_repo="$2"

local tag_name=$(curl -fSsL \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/"$github_org"/"$github_repo"/releases | jq -r '.[0].tag_name' | tr -d " \t\r\n")

echo -n "$tag_name"
}

# Checks if version is semver and removes "v" from the beginning
version()
{
Expand Down Expand Up @@ -49,11 +61,20 @@ branch_chart_version()
# Develop has no meaningful version
echo "0.0.0"
elif [ "$CHECK_BRANCH" == "main" ]; then
# Main has no meaningful version, other than the date-time
local latest_tag=$(github_latest_version_tag "$GITHUB_ORG" "$GITHUB_REPO")
# Main sits one version bump ahead of the latest GitHub release.
local bumped_github_latest=""
# Bump minor by default.
if [ "$BUMP_MAJOR_FOR_MAIN" = "true" ]; then
bumped_github_latest=$(semver bump major "$latest_tag")
else
bumped_github_latest=$(semver bump minor "$latest_tag")
fi
# Date-time appended to main tag, if present.
if [ -n "$DATE_TIME" ]; then
echo "0.0.0-$DATE_TIME"
echo "$bumped_github_latest-$DATE_TIME"
else
echo "0.0.0-main"
echo "$bumped_github_latest-main"
fi
elif [ "$RELEASE_V" != "${CHECK_BRANCH}" ]; then
if [ "$(semver validate "$RELEASE_V")" == "valid" ]; then
Expand Down Expand Up @@ -112,12 +133,16 @@ Options:
-d, --dry-run Output actions that would be taken, but don't run them.
-h, --help Display this text.
--check-chart <branch> Check if the chart version/app version is correct for the branch.
--develop-to-release Also upgrade the chart to the release version matching the branch.
--develop-to-release Also upgrade the chart to the release version matching the branch.
--app-tag <tag> The appVersion tag.
--override-index <latest_version> Override the latest chart version from the published chart's index.
--index-file <index_yaml> Use the provided index.yaml instead of fetching from the git branch.
--override-chart <version> <app_version> Override the Chart.yaml version and app version.
--date-time <date-time> The date-time in the format +"$DATE_TIME_FMT".
--github-org <org_name> Set GitHub org name (default "openebs").
--github-repo <repo_name> Set GitHub repository name (default "mayastor-extensions").
--bump-major-for-main Bump latest released GitHub version tag major version for 'main'
branch, instead of the minor version.
Examples:
$(basename "$0") --app-tag v2.0.0-alpha.0
Expand Down Expand Up @@ -149,6 +174,9 @@ DEVELOP_TO_REL=
DATE_TIME_FMT="%Y-%m-%d-%H-%M-%S"
DATE_TIME=
IGNORE_INDEX_CHECK=
GITHUB_ORG="openebs"
GITHUB_REPO="mayastor-extensions"
BUMP_MAJOR_FOR_MAIN="false"

# Check if all needed tools are installed
semver --version >/dev/null
Expand Down Expand Up @@ -204,6 +232,20 @@ while [ "$#" -gt 0 ]; do
DATE_TIME=$1
shift
;;
--github-org)
shift
GITHUB_ORG=$1
shift
;;
--github-repo)
shift
GITHUB_REPO=$1
shift
;;
--bump-major-for-main)
BUMP_MAJOR_FOR_MAIN="true"
shift
;;
*)
help
die "Unknown option: $1"
Expand Down
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mkShell {
utillinux
which
yq-go
jq
] ++ pkgs.lib.optional (!norust) channel.default_src.nightly
++ pkgs.lib.optional (system == "aarch64-darwin") darwin.apple_sdk.frameworks.Security;

Expand Down

0 comments on commit 71b88c7

Please sign in to comment.