Skip to content

Commit

Permalink
build: add missing scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon committed Oct 27, 2023
1 parent 10ee5e5 commit 1fc336e
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions get_timestamp_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Path to your gradle.properties file
GRADLE_PROPERTIES_FILE="gradle.properties"

# Read the current version from gradle.properties
CURRENT_VERSION=$(grep "pluginVersion=" "$GRADLE_PROPERTIES_FILE" | cut -d'=' -f2)

# Extract the version part before any hyphen
BASE_VERSION=$(echo "$CURRENT_VERSION" | awk -F'-' '{print $1}')

# Replace any suffix following a hyphen with a timestamp in the format YYYYMMDD-HHmmSS
TIMESTAMP=$(date +'%Y%m%d-%H%M%S')
NEW_VERSION="${BASE_VERSION}-$TIMESTAMP"

# Use awk to update the gradle.properties file
awk -v new_version="$NEW_VERSION" '/pluginVersion=/{sub(/=.*/, "=" new_version)}1' "$GRADLE_PROPERTIES_FILE" > tmpfile && mv tmpfile "$GRADLE_PROPERTIES_FILE"

echo $NEW_VERSION
22 changes: 22 additions & 0 deletions increment_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Path to your gradle.properties file
GRADLE_PROPERTIES_FILE="gradle.properties"

# Read the current version from gradle.properties
CURRENT_VERSION=$(grep "pluginVersion=" "$GRADLE_PROPERTIES_FILE" | cut -d'=' -f2)

# Extract version parts
IFS="-" read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
IFS="." read -ra VERSION_NUM <<< "${VERSION_PARTS[0]}"

# Increment the last digit
((VERSION_NUM[2]++))

# Assemble the new version
NEW_VERSION="${VERSION_NUM[0]}.${VERSION_NUM[1]}.${VERSION_NUM[2]}-SNAPSHOT"

# Use awk to update the gradle.properties file
awk -v new_version="$NEW_VERSION" '/pluginVersion=/{sub(/=.*/, "=" new_version)}1' "$GRADLE_PROPERTIES_FILE" > tmpfile && mv tmpfile "$GRADLE_PROPERTIES_FILE"

echo $NEW_VERSION
14 changes: 14 additions & 0 deletions set_release_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

GRADLE_PROPERTIES_FILE="gradle.properties"

# Read the current version from gradle.properties
CURRENT_VERSION=$(grep "pluginVersion=" "$GRADLE_PROPERTIES_FILE" | cut -d'=' -f2)

# Remove the "-SNAPSHOT" suffix from the current version
NEW_VERSION=${CURRENT_VERSION%-SNAPSHOT}

# Update the gradle.properties file with the new version
awk -v current="$CURRENT_VERSION" -v new="$NEW_VERSION" 'BEGIN {FS=OFS="="} $1 == "pluginVersion" { $2 = new }1' "$GRADLE_PROPERTIES_FILE" > tmpfile && mv tmpfile "$GRADLE_PROPERTIES_FILE"

echo $NEW_VERSION

0 comments on commit 1fc336e

Please sign in to comment.