Rename {tar,zip}ball and packaged directory

{Tar,zip}balls now have the form openseadragon-bin-0.9.125.{tar.gz,zip},
containing a directory openseadragon-bin-0.9.125.

Including the project's version number makes it easy to determine the
version of a random release sitting around a filesystem, and ensures
that unpacking a tarball won't overwrite another unpacked tarball or
write into a checked-out repo.

Adding -bin distinguishes the packages from source tarballs, which are
conventionally <project>-<version>.{tar.gz,zip}.
This commit is contained in:
Benjamin Gilbert 2013-04-22 20:20:07 -04:00
parent 551215404d
commit 739ff2dbed

View File

@ -12,8 +12,11 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-git-describe"); grunt.loadNpmTasks("grunt-git-describe");
// ---------- // ----------
var distribution = "build/openseadragon/openseadragon.js", var packageJson = grunt.file.readJSON("package.json"),
distribution = "build/openseadragon/openseadragon.js",
minified = "build/openseadragon/openseadragon.min.js", minified = "build/openseadragon/openseadragon.min.js",
packageDirName = "openseadragon-bin-" + packageJson.version,
packageDir = "build/" + packageDirName + "/",
releaseRoot = "../site-build/built-openseadragon/", releaseRoot = "../site-build/built-openseadragon/",
sources = [ sources = [
"src/openseadragon.js", "src/openseadragon.js",
@ -49,9 +52,10 @@ module.exports = function(grunt) {
// ---------- // ----------
// Project configuration. // Project configuration.
grunt.initConfig({ grunt.initConfig({
pkg: grunt.file.readJSON("package.json"), pkg: packageJson,
clean: { clean: {
build: ["build"], build: ["build"],
"package": [packageDir],
release: { release: {
src: [releaseRoot], src: [releaseRoot],
options: { options: {
@ -84,20 +88,20 @@ module.exports = function(grunt) {
compress: { compress: {
zip: { zip: {
options: { options: {
archive: "build/openseadragon.zip", archive: "build/" + packageDirName + ".zip",
level: 9 level: 9
}, },
files: [ files: [
{ expand: true, cwd: "build/", src: ["openseadragon/**"] } { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
] ]
}, },
tar: { tar: {
options: { options: {
archive: "build/openseadragon.tar.gz", archive: "build/" + packageDirName + ".tar.gz",
level: 9 level: 9
}, },
files: [ files: [
{ expand: true, cwd: "build/", src: [ "openseadragon/**" ] } { expand: true, cwd: "build/", src: [ packageDirName + "/**" ] }
] ]
} }
}, },
@ -152,6 +156,18 @@ module.exports = function(grunt) {
grunt.file.copy("changelog.txt", "build/changelog.txt"); grunt.file.copy("changelog.txt", "build/changelog.txt");
}); });
// ----------
// Copy:package task.
// Creates a directory tree to be compressed into a package.
grunt.registerTask("copy:package", function() {
grunt.file.recurse("build/openseadragon", function(abspath, rootdir, subdir, filename) {
var dest = packageDir
+ (subdir ? subdir + "/" : '/')
+ filename;
grunt.file.copy(abspath, dest);
});
});
// ---------- // ----------
// Copy:release task. // Copy:release task.
// Copies the contents of the build folder into the release folder. // Copies the contents of the build folder into the release folder.
@ -180,7 +196,7 @@ module.exports = function(grunt) {
// ---------- // ----------
// Package task. // Package task.
// Builds and creates the .zip and .tar.gz files. // Builds and creates the .zip and .tar.gz files.
grunt.registerTask("package", ["build", "compress"]); grunt.registerTask("package", ["build", "copy:package", "compress", "clean:package"]);
// ---------- // ----------
// Publish task. // Publish task.