Skip to content

Commit

Permalink
Merge pull request #208 from snappizz/topic/package-naming-tweaks
Browse files Browse the repository at this point in the history
Tweak names produced by package script, merge #186 into 3.10
  • Loading branch information
patrickdupuis authored Aug 23, 2018
2 parents 9326e12 + 6f62865 commit 4e3530b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.DS_Store
build*
package/*.tar.bz2
package/*.asc
source/local/*.cpp
source/local/*.scd
source/local/*.sc
Expand Down
109 changes: 109 additions & 0 deletions package/create_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Creates assets for sc3-plugins in the form of
# 'sc3-plugins-x.x.x-Source.tar.bz2' and moves the file to the repository's
# package folder.
# Requires a writable /tmp folder.

set -euo pipefail

get_absolute_path() {
echo "$(cd "$(dirname "$0")" && pwd -P)"
}

remove_source_dir() {
echo "Removing potential previous sources."
rm -rf "${source_dir}/sc3-plugins"*
}

checkout_project() {
remove_source_dir
echo "Cloning project..."
cd "$source_dir"
git clone $upstream --branch "Version-$version" --single-branch --recursive
}

clean_sources() {
cd "${source_dir}/${package_name}"
echo "Removing unneeded files and folders..."
rm -rfv .gitignore \
.gitmodules \
.travis.yml \
.git/ \
website \
package
}

rename_sources() {
cd "${source_dir}"
mv -v "${package_name}" "${package_name}-${version}-Source"
}

compress_sources() {
cd "${source_dir}"
tar cvfz "${package_name}-${version}-Source.tar.bz2" \
"${package_name}-${version}-Source"
}

move_sources() {
cd "${source_dir}"
mv -v "${package_name}-${version}-Source.tar.bz2" "${output_dir}/"
}

sign_sources() {
cd "${output_dir}"
gpg2 --default-key "${signer}" \
--output "${package_name}-${version}-Source.tar.bz2.asc" \
--detach-sign "${package_name}-${version}-Source.tar.bz2"
}

cleanup_source_dir() {
cd "${source_dir}"
rm -rf "${package_name}-${version}"
}

print_help() {
echo "Usage: $0 -v <version tag> -s <signature email>"
exit 1
}

upstream="https://github.com/supercollider/sc3-plugins"
package_name="sc3-plugins"
source_dir="/tmp"
version=`date "+%Y-%m-%d"`
signer=""
signature=0
output_dir=$(get_absolute_path $0)

if [ ${#@} -gt 0 ]; then
while getopts 'hv:s:' flag; do
case "${flag}" in
h) print_help
;;
s) signer=$OPTARG
signature=1
;;
v) version=$OPTARG
;;
*)
echo "Error! Try '${0} -h'."
exit 1
;;
esac
done
else
print_help
fi

checkout_project
clean_sources
rename_sources
compress_sources
move_sources
if [ $signature -eq 1 ]; then
sign_sources
fi
cleanup_source_dir

exit 0

# vim:set ts=2 sw=2 et:

0 comments on commit 4e3530b

Please sign in to comment.