Skip to content

Commit

Permalink
Bump elastic stack version automation (#25148)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Apr 23, 2021
1 parent 08caa4e commit cc29196
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .ci/bump-stack-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/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

FILES="testing/environments/snapshot-oss.yml
testing/environments/snapshot.yml
"

echo "Update stack with version ${VERSION}"
for FILE in ${FILES} ; do
${SED} -E -e "s#(image: docker\.elastic\.co/.*):[0-9]+\.[0-9]+\.[0-9]+(-[a-f0-9]{8})?#\1:${VERSION}#g" $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
for FILE in ${FILES} ; do
git add $FILE
done
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"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ x-pack/elastic-agent/pkg/agent/operation/tests/scripts/serviceable-1.0-darwin-x8
# Terraform
*.terraform
*.tfstate*

# Files generated with the bump elastic stack version automation
testing/environments/*.bck
9 changes: 9 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ pull_request_rules:
git merge upstream/{{base}}
git push upstream {{head}}
```
- name: Automatic squash and merge with success checks and the files matching the regex ^testing/environments/snapshot* are modified.
conditions:
- check-success=beats-ci/pr-merge
- label=automation
- files~=^testing/environments/snapshot.*\.yml$
actions:
merge:
method: squash
strict: smart+fasttrack

0 comments on commit cc29196

Please sign in to comment.