upgraded flow
This commit is contained in:
139
flow
139
flow
@ -1,18 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Flows
|
||||
source "flows/base"
|
||||
source "flows/release"
|
||||
source "flows/rust"
|
||||
source ./flows/base
|
||||
source ./flows/git
|
||||
source ./flows/packaging
|
||||
source ./flows/rust
|
||||
|
||||
# Vars
|
||||
POSTGRES_VERSION="17"
|
||||
POSTGRES_CONFIG_PATH="/opt/homebrew/opt/postgresql@${POSTGRES_VERSION}/bin/pg_config"
|
||||
DEPENDENCIES=(cargo git icu4c pkg-config "postgresql@${POSTGRES_VERSION}")
|
||||
CARGO_DEPENDENCIES=(cargo-pgrx==0.14.0)
|
||||
PACKAGE_NAME="jspg"
|
||||
GITEA_ORGANIZATION="cellular"
|
||||
GITEA_REPOSITORY="jspg"
|
||||
PACKAGE_NAME="jspg"
|
||||
|
||||
pgrx-prepare() {
|
||||
echo -e "${BLUE}Initializing pgrx...${RESET}"
|
||||
@ -35,60 +36,28 @@ pgrx-prepare() {
|
||||
|
||||
build() {
|
||||
local version=$(get-version)
|
||||
echo -e "📦 ${CYAN}Building release v$version for $PACKAGE_NAME...${RESET}"
|
||||
echo -e "📦 ${CYAN}Preparing source package v$version for $PACKAGE_NAME...${RESET}"
|
||||
|
||||
# Define target directories
|
||||
local package_dir="./package"
|
||||
local package_source_base_dir="./target/release"
|
||||
|
||||
# Define the actual base paths where package command places files within out-dir
|
||||
local package_lib_search_path="${package_source_base_dir}/opt/homebrew/lib/postgresql@17"
|
||||
local package_share_search_path="${package_source_base_dir}/opt/homebrew/share/postgresql@17/extension"
|
||||
|
||||
# Clean previous package dirs
|
||||
# Clean previous package dir
|
||||
rm -rf "${package_dir}"
|
||||
mkdir -p "${package_dir}"
|
||||
|
||||
# Use cargo pgrx package to build and stage artifacts (release is default)
|
||||
if ! cargo pgrx package --pg-config "${POSTGRES_CONFIG_PATH}" --out-dir "${package_source_base_dir}"; then
|
||||
echo -e "❌ ${RED}Build failed during cargo pgrx package.${RESET}"
|
||||
exit 1
|
||||
# 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
|
||||
fi
|
||||
|
||||
echo -e " ${CYAN}Copying artifacts from ${package_source_base_dir} subdirs to ${package_dir}${RESET}"
|
||||
|
||||
# Find and copy the library
|
||||
local lib_path=$(find "${package_lib_search_path}" -name "${PACKAGE_NAME}.dylib" -print -quit)
|
||||
if [[ -n "$lib_path" ]]; then
|
||||
cp "$lib_path" "${package_dir}/"
|
||||
echo -e " ✨ ${GREEN}Copied library: $(basename "$lib_path")${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Could not find library (${PACKAGE_NAME}.dylib) in package source dir.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and copy the control file
|
||||
local control_path=$(find "${package_share_search_path}" -name "${PACKAGE_NAME}.control" -print -quit)
|
||||
if [[ -n "$control_path" ]]; then
|
||||
cp "$control_path" "${package_dir}/"
|
||||
echo -e " ✨ ${GREEN}Copied control file: $(basename "$control_path")${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Could not find control file (${PACKAGE_NAME}.control) in package source dir.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Find and copy the SQL file
|
||||
local sql_file_pattern="${PACKAGE_NAME}--*.sql"
|
||||
local sql_path=$(find "${package_share_search_path}" -name "${sql_file_pattern}" -print -quit)
|
||||
if [[ -n "$sql_path" ]]; then
|
||||
cp "$sql_path" "${package_dir}/"
|
||||
echo -e " ✨ ${GREEN}Copied SQL file: $(basename "$sql_path")${RESET}"
|
||||
else
|
||||
echo -e "❌ ${RED}Could not find SQL file (${sql_file_pattern}) in package source dir.${RESET}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "✨ ${GREEN}Package artifacts created in ${package_dir}${RESET}"
|
||||
echo -e "✨ ${GREEN}Source package prepared in ${package_dir}${RESET}"
|
||||
}
|
||||
|
||||
install() {
|
||||
@ -106,7 +75,48 @@ clean() {
|
||||
cargo clean # Use standard cargo clean
|
||||
}
|
||||
|
||||
usage() {
|
||||
# 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."
|
||||
echo -e " install [opts] Build and install the extension locally (dev)."
|
||||
echo -e " test [opts] Run pgrx integration tests."
|
||||
echo -e " clean Remove pgrx build artifacts."
|
||||
@ -116,14 +126,19 @@ usage() {
|
||||
echo -e " release Perform a full release (increments patch, builds, tags, pushes, packages)."
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
prepare) base prepare; cargo-prepare; pgrx-prepare;;
|
||||
build) build;;
|
||||
install) install;;
|
||||
reinstall) reinstall;;
|
||||
test) test;;
|
||||
package) package;;
|
||||
release) create-release;;
|
||||
clean) clean;;
|
||||
*) base "$@";;
|
||||
esac
|
||||
jspg-flow() {
|
||||
case "$1" in
|
||||
prepare) base prepare; cargo-prepare; pgrx-prepare; return 0;;
|
||||
build) build; return 0;;
|
||||
install) install; return 0;;
|
||||
reinstall) reinstall; return 0;;
|
||||
test) test; return 0;;
|
||||
package) package; return 0;;
|
||||
release) release; return 0;;
|
||||
clean) clean; return 0;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
register-flow "jspg-flow" "jspg-usage"
|
||||
dispatch "$@"
|
||||
Reference in New Issue
Block a user