2019-08-05 11:07:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Make sure the current directory is the location of this script to simplify matters
|
2019-08-05 11:28:25 +00:00
|
|
|
cd "$(dirname "$(readlink -f $0)")" || exit 1;
|
2019-08-05 11:07:17 +00:00
|
|
|
################
|
|
|
|
### Settings ###
|
|
|
|
################
|
|
|
|
|
|
|
|
# The name of this project
|
|
|
|
project_name="PolyFeed";
|
|
|
|
|
|
|
|
# The path to the lantern build engine git submodule
|
|
|
|
lantern_path="./lantern-build-engine";
|
|
|
|
|
|
|
|
###
|
|
|
|
# Custom Settings
|
|
|
|
###
|
|
|
|
|
2019-08-06 21:05:45 +00:00
|
|
|
# Deployment settings
|
|
|
|
deploy_ssh_user="ci";
|
|
|
|
deploy_ssh_host="apt.starbeamrainbowlabs.com";
|
2019-08-07 18:04:59 +00:00
|
|
|
deploy_ssh_port="2403";
|
2019-08-06 21:05:45 +00:00
|
|
|
deploy_root_dir="CIAptPackages";
|
2019-08-05 11:07:17 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
# Check out the lantern git submodule if needed
|
|
|
|
if [ ! -f "${lantern_path}/lantern.sh" ]; then git submodule update --init "${lantern_path}"; fi
|
|
|
|
|
2019-08-05 11:28:25 +00:00
|
|
|
# shellcheck disable=SC1090
|
2019-08-05 11:07:17 +00:00
|
|
|
source "${lantern_path}/lantern.sh";
|
|
|
|
|
|
|
|
if [[ "$#" -lt 1 ]]; then
|
|
|
|
echo -e "${FBLE}${project_name}${RS} build script";
|
|
|
|
echo -e " by Starbeamrainbowlabs";
|
2019-08-05 11:28:25 +00:00
|
|
|
# shellcheck disable=SC2154
|
2019-08-05 11:07:17 +00:00
|
|
|
echo -e "${LC}Powered by the lantern build engine, v${version}${RS}";
|
|
|
|
echo -e "";
|
|
|
|
echo -e "${CSECTION}Usage${RS}";
|
|
|
|
echo -e " ./build ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ${CTOKEN}{action}${RS} ...";
|
|
|
|
echo -e "";
|
|
|
|
echo -e "${CSECTION}Available actions${RS}";
|
|
|
|
echo -e " ${CACTION}setup${RS} - Do initial setup";
|
|
|
|
echo -e " ${CACTION}ci${RS} - Execute CI tasks";
|
|
|
|
echo -e "";
|
|
|
|
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
task_setup() {
|
|
|
|
task_begin "Checking environment";
|
|
|
|
|
|
|
|
check_command git true;
|
|
|
|
check_command msbuild true;
|
|
|
|
check_command nuget true;
|
|
|
|
check_command fpm true;
|
2019-08-05 12:41:59 +00:00
|
|
|
check_command dpkg true;
|
2019-08-05 11:31:20 +00:00
|
|
|
check_command awk true;
|
2019-08-05 11:07:17 +00:00
|
|
|
|
|
|
|
task_end 0;
|
|
|
|
|
|
|
|
|
|
|
|
task_begin "Initialising submodules";
|
|
|
|
execute git submodule update --init;
|
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
|
|
|
task_build() {
|
|
|
|
task_begin "Building PolyFeed for release";
|
|
|
|
execute nuget restore;
|
|
|
|
execute msbuild /p:Configuration=Release;
|
|
|
|
execute chmod -x PolyFeed/bin/Release/*;
|
|
|
|
execute chmod +x PolyFeed/bin/Release/*.exe;
|
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
|
|
|
task_package() {
|
|
|
|
task_begin "Packaging as .deb";
|
2019-08-05 12:49:31 +00:00
|
|
|
execute cp -ral PolyFeed/bin/Release PolyFeed/bin/polyfeed;
|
2019-08-05 13:02:37 +00:00
|
|
|
version="$(awk '/version = / { print($3) }' PolyFeed.sln | tr -d '\n\r')-$(date +"%Y%m%dT%H%M").$(git rev-parse HEAD | head -c7)";
|
|
|
|
fpm -s dir -t deb -n polyfeed \
|
|
|
|
--epoch 0 -v "${version}" \
|
|
|
|
--license MPL-2.0 \
|
2019-08-06 10:22:18 +00:00
|
|
|
--architecture all \
|
|
|
|
--maintainer "Starbeamrainbowlabs <feedback@starbeamrainbowlabs.com>" \
|
|
|
|
--vendor "Starbeamrainbowlabs <feedback@starbeamrainbowlabs.com>" \
|
2019-08-05 11:25:28 +00:00
|
|
|
--description "Create Atom feeds for websites that don't support it" \
|
|
|
|
--url "https://github.com/sbrl/PolyFeed" \
|
|
|
|
--depends mono-runtime \
|
2019-08-05 12:41:59 +00:00
|
|
|
PolyFeed/bin/polyfeed=/usr/lib \
|
2019-08-05 12:51:19 +00:00
|
|
|
polyfeed=/usr/bin/polyfeed;
|
2019-08-05 12:44:27 +00:00
|
|
|
execute rm -r PolyFeed/bin/polyfeed;
|
2019-08-05 12:41:59 +00:00
|
|
|
execute dpkg -c *.deb; # We don't know it's name :P
|
2019-08-05 11:25:28 +00:00
|
|
|
task_end $?;
|
2019-08-05 12:41:59 +00:00
|
|
|
|
2019-08-05 11:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task_archive() {
|
|
|
|
task_begin "Archiving artifacts";
|
|
|
|
mv *.deb "${ARCHIVE}";
|
2019-08-05 11:07:17 +00:00
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
2019-08-06 21:05:45 +00:00
|
|
|
task_upload-release() {
|
|
|
|
task_begin "Uploading release .deb file";
|
|
|
|
|
|
|
|
sftp -i "${SSH_KEY_PATH}" -P "${deploy_ssh_port}" -o PasswordAuthentication=no "${deploy_ssh_user}@${deploy_ssh_host}" << SFTPCOMMANDS
|
|
|
|
put ./*.deb ${deploy_root_dir}
|
|
|
|
bye
|
|
|
|
SFTPCOMMANDS
|
|
|
|
|
|
|
|
task_end $?;
|
|
|
|
}
|
|
|
|
|
2019-08-05 11:07:17 +00:00
|
|
|
task_ci() {
|
2019-08-05 11:25:28 +00:00
|
|
|
tasks_run setup build package archive;
|
2019-08-06 21:05:45 +00:00
|
|
|
|
|
|
|
if [[ "$(git tag --points-at HEAD | wc -l)" -gt 0 ]]; then
|
|
|
|
echo "Found tag $(git tag --points-at HEAD), uploading release";
|
|
|
|
tasks_run upload-release;
|
|
|
|
fi
|
2019-08-05 11:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
tasks_run $@;
|