Created
March 16, 2025 17:09
-
-
Save ebwood/d7301998667b8d7c75768b1d99fec79c to your computer and use it in GitHub Desktop.
Flutter increment build number script
This file contains hidden or 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
#!/bin/bash | |
# Read pubspec.yaml | |
file="pubspec.yaml" | |
# Use grep and sed to find and increment the build number | |
if grep -qE "version: [0-9]+\.[0-9]+\.[0-9]+\+[0-9]+" "$file"; then | |
# Get the current build number | |
current_build=$(grep -E "version: [0-9]+\.[0-9]+\.[0-9]+\+[0-9]+" "$file" | sed -E "s/version: [0-9]+\.[0-9]+\.[0-9]+\+([0-9]+)/\1/") | |
# Increment the build number | |
new_build=$((current_build + 1)) | |
# Update the file with the new build number | |
sed -i '' -E "s/(version: [0-9]+\.[0-9]+\.[0-9]+\+)[0-9]+/\1$new_build/" "$file" | |
echo "Build number incremented successfully from $current_build to $new_build." | |
else | |
echo "No version found in pubspec.yaml" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment