revert untouched file

This commit is contained in:
Kurnianto Trilaksono
2024-03-28 00:01:40 +08:00
parent 3d840a6584
commit f63e919e3e

View File

@@ -23,29 +23,14 @@ set -o errexit
set -o nounset
set -o pipefail
declare -a RELEASE_TYPES=("major" "minor" "patch")
upstream_master="master"
origin_master="master"
if [[ -z "${1-}" ]]; then
echo "Usage: $0 TAG"
echo " TAG: the tag to build or release, e.g. api/v1.2.3"
exit 1
fi
if [[ -z "${2-}" ]]; then
echo "Release type not specified, using default value: patch"
release_type="patch"
elif [[ ! "${RELEASE_TYPES[*]}" =~ "${2}" ]]; then
echo "Unsupported release type, only input these values: major, minor, patch."
exit 1
fi
git_tag=$1
release_type=$2
echo "release tag: $git_tag"
echo "release type: $release_type"
# Build the release binaries for every OS/arch combination.
# It builds compressed artifacts on $release_dir.
@@ -96,39 +81,22 @@ function build_kustomize_binary {
}
function create_release {
source ./releasing/helpers.sh
git_tag=$1
# Take everything before the last slash.
# This is expected to match $module.
module=${git_tag%/*}
module_slugified=$(echo $module | iconv -t ascii//TRANSLIT | sed -E -e 's/[^[:alnum:]]+/-/g' -e 's/^-+|-+$//g' | tr '[:upper:]' '[:lower:]')
# Take everything after the last slash.
version=${git_tag##*/}
determineNextVersion $@
release_branch="release-${module}/${nextVersion}"
# Create release branch release-{module}/{version}
echo "Creating release branch $release_branch..."
git fetch --tags upstream $upstream_master
git branch $release_branch $origin_master
git commit -a -m "create release branch $release_branch" || true
git push -f origin $release_branch
# Generate the changelog for this release
# using the last two tags for the module
changelog_file=$(mktemp)
./releasing/compile-changelog.sh "$module" "HEAD" "$changelog_file"
./releasing/compile-changelog.sh "$module" "$git_tag" "$changelog_file"
additional_release_artifacts_arg=""
# Trigger workflow for respective modeule release
gh workflow run "release-${module_slugified}.yml" -f "release_type=${release_type}" -f "release_branch=${release_branch}"
# build `kustomize` binary
if [[ "$module" == "kustomize" ]]; then
release_artifact_dir=$(mktemp -d)
@@ -154,27 +122,6 @@ function create_release {
--notes-file "$changelog_file"
}
function determineNextVersion {
currentTag=$(git tag --list "${module}*" --sort=-creatordate | head -n1)
currentVersion=$(echo ${currentTag##*/} | cut -d'v' -f2)
majorVer=$(echo $currentVersion | cut -d'.' -f1)
minorVer=$(echo $currentVersion | cut -d'.' -f2)
patchVer=$(echo $currentVersion | cut -d'.' -f3)
if [[ ${release_type} == "major" ]]; then
majorVer="$(($majorVer + 1))"
elif [[ ${release_type} == "minor" ]]; then
minorVer="$(($minorVer + 1))"
elif [[ ${release_type} == "patch" ]]; then
patchVer="$(($patchVer + 1))"
else
echo "Error: release_type not supported. Available values 'major', 'minor', 'patch'"
exit 1
fi
nextVersion="$majorVer.$minorVer.$patchVer"
return
}
## create release
create_release "$git_tag"