-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77032ac
commit 713927e
Showing
5 changed files
with
214 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
pipeline { | ||
agent any | ||
|
||
tools { go 'Go 1.18' } | ||
|
||
environment { | ||
PATH = "${env.WORKSPACE}/bin:${env.HOME}/go/bin:${env.PATH}" | ||
GIT_CREDENTIAL_ID = 'wf-jenkins-github' | ||
GITHUB_TOKEN = credentials('GITHUB_TOKEN') | ||
REPO_NAME = 'wavefront-kubernetes-adapter' | ||
} | ||
|
||
parameters { | ||
choice(name: 'BUMP_COMPONENT', choices: ['patch', 'minor', 'major'], description: 'Specify a semver component to bump.') | ||
} | ||
|
||
stages { | ||
stage('Build and Run Tests') { | ||
steps { | ||
sh 'make fmt lint build test' | ||
} | ||
} | ||
|
||
stage('Create Bump Version PR') { | ||
environment { | ||
BUMP_COMPONENT = "${params.BUMP_COMPONENT}" | ||
} | ||
|
||
steps { | ||
sh 'git config --global user.email "[email protected]"' | ||
sh 'git config --global user.name "svc.wf-jenkins"' | ||
sh 'git remote set-url origin https://${GITHUB_TOKEN}@github.com/wavefronthq/${REPO_NAME}.git' | ||
sh 'CGO_ENABLED=0 go install github.com/davidrjonas/semver-cli@latest' | ||
sh './scripts/update_release_version.sh -v $(cat release/VERSION) -s ${BUMP_COMPONENT}' | ||
sh './scripts/create_bump_version_pr.sh -v $(cat release/VERSION) -t ${GITHUB_TOKEN}' | ||
} | ||
} | ||
} | ||
|
||
// Notify only on null->failure or success->failure or failure->success | ||
post { | ||
failure { | ||
script { | ||
if(currentBuild.previousBuild == null) { | ||
slackSend (channel: '#tobs-k8po-team', color: '#FF0000', message: "Bump version failed: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>") | ||
} | ||
} | ||
} | ||
regression { | ||
slackSend (channel: '#tobs-k8po-team', color: '#FF0000', message: "Bump version failed: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>") | ||
} | ||
fixed { | ||
slackSend (channel: '#tobs-k8po-team', color: '#008000', message: "Bump version fixed: <${env.BUILD_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>") | ||
} | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.9.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env bash | ||
set -eou pipefail | ||
|
||
REPO_ROOT="$(git rev-parse --show-toplevel)" | ||
|
||
function create_pull_request() { | ||
local version="$1" | ||
local token="$2" | ||
local branch_name="$3" | ||
|
||
curl -fsSL -X 'POST' \ | ||
-H 'Accept: application/vnd.github+json' \ | ||
-H "Authorization: Bearer ${token}" \ | ||
-H 'X-GitHub-Api-Version: 2022-11-28' \ | ||
-d "{\"head\":\"${branch_name}\",\"base\":\"master\",\"title\":\"Bump version to ${version}\"}" \ | ||
https://api.github.com/repos/wavefrontHQ/wavefront-kubernetes-adapter/pulls | ||
} | ||
|
||
function check_required_argument() { | ||
local required_arg="$1" | ||
local failure_msg="$2" | ||
|
||
if [[ -z "${required_arg}" ]]; then | ||
print_usage_and_exit "${failure_msg}" | ||
fi | ||
} | ||
|
||
function print_usage_and_exit() { | ||
echo "Failure: $1" | ||
echo "Usage: $0 [flags] [options]" | ||
echo -e "\t-v bump version (required)" | ||
echo -e "\t-t github token (required)" | ||
exit 1 | ||
} | ||
|
||
function main() { | ||
cd "${REPO_ROOT}" | ||
|
||
local VERSION='' | ||
local GITHUB_TOKEN='' | ||
|
||
while getopts ":v:t:" opt; do | ||
case $opt in | ||
v) VERSION="$OPTARG";; | ||
t) GITHUB_TOKEN="$OPTARG";; | ||
\?) print_usage_and_exit "Invalid option: -$OPTARG";; | ||
esac | ||
done | ||
|
||
check_required_argument "${VERSION}" "-v <VERSION> is required" | ||
check_required_argument "${GITHUB_TOKEN}" "-t <GITHUB_TOKEN> is required" | ||
|
||
local GIT_BUMP_BRANCH_NAME="bump-version-${VERSION}" | ||
git branch -D "$GIT_BUMP_BRANCH_NAME" &>/dev/null || true | ||
git checkout -b "$GIT_BUMP_BRANCH_NAME" | ||
|
||
make update-version NEW_VERSION="${VERSION}" | ||
|
||
create_pull_request "${VERSION}" "${GITHUB_TOKEN}" "${GIT_BUMP_BRANCH_NAME}" | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
|
||
function get_bumped_version() { | ||
local version="$1" | ||
local bump_component="$2" | ||
|
||
semver-cli inc "${bump_component}" "${version}" | ||
} | ||
|
||
function check_required_argument() { | ||
local required_arg="$1" | ||
local failure_msg="$2" | ||
|
||
if [[ -z "${required_arg}" ]]; then | ||
print_usage_and_exit "${failure_msg}" | ||
fi | ||
} | ||
|
||
function print_usage_and_exit() { | ||
echo "Failure: $1" | ||
echo "Usage: $0 [flags] [options]" | ||
echo -e "\t-v version to bump (required)" | ||
echo -e "\t-s semver component to bump (required, ex: major, minor, patch)" | ||
exit 1 | ||
} | ||
|
||
function main() { | ||
cd "${REPO_ROOT}" | ||
|
||
local VERSION='' | ||
local BUMP_COMPONENT='' | ||
local NEXT_RELEASE_VERSION='' | ||
local FUTURE_RELEASE_VERSION='' | ||
|
||
while getopts ":v:s:" opt; do | ||
case $opt in | ||
v) VERSION="$OPTARG";; | ||
s) BUMP_COMPONENT="$OPTARG";; | ||
\?) print_usage_and_exit "Invalid option: -$OPTARG";; | ||
esac | ||
done | ||
|
||
check_required_argument "${VERSION}" "-v <VERSION> is required" | ||
check_required_argument "${BUMP_COMPONENT}" "-s <BUMP_COMPONENT> is required" | ||
|
||
echo "Current release version: ${VERSION}" | ||
|
||
NEXT_RELEASE_VERSION="$(get_bumped_version "${VERSION}" "${BUMP_COMPONENT}")" | ||
echo "Next release version: ${NEXT_RELEASE_VERSION}" | ||
|
||
# update the version in the image tag | ||
sed -i.bak "s/wavefront-hpa-adapter:${VERSION}/wavefront-hpa-adapter:${NEXT_RELEASE_VERSION}/g" "${REPO_ROOT}"/deploy/manifests/05-custom-metrics-apiserver-deployment.yaml | ||
rm -f "${REPO_ROOT}"/deploy/manifests/05-custom-metrics-apiserver-deployment.yaml.bak | ||
|
||
echo "${NEXT_RELEASE_VERSION}" >"${REPO_ROOT}"/release/VERSION | ||
|
||
FUTURE_RELEASE_VERSION="$(get_bumped_version "${NEXT_RELEASE_VERSION}" "patch")" | ||
echo "Future release version: ${FUTURE_RELEASE_VERSION}" | ||
|
||
# update the version in the Makefile | ||
sed -i.bak "s/VERSION?=[0-9.]*/VERSION?=${FUTURE_RELEASE_VERSION}/g" "${REPO_ROOT}"/Makefile | ||
rm -f "${REPO_ROOT}"/Makefile.bak | ||
} | ||
|
||
main "$@" |