Skip to content

Instantly share code, notes, and snippets.

@pauloantonelli
Forked from evelyne24/pre-build.sh
Created March 8, 2022 12:58
Show Gist options
  • Save pauloantonelli/69b0c8202556f5569087027a84ffe1e8 to your computer and use it in GitHub Desktop.
Save pauloantonelli/69b0c8202556f5569087027a84ffe1e8 to your computer and use it in GitHub Desktop.
Bash script to extract the build name and number from `pubspec.yaml` before building your Flutter app
#!/bin/bash
set -e
file=$(cat pubspec.yaml)
BUILD_NAME=$(echo $file | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,4\}[0-9][^.]\).*/\1/p')
BUILD_NUMBER=$(git rev-list HEAD --count)
echo "Building version ${BUILD_NAME} ${BUILD_NUMBER}"
export BUILD_NAME="$BUILD_NAME"
export BUILD_NUMBER="$BUILD_NUMBER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment