Skip to content

Commit

Permalink
Write script to ship version automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstyl committed Aug 3, 2024
1 parent 6955953 commit ed3bcf7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 24 deletions.
24 changes: 0 additions & 24 deletions scripts/prepare_version.sh

This file was deleted.

44 changes: 44 additions & 0 deletions scripts/release_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Define the root directory as the current directory
root_dir=$(pwd)

# Read the docs version from the keyboard
previous_version=$(grep '^val publishVersion =' "$root_dir/core/build.gradle.kts" | sed 's/^val publishVersion = "\([^\"]*\)"/\1/')

read -p "🚢 Shipping version $previous_version (y/n):" confirm
if [[ "$confirm" != "y" ]]; then
echo "Aborted."
exit 1
fi

echo "Publishing to Sonar..."

./gradlew publishAllPublicationsToSonatypeRepository closeAndReleaseSonatypeStagingRepository

echo "👍 Published"

# Retrieve the last commit hash
last_commit=$(git rev-parse HEAD)

# Tag the last commit with the last version
git tag "$previous_version" $last_commit

# Read the WIP version from the keyboard
read -p "Enter next version (e.g., 1.8.0): " wip_version

# Find and update the version in .md files
find "$root_dir" -type f -name "*.md" -exec sed -i '' "s/implementation(\"com\.composables:core:[^\"]*\")/implementation(\"com.composables:core:$previous_version\")/g" {} +

# Update the publishVersion value in build.gradle.kts
sed -i '' "s/^val publishVersion = \".*\"/val publishVersion = \"$wip_version\"/" "$root_dir/core/build.gradle.kts"

# Add all changes to git
git add .

# Commit with the provided version in the message
git commit -m "Prepare version $wip_version"

git push origin --follow-tags

echo "💯 All done. Working version is $previous_version"

0 comments on commit ed3bcf7

Please sign in to comment.