From 58b88150254fe371021f2853d5f8c9ca006a89bd Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 23 Apr 2021 17:09:38 +0100 Subject: [PATCH] Bump elastic stack version automation (#25148) (cherry picked from commit cc29196dfbb5a40a47ff4f3c0f25cf1b09b9d382) # Conflicts: # .mergify.yml --- .ci/bump-stack-version.sh | 48 +++++++++++++++++++++++++ .gitignore | 3 ++ .mergify.yml | 76 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100755 .ci/bump-stack-version.sh create mode 100644 .mergify.yml diff --git a/.ci/bump-stack-version.sh b/.ci/bump-stack-version.sh new file mode 100755 index 00000000000..30192b07232 --- /dev/null +++ b/.ci/bump-stack-version.sh @@ -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" diff --git a/.gitignore b/.gitignore index 2f5a63889a9..1f7b9ad9f11 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 00000000000..3711f17c84f --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,76 @@ +pull_request_rules: + - name: backport patches to 7.x branch + conditions: + - merged + - base=master + - label=backport-v7.14.0 + actions: + backport: + assignees: + - "{{ author }}" + branches: + - "7.x" + labels: + - "backport" + - name: backport patches to 7.13 branch + conditions: + - merged + - base=master + - label=backport-v7.13.0 + actions: + backport: + assignees: + - "{{ author }}" + branches: + - "7.13" + labels: + - "backport" + - name: backport patches to 7.12 branch + conditions: + - merged + - base=master + - label=backport-v7.12.0 + actions: + backport: + assignees: + - "{{ author }}" + branches: + - "7.12" + labels: + - "backport" + - name: backport patches to 7.11 branch + conditions: + - merged + - base=master + - label=backport-v7.11.0 + actions: + backport: + assignees: + - "{{ author }}" + branches: + - "7.11" + labels: + - "backport" + - name: ask to resolve conflict + conditions: + - conflict + actions: + comment: + message: | + This pull request is now in conflicts. Could you fix it? 🙏 + To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/ + ``` + git fetch upstream + git checkout -b {{head}} upstream/{{head}} + 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