@@ -983,22 +983,11 @@ jobs:
983
983
find . -name "*.tar.gz" -type f
984
984
echo ""
985
985
986
- # Create a manifest of all built binaries
987
- cat > manifest.json << EOF
988
- {
989
- "version": "$(date +%Y.%m.%d)",
990
- "built_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
991
- "commit": "${{ github.sha }}",
992
- "binaries": [
993
- EOF
986
+ # Create a temporary JSON array file
987
+ echo "[]" > binaries_array.json
994
988
995
- first=true
996
- # Find all tar.gz files recursively
989
+ # Find all tar.gz files recursively and process them
997
990
for tarball in $(find . -name "*.tar.gz" -type f); do
998
- if [[ $first == "false" ]]; then
999
- echo "," >> manifest.json
1000
- fi
1001
-
1002
991
filename=$(basename "$tarball")
1003
992
size=$(stat -c%s "$tarball" 2>/dev/null || stat -f%z "$tarball")
1004
993
@@ -1025,21 +1014,39 @@ jobs:
1025
1014
configuration="unknown"
1026
1015
fi
1027
1016
1028
- echo " {" >> manifest.json
1029
- echo " \"filename\": \"$filename\"," >> manifest.json
1030
- echo " \"size\": $size," >> manifest.json
1031
- echo " \"php_version\": \"$php_version\"," >> manifest.json
1032
- echo " \"platform\": \"$platform\"," >> manifest.json
1033
- echo " \"architecture\": \"$architecture\"," >> manifest.json
1034
- echo " \"configuration\": \"$configuration\"," >> manifest.json
1035
- echo " \"built_at\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\"," >> manifest.json
1036
- echo " \"extensions\": \"$(cat temp_metadata.json | jq -r '.extensions // ""' 2>/dev/null || echo '')\"" >> manifest.json
1037
- echo " }" >> manifest.json
1038
- first=false
1017
+ # Create JSON object for this binary
1018
+ binary_json=$(cat <<EOF
1019
+ {
1020
+ " filename " : " $filename" ,
1021
+ " size " : $size,
1022
+ " php_version " : " $php_version" ,
1023
+ " platform " : " $platform" ,
1024
+ " architecture " : " $architecture" ,
1025
+ " configuration " : " $configuration" ,
1026
+ " built_at " : " $(date -u +%Y-%m-%dT%H:%M:%SZ)" ,
1027
+ " extensions " : " $(cat temp_metadata.json | jq -r '.extensions // " " ' 2>/dev/null || echo '')"
1028
+ }
1029
+ EOF
1030
+ )
1031
+
1032
+ # Add this binary to the array using jq
1033
+ jq --argjson binary "$binary_json" '. += [$binary]' binaries_array.json > temp_array.json
1034
+ mv temp_array.json binaries_array.json
1039
1035
done
1040
1036
1041
- echo " ]" >> manifest.json
1042
- echo " }" >> manifest.json
1037
+ # Create the final manifest with proper structure and sorted binaries
1038
+ jq --arg version "$(date +%Y.%m.%d)" \
1039
+ --arg built_at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
1040
+ --arg commit "${{ github.sha }}" \
1041
+ ' {
1042
+ version: $version,
1043
+ built_at: $built_at,
1044
+ commit: $commit,
1045
+ binaries: (. | sort_by(.php_version))
1046
+ }' binaries_array.json > manifest.json
1047
+
1048
+ # Clean up temporary files
1049
+ rm -f binaries_array.json temp_metadata.json
1043
1050
1044
1051
echo ""
1045
1052
echo "📋 Generated manifest.json:"
0 commit comments