Skip to content

Commit

Permalink
First steps to packaging with Bash.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Dec 20, 2015
1 parent c5d711c commit c4e8883
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 19 deletions.
4 changes: 4 additions & 0 deletions scripts/configuration.sh
Expand Up @@ -53,3 +53,7 @@ function rbx_write_revision_file {
rbx_get_revision > "$(rbx_revision_file)"
fi
}

function rbx_release_name {
echo "rubinius-$(rbx_revision_version).tar.bz2"
}
36 changes: 25 additions & 11 deletions scripts/deploy.sh
Expand Up @@ -4,6 +4,14 @@ source "scripts/configuration.sh"
source "scripts/aws.sh"
source "scripts/io.sh"

function rbx_release_bucket {
echo "rubinius-releases-rubinius-com"
}

function rbx_binary_bucket {
echo "rubinius-binaries-rubinius-com"
}

function rbx_url_prefix {
local bucket=$1
echo "https://${bucket}.s3-us-west-2.amazonaws.com"
Expand All @@ -17,7 +25,7 @@ function rbx_upload_files {
src=$3
path=${4:-}
url=$(rbx_url_prefix "$bucket")
file_exts=("" ".md5" ".sha1" ".sha512")
file_exts=("" ".sha512")
index="index.txt"

rbx_s3_download "$url" "$index"
Expand Down Expand Up @@ -46,24 +54,29 @@ function rbx_upload_files {
}

# Build and upload the release tarball to S3.
if [[ $TRAVIS_OS_NAME == osx && $CC == gcc && $RVM == "rbx-2" ]]; then
echo "Deploying release tarball $(rbx_revision_version)..."
if [[ $TRAVIS_OS_NAME == osx ]]; then
echo "Deploying release tarball $(rbx_release_name)..."

./scripts/release || fail "unable to build release tarball"
"$(rbx_script_path)/release.sh" || fail "unable to build release tarball"

bucket="rubinius-releases-rubinius-com"
release_name="$(rbx_release_name)"
rbx_upload_files "$(rbx_release_bucket)" "$(rbx_release_name)" "$(rbx_release_name)"
fi

# Build and upload a Homebrew binary to S3.
if [[ $TRAVIS_OS_NAME == osx ]]; then
echo "Deploying Homebrew binary $(rbx_release_name)..."

rbx_upload_files "$bucket" "$release_name" "$release_name"
"$(rbx_script_path)/package.sh" homebrew || fail "unable to build Homebrew binary"

rbx_upload_files "$(rbx_binary_bucket)" "$(rbx_release_name)" \
"$(rbx_release_name)" "/homebrew/"
fi

# Build and upload a binary to S3.
if [[ $RVM == "rbx-2" ]]; then
echo "Deploying Travis binary $(rbx_revision_version) for ${TRAVIS_OS_NAME}..."

rake package:binary || fail "unable to build binary"

bucket="rubinius-binaries-rubinius-com"
"$(rbx_scripts)/package.sh" binary || fail "unable to build binary"

declare -a paths os_releases versions

Expand Down Expand Up @@ -93,7 +106,8 @@ if [[ $RVM == "rbx-2" ]]; then

for path in "${paths[@]}"; do
for version in "${versions[@]}"; do
rbx_upload_files "$bucket" "rubinius$version.tar.bz2" "$(rbx_release_name)" "$path"
rbx_upload_files "$(rbx_binary_bucket)" "rubinius$version.tar.bz2" \
"$(rbx_release_name)" "$path"
done
done
fi
31 changes: 30 additions & 1 deletion scripts/package.sh 100644 → 100755
@@ -1,3 +1,5 @@
#!/bin/bash

function rbx_digest_file {
local name digest

Expand All @@ -8,7 +10,7 @@ function rbx_digest_file {
}

function rbx_package_tar {
local archive files prefix
local archive files

archive="$(rbx_release_name)"
rm -rf "$archive"
Expand All @@ -20,3 +22,30 @@ function rbx_package_tar {

rbx_digest_file "$archive" "sha512"
}

function rbx_package_binary {
rake package:binary
}

function rbx_package_homebrew {
echo "Packaging for Homebrew..."
rake package:homebrew
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
case "$1" in
"tar")
rbx_package_tar
;;
"binary")
rbx_package_binary
;;
"homebrew")
rbx_package_homebrew
;;
*)
echo "Usage: ${0##*/} package_type"
exit 1
;;
esac
fi
8 changes: 1 addition & 7 deletions scripts/release.sh
@@ -1,13 +1,7 @@
#!/bin/bash

source "scripts/configuration.sh"
source "scripts/package.sh"

function rbx_release_name {
echo "rubinius-$(rbx_revision_version).tar.bz2"
}

rbx_write_revision_file
rbx_package_tar

exit 1
"$(rbx_script_path)/package.sh" tar

0 comments on commit c4e8883

Please sign in to comment.