mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-29 17:41:13 +00:00
Add buildMetadata task and ref (#5511)
* Add buildMetadata task and ref Move build metadata tasks, draft buildMetadata reference Clean up buildMetadata ref Add managed by label task Add local non-generated task Add local generated resource Add remote generator task Clean up tasks and ref Add local transformer annotation example Add local and remote transformer example * Address PR feedback and general cleanup cherrypick updates from feature branch fix script fix release script
This commit is contained in:
committed by
Kurnianto Trilaksono
parent
d514df3db0
commit
50dc813731
@@ -258,7 +258,8 @@ func (gr *Runner) AssureOnMainBranch() error {
|
||||
// CheckoutMainBranch does that.
|
||||
func (gr *Runner) CheckoutMainBranch() error {
|
||||
gr.comment("checking out main branch")
|
||||
return gr.runNoOut(noHarmDone, "checkout", mainBranch)
|
||||
fullBranchSpec := fmt.Sprintf("%s/%s", remoteOrigin, mainBranch)
|
||||
return gr.runNoOut(noHarmDone, "checkout", fullBranchSpec)
|
||||
}
|
||||
|
||||
// FetchRemote does that.
|
||||
|
||||
@@ -23,14 +23,29 @@ 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.
|
||||
@@ -81,22 +96,39 @@ 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" "$git_tag" "$changelog_file"
|
||||
./releasing/compile-changelog.sh "$module" "HEAD" "$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)
|
||||
@@ -122,6 +154,27 @@ 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"
|
||||
|
||||
@@ -2,12 +2,20 @@
|
||||
# Copyright 2022 The Kubernetes Authors.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
ORIGIN_MASTER="feat/5449-add-release-automation"
|
||||
UPSTREAM_REPO="upstream"
|
||||
UPSTREAM_MASTER="master"
|
||||
|
||||
function createBranch {
|
||||
branch=$1
|
||||
title=$2
|
||||
echo "Making branch $branch : \"$title\""
|
||||
git branch -D $branch # delete if it exists
|
||||
# Check if release branch exists
|
||||
if git show-ref --quiet "refs/heads/${branch}"; then
|
||||
git fetch --tags upstream master
|
||||
git checkout $ORIGIN_MASTER
|
||||
git branch -D $branch # delete if it exists
|
||||
fi
|
||||
git checkout -b $branch
|
||||
git commit -a -m "$title"
|
||||
git push -f origin $branch
|
||||
|
||||
Reference in New Issue
Block a user