-
Notifications
You must be signed in to change notification settings - Fork 4
/
Release.hx
58 lines (50 loc) · 1.28 KB
/
Release.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import haxe.crypto.Crc32;
import haxe.zip.Entry;
import haxe.zip.Tools;
import haxe.zip.Writer;
import sys.FileSystem;
import sys.io.File;
class Release {
static var outPath = "release.zip";
static var files = ["haxelib.json", "src", "LICENSE.md", "README.md"];
static function makeZip() {
var entries = new List<Entry>();
function add(path:String, target:String) {
if (!FileSystem.exists(path))
throw 'Invalid path: $path';
if (FileSystem.isDirectory(path)) {
for (item in FileSystem.readDirectory(path))
add(path + "/" + item, target + "/" + item);
} else {
trace("Adding " + target);
var bytes = File.getBytes(path);
var entry:Entry = {
fileName: target,
fileSize: bytes.length,
fileTime: FileSystem.stat(path).mtime,
compressed: false,
dataSize: 0,
data: bytes,
crc32: Crc32.make(bytes),
}
Tools.compress(entry, 9);
entries.add(entry);
}
}
for (file in files)
add(file, file);
trace("Saving to " + outPath);
var out = File.write(outPath, true);
var writer = new Writer(out);
writer.write(entries);
out.close();
}
static function submitZip() {
trace("Submitting " + outPath);
Sys.command("haxelib", ["submit", outPath]);
}
static function main() {
makeZip();
submitZip();
}
}