-
Notifications
You must be signed in to change notification settings - Fork 5
/
Release.hx
56 lines (48 loc) · 1.19 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
import haxe.crypto.Crc32;
import haxe.zip.Entry;
import haxe.zip.Tools;
import haxe.zip.Writer;
import sys.FileSystem;
import sys.io.File;
final outPath = "release.zip";
final files = ["haxelib.json", "src", "LICENSE.md", "README.md"];
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();
}
function submitZip() {
trace("Submitting " + outPath);
Sys.command("haxelib", ["submit", outPath]);
}
function main() {
makeZip();
submitZip();
}