Improve the distribution download

- add a simple readme
- create a gzipped tar file of the download
- add a dry-run option to the release script
This commit is contained in:
Peter Vlugter 2011-12-24 16:43:08 +13:00
parent 9749afd72e
commit 7ff362c9c6
9 changed files with 129 additions and 41 deletions

1
.gitignore vendored
View file

@ -15,7 +15,6 @@ tags
TAGS
akka.tmproj
reports
dist
target
deploy/*.jar
.history

34
akka-kernel/src/main/dist/README vendored Normal file
View file

@ -0,0 +1,34 @@
Akka
====
This is the Akka 2.0-SNAPSHOT download.
Included are all libraries, documentation, and sources for Akka.
This download can also be used for running the Akka Microkernel.
Contents
--------
- README - this document
- bin - start scripts for the Akka Microkernel
- config - config files for microkernel applications
- deploy - deploy dir for microkernel applications
- doc - Akka documentation and Scaladoc API
- lib - all Akka jars and dependencies
- src - source jars for Akka
Microkernel
-----------
This download includes everything needed for a self-contained Akka
Microkernel. See the documentation for more information about the
microkernel (see `doc/akka/docs/modules/microkernel.html`).
There is a sample microkernel application included in this download.
Start this application with the following command:
bin/akka sample.kernel.hello.HelloKernel

View file

@ -0,0 +1 @@
Place application jars in this directory

View file

@ -52,10 +52,7 @@ object Dist {
(baseDirectory, distSources, distUnzipped, version, distFile, streams) map {
(projectBase, allSources, unzipped, version, zipFile, s) => {
val base = unzipped / ("akka-" + version)
val scripts = (projectBase / "akka-kernel" / "src" / "main" / "scripts" * "*").get
val bin = base / "bin"
val configSources = projectBase / "config"
val config = base / "config"
val distBase = projectBase / "akka-kernel" / "src" / "main" / "dist"
val deploy = base / "deploy"
val deployReadme = deploy / "readme"
val doc = base / "doc" / "akka"
@ -68,30 +65,49 @@ object Dist {
val libAkka = lib / "akka"
val src = base / "src" / "akka"
IO.delete(unzipped)
copyFilesTo(scripts, bin, setExecutable = true)
IO.copyDirectory(configSources, config)
IO.createDirectory(deploy)
IO.write(deployReadme, "Place application jars in this directory")
IO.copyDirectory(allSources.api, api)
IO.copyDirectory(allSources.docs, docs)
copyFilesTo(allSources.docJars, docJars)
copyFilesTo(scalaLibs, lib)
copyFilesTo(akkaLibs, libAkka)
copyFilesTo(allSources.srcJars, src)
val files = unzipped ** -DirectoryFilter
val sources = files x relativeTo(unzipped)
IO.zip(sources, zipFile)
zipFile
copyDirectory(distBase, base, setExecutable = true)
copyDirectory(allSources.api, api)
copyDirectory(allSources.docs, docs)
copyFlat(allSources.docJars, docJars)
copyFlat(scalaLibs, lib)
copyFlat(akkaLibs, libAkka)
copyFlat(allSources.srcJars, src)
zip(unzipped, zipFile)
}
}
}
def copyFilesTo(files: Seq[File], dir: File, setExecutable: Boolean = false): Unit = {
IO.createDirectory(dir)
for (file <- files) {
val target = dir / file.name
IO.copyFile(file, target)
if (setExecutable) target.setExecutable(file.canExecute, false)
def copyDirectory(source: File, target: File, overwrite: Boolean = false, preserveLastModified: Boolean = false, setExecutable: Boolean = false): Set[File] = {
val sources = (source ***) x rebase(source, target)
copyMapped(sources, overwrite, preserveLastModified, setExecutable)
}
def copyFlat(files: Seq[File], target: File, overwrite: Boolean = false, preserveLastModified: Boolean = false, setExecutable: Boolean = false): Set[File] = {
IO.createDirectory(target)
val sources = files map { f => (f, target / f.name) }
copyMapped(sources, overwrite, preserveLastModified, setExecutable)
}
def copyMapped(sources: Traversable[(File, File)], overwrite: Boolean, preserveLastModified: Boolean, setExecutable: Boolean): Set[File] = {
sources map { Function.tupled(copy(overwrite, preserveLastModified, setExecutable)) } toSet
}
def copy(overwrite: Boolean, preserveLastModified: Boolean, setExecutable: Boolean)(source: File, target: File): File = {
if (overwrite || !target.exists || source.lastModified > target.lastModified) {
if (source.isDirectory) IO.createDirectory(target)
else {
IO.createDirectory(target.getParentFile)
IO.copyFile(source, target, preserveLastModified)
if (setExecutable) target.setExecutable(source.canExecute, false)
}
}
target
}
def zip(source: File, target: File): File = {
val files = source ** -DirectoryFilter
val sources = files x relativeTo(source)
IO.zip(sources, target)
target
}
}

View file

@ -38,7 +38,7 @@ echolog "$find_expr --> $replace_expr"
# exclude directories from search
declare exclude_dirs=".git dist deploy embedded-repo lib_managed project/boot project/scripts src_managed target"
declare exclude_dirs=".git project/project project/scripts src_managed target"
echolog "excluding directories: $exclude_dirs"

View file

@ -10,9 +10,10 @@ declare -r default_path="/akka/www"
declare -r release_dir="target/release"
declare release_server=${default_server}
declare release_path=${default_path}
declare -r unzipped_dir="target/dist/unzipped"
# flags
unset run_tests
unset run_tests dry_run
# get the source location for this script; handles symlinks
function get_script_path {
@ -32,10 +33,11 @@ declare -r script_dir="$(cd -P "$(dirname "${script_path}")" && pwd)"
function usage {
cat <<EOM
Usage: ${script_name} [options] VERSION
-h | --help Print this usage message
-t | --run-tests Run all tests before releasing
-s | --server SERVER Set the release server (default ${default_server})
-p | --path PATH Set the path on the release server (default ${default_path})
-h | --help Print this usage message
-t | --run-tests Run all tests before releasing
-s | --server SERVER Set the release server (default ${default_server})
-p | --path PATH Set the path on the release server (default ${default_path})
-n | --dry-run Build everything but do not push the release
EOM
}
@ -49,6 +51,11 @@ function echoerr {
echo "[${script_name}] $@" 1>&2
}
# echo a dry run log message
function echodry {
echolog "(dry run) $@"
}
# fail the script with an error message
function fail {
echoerr "$@"
@ -62,6 +69,7 @@ while true; do
-t | --run-tests ) run_tests=true; shift ;;
-s | --server ) release_server=$2; shift 2 ;;
-p | --path ) release_path=$2; shift 2 ;;
-n | --dry-run) dry_run=true; shift ;;
* ) break ;;
esac
done
@ -80,6 +88,12 @@ type -P git &> /dev/null || fail "git command not found"
# check for an sbt command
type -P sbt &> /dev/null || fail "sbt command not found"
# check for an rsync command
type -P rsync &> /dev/null || fail "rsync command not found"
# check for a tar command
type -P tar &> /dev/null || fail "tar command not found"
# get the current git branch
function get_current_branch {
local ref=$(git symbolic-ref HEAD 2> /dev/null)
@ -124,17 +138,17 @@ function git_cleanup {
safely git clean -f
if [ "${branch}" == "${release_branch}" ]; then
safely git checkout ${initial_branch}
safely git branch -d ${release_branch}
safely git branch -D ${release_branch}
local tags=$(git tag -l)
[[ "${tags}" == *v${version}* ]] && safely git tag -d v${version}
fi
echoerr "Cleaned up failed release"
}
# clean up and fail the script with an error message
function bail_out {
echoerr "Bailing out!"
git_cleanup
echoerr "Cleaned up failed release"
fail "$@"
}
@ -153,7 +167,13 @@ function try {
}
echolog "Creating release ${version} ..."
echolog "Publishing to ${publish_path}"
if [ $dry_run ]; then
echodry "Building everything but not pushing release"
else
echolog "Publishing to ${publish_path}"
fi
[[ $run_tests ]] && echolog "All tests will be run"
# try ssh'ing to the release server
@ -184,6 +204,8 @@ fi
echolog "Building the release..."
try sbt build-release
try cp akka-spring/src/main/resources/akka/spring/akka-*.xsd ${release_dir}
echolog "Creating gzipped tar download..."
try tar -cz -C ${unzipped_dir} -f ${release_dir}/downloads/akka-${version}.tgz akka-${version}
echolog "Successfully created local release"
# commit and tag this release
@ -222,14 +244,30 @@ trap arrgh_interrupt SIGHUP SIGINT SIGTERM
# push the commits and tags to git origin
echolog "Pushing to git origin..."
important git push origin ${release_branch}
important git push origin --tags
if [ $dry_run ]; then
echodry "Not actually pushing to git origin. Commands:"
echodry " git push origin ${release_branch}"
echodry " git push origin --tags"
else
important git push origin ${release_branch}
important git push origin --tags
fi
# push the release to the server
echolog "Pushing ${release_dir} to ${publish_path} ..."
important rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/
if [ $dry_run ]; then
echodry "Not actually pushing to server. Command:"
echodry " rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/"
else
important rsync -rlpvz --chmod=Dg+ws,Fg+w ${release_dir}/ ${publish_path}/
fi
echolog "Switching back to initial branch"
git checkout ${initial_branch}
echolog "Successfully created release ${version}"
if [ $dry_run ]; then
git_cleanup
echodry "Successfully created release ${version}"
echodry "See ${release_dir}"
else
echolog "Switching back to initial branch"
git checkout ${initial_branch}
echolog "Successfully created release ${version}"
fi