-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Update bump version workflow to work for x.x branches (#2757)
- Loading branch information
Showing
4 changed files
with
94 additions
and
27 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,24 @@ | ||
name: Sync Cloudbeat Versions on release | ||
# Makes sure all cloudbeat versions are updated with release branches | ||
on: | ||
push: | ||
branches: | ||
# matches branches pushed by elasticmachine, e.g. "update-version-next-8.15.3" | ||
- 'update-version-next-*' | ||
|
||
jobs: | ||
synchronize-versions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
- name: Synchronize versions using a script | ||
run: | | ||
./scripts/sync_internal_cloudbeat_version.sh | ||
- name: Push changes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.CLOUDSEC_MACHINE_TOKEN }} | ||
run: | ||
git push origin |
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,30 @@ | ||
#! /bin/bash | ||
set -xeuo pipefail | ||
|
||
VERSION_FILE="version/version.go" | ||
HERMIT_FILE="bin/hermit.hcl" | ||
|
||
find_current_cloudbeat_version() { | ||
echo "Checking current cloudbeat version" | ||
CLOUDBEAT_VERSION=$(grep -oE 'defaultBeatVersion\s+=\s+".*"' $VERSION_FILE | grep -oE '[0-9]\.[0-9]\.[0-9]') | ||
echo "Cloudbeat version is $CLOUDBEAT_VERSION" | ||
} | ||
|
||
set_hermit_cloudbeat_version() { | ||
echo "Setting cloudbeat version for hermit version" | ||
sed -E -i '' "s/CLOUDBEAT_VERSION\": \".*\"/CLOUDBEAT_VERSION\": \"$CLOUDBEAT_VERSION\"/g" $HERMIT_FILE | ||
} | ||
|
||
commit_if_different() { | ||
if git diff --quiet --exit-code $HERMIT_FILE; then | ||
echo "No changes to $HERMIT_FILE; I'm done" | ||
return | ||
fi | ||
echo "Versions changed, commiting changes" | ||
git add $HERMIT_FILE | ||
git commit -m "bump CLOUDBEAT_VERSION in $HERMIT_FILE to $CLOUDBEAT_VERSION" | ||
} | ||
|
||
find_current_cloudbeat_version | ||
set_hermit_cloudbeat_version | ||
commit_if_different |