install and build flow cleanup
This commit is contained in:
83
flow
83
flow
@ -35,34 +35,42 @@ pgrx-prepare() {
|
||||
}
|
||||
|
||||
build() {
|
||||
local version=$(get-version)
|
||||
echo -e "📦 ${CYAN}Preparing source package v$version for $PACKAGE_NAME...${RESET}"
|
||||
|
||||
local version
|
||||
version=$(get-version) || return 1
|
||||
local package_dir="./package"
|
||||
local tarball_name="${GITEA_REPOSITORY}-src-v${version}.tar.gz"
|
||||
local tarball_path="${package_dir}/${tarball_name}"
|
||||
|
||||
echo -e "📦 Creating source tarball v$version for ${GITEA_REPOSITORY} in $package_dir..."
|
||||
|
||||
# Clean previous package dir
|
||||
rm -rf "${package_dir}"
|
||||
mkdir -p "${package_dir}"
|
||||
|
||||
# Copy necessary source files
|
||||
echo -e " ${CYAN}Copying source files to ${package_dir}${RESET}"
|
||||
cp -R src "${package_dir}/"
|
||||
cp Cargo.toml "${package_dir}/"
|
||||
cp Cargo.lock "${package_dir}/"
|
||||
cp jspg.control "${package_dir}/"
|
||||
|
||||
# Verify files copied
|
||||
if [ ! -d "${package_dir}/src" ] || [ ! -f "${package_dir}/Cargo.toml" ] || [ ! -f "${package_dir}/Cargo.lock" ] || [ ! -f "${package_dir}/jspg.control" ]; then
|
||||
echo -e "❌ ${RED}Failed to copy all source files to ${package_dir}.${RESET}"
|
||||
exit 1
|
||||
# Create the source tarball excluding specified patterns
|
||||
echo -e " ${CYAN}Creating tarball: ${tarball_path}${RESET}"
|
||||
if tar --exclude='.git*' --exclude='./target' --exclude='./package' -czf "${tarball_path}" .; then
|
||||
echo -e "✨ ${GREEN}Successfully created source tarball: ${tarball_path}${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Failed to create source tarball.${RESET}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "✨ ${GREEN}Source package prepared in ${package_dir}${RESET}"
|
||||
}
|
||||
|
||||
install() {
|
||||
echo -e "🔧 ${CYAN}Installing jspg extension (dev build)...${RESET}"
|
||||
cargo pgrx install "$@" # Pass any extra args like --debug
|
||||
local version
|
||||
version=$(get-version) || return 1
|
||||
|
||||
echo -e "🔧 ${CYAN}Building and installing PGRX extension v$version into local PostgreSQL...${RESET}"
|
||||
|
||||
# Run the pgrx install command
|
||||
# It implicitly uses --release unless --debug is passed
|
||||
# It finds pg_config or you can add flags like --pg-config if needed
|
||||
if ! cargo pgrx install "$@"; then # Pass any extra args like --debug
|
||||
echo -e "❌ ${RED}cargo pgrx install command failed.${RESET}" >&2
|
||||
return 1
|
||||
fi
|
||||
echo -e "✨ ${GREEN}PGRX extension v$version successfully built and installed.${RESET}"
|
||||
}
|
||||
|
||||
test() {
|
||||
@ -75,45 +83,6 @@ clean() {
|
||||
cargo clean # Use standard cargo clean
|
||||
}
|
||||
|
||||
# Override base package function to create and upload a source tarball
|
||||
package() {
|
||||
local version
|
||||
version=$(get-version) || return 1
|
||||
local package_dir="./package"
|
||||
local tarball_name="${GITEA_REPOSITORY}-src-v${version}.tar.gz"
|
||||
local tarball_path="${package_dir}/${tarball_name}"
|
||||
|
||||
echo -e "📦 ${CYAN}Creating source tarball ${tarball_name}...${RESET}"
|
||||
|
||||
# Ensure the package directory exists and has content
|
||||
if [ ! -d "$package_dir" ] || [ -z "$(ls -A "$package_dir")" ]; then
|
||||
echo -e "❌ ${RED}Source files not found in $package_dir. Run 'flow build' first.${RESET}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Create the tarball from the contents of the package directory
|
||||
if tar -czf "${tarball_path}" -C "${package_dir}" .; then
|
||||
echo -e "✨ ${GREEN}Created source tarball: ${tarball_path}${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Failed to create tarball.${RESET}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -e "📤 ${CYAN}Uploading ${tarball_name} to Gitea...${RESET}"
|
||||
if curl -X PUT \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"$GITEA_API_URL/packages/$GITEA_ORGANIZATION/generic/$GITEA_REPOSITORY/$version/$tarball_name" \
|
||||
-H "Content-Type: application/gzip" \
|
||||
-T "${tarball_path}" \
|
||||
-f > /dev/null; then
|
||||
echo -e "✨ ${GREEN}Successfully uploaded ${tarball_name}${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Failed to upload ${tarball_name}${RESET}" >&2
|
||||
# Clean up tarball on failure? Maybe not, user might want it.
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
jspg-usage() {
|
||||
echo -e " ${CYAN}JSPG Commands:${RESET}"
|
||||
echo -e " prepare Check OS, Cargo, and PGRX dependencies."
|
||||
|
||||
Reference in New Issue
Block a user