-
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.
Merge branch 'main' into azure-management-groups
- Loading branch information
Showing
29 changed files
with
1,781 additions
and
297 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
# Calculate Previous Version | ||
# | ||
# This script takes a version as input, calculates the previous version, | ||
# fetches the corresponding release version from Elastic snapshots, | ||
# and outputs the previous version. | ||
# | ||
# Usage: ./get_previous_version.sh <version> | ||
# | ||
# Example: | ||
# ./get_previous_version.sh 8.12.0-SNAPSHOT | ||
|
||
# Input: version to calculate previous version | ||
VERSION="$1" | ||
|
||
# Extract the major and minor versions | ||
MAJOR_VERSION=$(echo "$VERSION" | cut -d'.' -f1) | ||
MINOR_VERSION=$(echo "$VERSION" | cut -d'.' -f2) | ||
|
||
# Calculate the previous version (assuming it's always X.(Y-1)) | ||
PREVIOUS_VERSION="$MAJOR_VERSION.$((MINOR_VERSION - 1))" | ||
|
||
URL="https://snapshots.elastic.co/latest/$PREVIOUS_VERSION.json" | ||
|
||
# Use curl to fetch the JSON data | ||
JSON_RESPONSE=$(curl -s "$URL") | ||
|
||
# Get latest snapshot version | ||
SNAPSHOT_VERSION=$(echo "$JSON_RESPONSE" | jq -r '.version') | ||
|
||
# Check if SNAPSHOT_VERSION is empty | ||
if [ -z "$SNAPSHOT_VERSION" ]; then | ||
# Log an error message with variable values | ||
echo "Error: The release version corresponding to $PREVIOUS_VERSION could not be found." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Split the version into major, minor, and patch parts | ||
IFS='.-' read -ra PARTS <<<"$SNAPSHOT_VERSION" | ||
MAJOR="${PARTS[0]}" | ||
MINOR="${PARTS[1]}" | ||
PATCH="${PARTS[2]}" | ||
|
||
# Decrement the patch version by 1 | ||
PATCH=$((PATCH - 1)) | ||
|
||
# Format the previous version | ||
PREVIOUS_VERSION="$MAJOR.$MINOR.$PATCH" | ||
|
||
# Output the previous version | ||
echo "$PREVIOUS_VERSION" |
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
Oops, something went wrong.