Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to build Linux ARM binary in github action #395

Merged
merged 6 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions scripts/build-linux-arm-pg14.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

set -e

list=(
"steampipe-plugin-$1"
)

if [[ ! ${MY_PATH} ]];
then
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
fi

echo $MY_PATH

mkdir $MY_PATH/go-cache || true
mkdir $MY_PATH/go-mod-cache || true

GOCACHE=$(docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder steampipe_fdw_builder:14 go env GOCACHE)
MODCACHE=$(docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder steampipe_fdw_builder:14 go env GOMODCACHE)

for item in "${list[@]}"; do
plugin_name=${item##*-}

echo "Processing plugin: ${plugin_name}"

# Step 1: Switch to steampipe-postgres-fdw directory
cd $GITHUB_WORKSPACE || exit 1

# Step 2: Run Docker commands for Postgres FDW Builder v14
echo "Building Postgres FDW 14 for plugin: ${plugin_name}"
docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder -v "$(pwd)":/tmp/ext steampipe_fdw_builder:14 make clean
docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder -v "$(pwd)":/tmp/ext steampipe_fdw_builder:14 make standalone plugin="${plugin_name}"

# Step 3: Check if build-Linux directory is created
if [ ! -d "build-Linux" ] || [ ! -f "build-Linux/steampipe_postgres_${plugin_name}.so" ]; then
echo "Error: build-Linux directory or steampipe_postgres_${plugin_name}.so not found."
exit 1
fi

# Step 4: Move and tar for Postgres v14
echo "Move and tar for Postgres v14 for plugin: ${plugin_name}"
mv build-Linux steampipe_postgres_${plugin_name}.pg14.linux_arm64
tar -czvf steampipe_postgres_${plugin_name}.pg14.linux_arm64.tar.gz steampipe_postgres_${plugin_name}.pg14.linux_arm64

# Step 5: Check if tar.gz file is created for v14
if [ ! -f "steampipe_postgres_${plugin_name}.pg14.linux_arm64.tar.gz" ]; then
echo "Error: Tar file for Postgres v14 not created."
exit 1
fi

echo "Processing completed for plugin: ${plugin_name}"
done

echo "All plugins processed successfully."
56 changes: 56 additions & 0 deletions scripts/build-linux-arm-pg15.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

set -e

list=(
"steampipe-plugin-$1"
)

if [[ ! ${MY_PATH} ]];
then
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
fi

echo $MY_PATH

mkdir $MY_PATH/go-cache || true
mkdir $MY_PATH/go-mod-cache || true

GOCACHE=$(docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder steampipe_fdw_builder:15 go env GOCACHE)
MODCACHE=$(docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder steampipe_fdw_builder:15 go env GOMODCACHE)

for item in "${list[@]}"; do
plugin_name=${item##*-}

echo "Processing plugin: ${plugin_name}"

# Step 1: Switch to steampipe-postgres-fdw directory
cd $GITHUB_WORKSPACE || exit 1

# Step 2: Run Docker commands for Postgres FDW Builder v15
echo "Building Postgres FDW 15 for plugin: ${plugin_name}"
docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder -v "$(pwd)":/tmp/ext steampipe_fdw_builder:15 make clean
docker run --memory="10g" --memory-swap="16g" --rm --name sp_fdw_builder -v "$(pwd)":/tmp/ext steampipe_fdw_builder:15 make standalone plugin="${plugin_name}"

# Step 3: Check if build-Linux directory is created
if [ ! -d "build-Linux" ] || [ ! -f "build-Linux/steampipe_postgres_${plugin_name}.so" ]; then
echo "Error: build-Linux directory or steampipe_postgres_${plugin_name}.so not found."
exit 1
fi

# Step 4: Move and tar for Postgres v15
echo "Move and tar for Postgres v15 for plugin: ${plugin_name}"
mv build-Linux steampipe_postgres_${plugin_name}.pg15.linux_arm64
tar -czvf steampipe_postgres_${plugin_name}.pg15.linux_arm64.tar.gz steampipe_postgres_${plugin_name}.pg15.linux_arm64

# Step 5: Check if tar.gz file is created for v15
if [ ! -f "steampipe_postgres_${plugin_name}.pg15.linux_arm64.tar.gz" ]; then
echo "Error: Tar file for Postgres v15 not created."
exit 1
fi

echo "Processing completed for plugin: ${plugin_name}"
done

echo "All plugins processed successfully."
Loading