[Android|Windows|macOS|iOS] Rework flutter build helpers #5
@@ -50,4 +50,5 @@ windows/installer/*
|
|||||||
bugreport*
|
bugreport*
|
||||||
!downloads/*
|
!downloads/*
|
||||||
android/builds.json
|
android/builds.json
|
||||||
|
macos/builds.json
|
||||||
windows/busylight-buddy-windows-installer-builder.iss
|
windows/busylight-buddy-windows-installer-builder.iss
|
||||||
Executable
+60
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Default values
|
||||||
|
buildType="release"
|
||||||
|
buildName="0.0.0"
|
||||||
|
buildsRef="builds.json"
|
||||||
|
|
||||||
|
# Help message
|
||||||
|
show_help() {
|
||||||
|
echo "Usage: $0 [-t buildType] [-n buildName]"
|
||||||
|
echo "Builds a Flutter macOS application with versioning support."
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " -t, --buildType Build type (release or debug). Default: release"
|
||||||
|
echo " -n, --buildName Build name (version). Default: 0.0.0"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# Parse command-line arguments
|
||||||
|
while [[ "$#" -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-t|--buildType) buildType="$2"; shift ;;
|
||||||
|
-n|--buildName) buildName="$2"; shift ;;
|
||||||
|
-h|--help) show_help ;;
|
||||||
|
*) echo "Unknown parameter: $1"; show_help; exit 1 ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if builds.json exists
|
||||||
|
if [ ! -f "$buildsRef" ]; then
|
||||||
|
echo "File created: $buildsRef"
|
||||||
|
echo "{\"$buildName\": 0}" > "$buildsRef"
|
||||||
|
else
|
||||||
|
echo "File already exists: $buildsRef"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Read the JSON file
|
||||||
|
buildsMap=$(cat "$buildsRef")
|
||||||
|
|
||||||
|
# Check if buildName exists in the JSON
|
||||||
|
if jq -e --arg key "$buildName" 'has($key)' <<< "$buildsMap" > /dev/null; then
|
||||||
|
echo "Build exists: $buildName"
|
||||||
|
buildNumber=$(jq --arg key "$buildName" '.[$key]' <<< "$buildsMap")
|
||||||
|
buildNumber=$((buildNumber + 1))
|
||||||
|
echo "Next build number for $buildName: $buildNumber"
|
||||||
|
buildsMap=$(jq --arg key "$buildName" --argjson value "$buildNumber" '.[$key] = $value' <<< "$buildsMap")
|
||||||
|
else
|
||||||
|
echo "New build: $buildName, starting at build number: 1"
|
||||||
|
buildNumber=1
|
||||||
|
buildsMap=$(jq --arg key "$buildName" --argjson value "$buildNumber" '.[$key] = $value' <<< "$buildsMap")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save the updated JSON back to the file
|
||||||
|
echo "$buildsMap" > "$buildsRef"
|
||||||
|
|
||||||
|
# Build macOS application
|
||||||
|
echo "Building macOS application with arguments: --$buildType --build-name=$buildName --build-number=$buildNumber"
|
||||||
|
flutter build macos --"$buildType" --build-name="$buildName" --build-number="$buildNumber"
|
||||||
Reference in New Issue
Block a user