Skip to content

Commit

Permalink
Merge pull request #186 from dvzrv/package
Browse files Browse the repository at this point in the history
Create assets with a script
  • Loading branch information
Nathan Ho authored Aug 22, 2018
2 parents 9326e12 + 9beee8a commit e761b83
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.tgz
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-Version-x.x.x.tar.gz' 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-${version}"
}

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

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

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

cleanup_source_dir() {
cd "${source_dir}"
rm -rf "${package_name}-Version-${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 e761b83

Please sign in to comment.