11#! /bin/bash
22
3+
34mkdir -p .tmp
45BUILD_TEMP=$( mktemp -d -p .tmp)
5- VERSION=$( sed -n ' s/^__VERSION="\([^"]*\)"/\1/p' ../giv/ src/giv.sh)
6+ VERSION=$( sed -n ' s/^__VERSION="\([^"]*\)"/\1/p' src/giv.sh)
67DIST_DIR=" ./dist/${VERSION} "
78
89printf " Building GIV CLI version %s...\n" " ${VERSION} "
10+ rm -rf " ${DIST_DIR} "
11+ mkdir -p " ${DIST_DIR} "
12+
13+ FPM_INSTALLED=" false"
14+ # Check for fpm, try to install if missing
15+ if ! command -v fpm > /dev/null 2>&1 ; then
16+ echo " Trying: gem install dotenv fpm"
17+ if gem install dotenv fpm; then
18+ echo " fpm installed via gem."
19+ fi
20+ fi
21+
22+ if ! command -v fpm > /dev/null 2>&1 ; then
23+ cat >&2 << EOF
24+ Error: fpm is not installed and automatic installation failed.
25+
26+ Manual installation instructions:
27+ - See https://fpm.readthedocs.io/en/latest/installation.html
28+ - On macOS: gem install fpm
29+ - On Linux (Debian/Ubuntu): sudo apt-get install ruby ruby-dev build-essential && sudo gem install --no-document fpm
30+ - On Linux (Fedora): sudo dnf install ruby ruby-devel make gcc && sudo gem install --no-document fpm
31+ - Or see the docs for more options.
32+ EOF
33+ FPM_INSTALLED=" false"
34+ else
35+ FPM_INSTALLED=" true"
36+ fi
37+
938mkdir -p " ${BUILD_TEMP} /package"
1039cp -r src templates docs " ${BUILD_TEMP} /package/"
11- cp README.md " ${BUILD_TEMP} /package/"
40+ printf ' Copied src templates docs to %s\n' " ${BUILD_TEMP} /package/"
41+ cp README.md " ${BUILD_TEMP} /package/docs"
1242mv " ${BUILD_TEMP} /package/src/giv.sh" " ${BUILD_TEMP} /package/src/giv"
1343printf " Using build temp directory: %s\n" " ${BUILD_TEMP} "
44+
45+ # Collect file lists for setup.py
46+ SH_FILES=$( find " ${BUILD_TEMP} /package/src" -type f -name ' *.sh' -print0 | xargs -0 -I{} bash -c ' printf "src/%s " "$(basename "{}")"' )
47+ TEMPLATE_FILES=$( find " ${BUILD_TEMP} /package/templates" -type f -print0 | xargs -0 -I{} bash -c ' printf "templates/%s " "$(basename "{}")"' )
48+ DOCS_FILES=$( find " ${BUILD_TEMP} /package/docs" -type f -print0 | xargs -0 -I{} bash -c ' printf "docs/%s " "$(basename "{}")"' )
49+
50+
51+ export SH_FILES TEMPLATE_FILES DOCS_FILES
52+
1453./build/npm/build.sh " ${VERSION} " " ${BUILD_TEMP} "
1554./build/pypi/build.sh " ${VERSION} " " ${BUILD_TEMP} "
16- # ./build/snap/build.sh "${VERSION}" "${BUILD_TEMP}"
17- # ./build/linux/build.sh "${VERSION}" "${BUILD_TEMP}" "deb"
18- # ./build/linux/build.sh "${VERSION}" "${BUILD_TEMP}" "rpm"
19- # ./build/flatpak/build.sh "${VERSION}" "${BUILD_TEMP}"
20- # ./build/homebrew/build.sh "${VERSION}" "${BUILD_TEMP}"
21- # ./build/scoop/build.sh "${VERSION}" "${BUILD_TEMP}"
55+ ./build/homebrew/build.sh " ${VERSION} " " ${BUILD_TEMP} "
56+ ./build/scoop/build.sh " ${VERSION} " " ${BUILD_TEMP} "
57+ if [ " ${FPM_INSTALLED} " = " true" ]; then
58+ ./build/linux/build.sh " ${VERSION} " " ${BUILD_TEMP} " " deb"
59+ ./build/linux/build.sh " ${VERSION} " " ${BUILD_TEMP} " " rpm"
60+ fi
61+ ./build/snap/build.sh " ${VERSION} " " ${BUILD_TEMP} "
62+ ./build/flatpak/build.sh " ${VERSION} " " ${BUILD_TEMP} "
2263
2364# rm -rf "${BUILD_TEMP}"
24- printf " Build completed. Files are in %s\n" " ${DIST_DIR} "
65+ printf " Build completed. Files are in %s\n" " ${DIST_DIR} "
0 commit comments