This repository has been archived by the owner on Sep 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve the automation for the stack version bump (#1351)
* feat: automated update Beats' base version * chore: reduce number of version occurrences in tests * chore: decouple unit tests from the current version * feat: update Jenkinsfile * feat: automate .stack-version * fix: append snapshot * chore: simplify finding single files There is only one file to modify (cherry picked from commit 395bdb2) # Conflicts: # .ci/bump-stack-version.sh # internal/_testresources/gcp/commits.json # internal/_testresources/gcp/snapshots.json # internal/utils/utils_test.go
- Loading branch information
1 parent
2738330
commit 3ce15fe
Showing
15 changed files
with
7,388 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Given the stack version this script will bump the version. | ||
# | ||
# This script is executed by the automation we are putting in place | ||
# and it requires the git add/commit commands. | ||
# | ||
# Parameters: | ||
# $1 -> the version to be bumped. Mandatory. | ||
# $2 -> whether to create a branch where to commit the changes to. | ||
# this is required when reusing an existing Pull Request. | ||
# Optional. Default true. | ||
# | ||
set -euo pipefail | ||
MSG="parameter missing." | ||
VERSION=${1:?$MSG} | ||
CREATE_BRANCH=${2:-true} | ||
|
||
OS=$(uname -s| tr '[:upper:]' '[:lower:]') | ||
|
||
if [ "${OS}" == "darwin" ] ; then | ||
SED="sed -i .bck" | ||
else | ||
SED="sed -i" | ||
fi | ||
|
||
echo "Update stack with version ${VERSION} in .stack-version" | ||
echo "${VERSION}-SNAPSHOT" > .stack-version | ||
git add .stack-version | ||
|
||
echo "Update stack with version ${VERSION} in Go files" | ||
FILE="./internal/common/defaults.go" | ||
${SED} -E -e "s#(var BeatVersionBase = (\"))[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1${VERSION}#g" $FILE | ||
git add $FILE | ||
|
||
echo "Update stack with version ${VERSION} in Jenkinsfile" | ||
FILE="./.ci/Jenkinsfile" | ||
${SED} -E -e "s#(name: 'BEAT_VERSION', defaultValue: ')[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1${VERSION}#g" $FILE | ||
${SED} -E -e "s#(name: 'STACK_VERSION', defaultValue: ')[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1${VERSION}#g" $FILE | ||
git add $FILE | ||
|
||
echo "Update stack with version ${VERSION} in docker-compose.yml" | ||
find . -name 'docker-compose.yml' -path './cli/config/compose/profiles/*' -print0 | | ||
while IFS= read -r -d '' FILE ; do | ||
${SED} -E -e "s#(image: (\")?docker\.elastic\.co/.*):-[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1:-${VERSION}#g" $FILE | ||
git add $FILE | ||
done | ||
|
||
echo "Update stack with version ${VERSION} in deployment.yaml" | ||
find . -name 'deployment.yaml' -print0 | | ||
while IFS= read -r -d '' FILE ; do | ||
${SED} -E -e "s#(image: docker\.elastic\.co/.*):[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1:${VERSION}#g" $FILE | ||
git add $FILE | ||
done | ||
|
||
echo "Commit changes" | ||
if [ "$CREATE_BRANCH" = "true" ]; then | ||
git checkout -b "update-stack-version-$(date "+%Y%m%d%H%M%S")" | ||
else | ||
echo "Branch creation disabled." | ||
fi | ||
git diff --staged --quiet || git commit -m "bump stack version ${VERSION}" | ||
git --no-pager log -1 | ||
|
||
echo "You can now push and create a Pull Request" |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.