-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
releases.pl
96 lines (78 loc) · 1.9 KB
/
releases.pl
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl
use strict;
use warnings;
use File::Copy qw(copy);
local $ENV{PATH} = "$ENV{PATH};C:/Program Files/7-Zip";
my $githash = `git rev-parse HEAD`;
chomp $githash;
if (system("git diff --quiet HEAD --") != 0 ) {
$githash = 'DIRTY@'. $githash;
}
my $version = `git describe --abbrev=0 --tags`;
chomp $version;
my $binary = 'steam-screenshots';
my @OS = (
'windows',
'linux',
'darwin',
'freebsd',
);
my @ARCH = (
'386',
'amd64',
'arm',
);
my @static = (
'README.md',
'LICENSE.txt',
'settings_example.json',
'static/',
'static/default-skin/',
'templates/',
'banners/unknown.jpg',
);
mkdir 'tmp';
mkdir 'tmp/banners';
mkdir 'builds';
foreach my $s (@static) {
if (-d $s) {
mkdir "tmp/$s";
my @lst = glob("$s/*");
foreach (@lst) {
copy($_, "tmp/$_");
}
} else {
copy($s, "tmp/$s");
}
}
foreach my $o (@OS) {
my $ext = '';
$ext = '.exe' if ($o eq 'windows');
$ENV{'GOOS'} = $o;
foreach my $a (@ARCH) {
next if ($a eq 'arm' && $o ne 'linux');
$ENV{'GOARCH'} = $a;
print "Building ${o}/${a}\n";
my $bin = "${binary}_${version}_${o}_${a}";
`go build -ldflags "-X github.com/zorchenhimer/steam-screenshots.gitCommit=${githash} -X github.com/zorchenhimer/steam-screenshots.version=${version}" -o tmp/${binary}${ext} cmd/main.go`;
if ($o eq 'windows') {
`7z a builds/${bin}.zip ./tmp/*`;
} else {
`7z a builds/${bin}.tar ./tmp/*`;
`7z a builds/${bin}.tar.gz ./builds/${bin}.tar`;
unlink "./builds/${bin}.tar";
}
unlink "./tmp/${binary}${ext}";
}
}
foreach my $s (@static) {
if (-d $s) {
unlink glob "./tmp/$s/*";
rmdir "./tmp/$s";
} else {
unlink "./tmp/$s";
}
}
rmdir './tmp/banners/';
unlink glob "./tmp/*";
rmdir "./tmp";