-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
142 lines (130 loc) · 10.4 KB
/
build.js
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const process = require('process');
const fs = require('fs');
const { exec } = require('child_process');
const aws = require('aws-sdk');
exec('git pull', [], (err1, stdout1, stderr1) => {
console.log('pulled');
exec(`git log -n 1 --pretty=format:"%H"`, [], (err2, stdout2, stderr2) => {
if (!err2 && !stderr2) {
const currentCommit = stdout2.trim();
exec(`electron-builder`, [], (err3, stdout3, stderr3) => {
console.log('built macos arm');
exec(`electron-builder --x64`, [], (_err3, _stdout3, _stderr3) => {
console.log('built macos x64');
exec(`electron-builder --linux --x64`, [], (_err3, _stdout3, _stderr3) => {
console.log('built linux x64');
exec(`xcrun notarytool submit dist/homegames-1.0.0.dmg --apple-id ${process.env.APPLE_DEVELOPER_ID} --team-id ${process.env.APPLE_TEAM_ID} --password ${process.env.APPLE_PASSWORD} --wait`, [], (_err4, _stdout4, _stderr4) => {
console.log('notarized x64');
console.log(_err4);
console.log(_stdout4);
console.log(_stderr4);
if (!err3) {
exec(`xcrun notarytool submit dist/homegames-1.0.0-arm64.dmg --apple-id ${process.env.APPLE_DEVELOPER_ID} --team-id ${process.env.APPLE_TEAM_ID} --password ${process.env.APPLE_PASSWORD} --wait`, [], (err4, stdout4, stderr4) => {
console.log('notarized arm');
console.log(err4);
console.log(stdout4);
console.log(stderr4);
exec('xcrun stapler staple dist/homegames-1.0.0-arm64.dmg ', [], (err5, stdout5, stderr5) => {
console.log('stapled arm');
console.log(err5);
console.log(stdout5);
console.log(stderr5);
exec('xcrun stapler staple dist/homegames-1.0.0.dmg ', [], (_err5, _stdout5, _stderr5) => {
console.log('stapled x64. need to upload to s3 and send out sqs message for windows build');
console.log(_err5);
console.log(_stdout5);
console.log(_stderr5);
const s3 = new aws.S3();
const armDmg = fs.readFileSync('dist/homegames-1.0.0-arm64.dmg');
const x64Dmg = fs.readFileSync('dist/homegames-1.0.0.dmg');
const armUploadParams = {
Bucket: process.env.BUILD_BUCKET,
Key: `${currentCommit}/homegames-arm64.dmg`,
Body: armDmg
};
const x64UploadParams = {
Bucket: process.env.BUILD_BUCKET,
Key: `${currentCommit}/homegames-x64.dmg`,
Body: x64Dmg
};
const linuxSnapUploadParams = {
Bucket: process.env.BUILD_BUCKET,
Key: `${currentCommit}/homegames-x64.snap`,
Body: x64Dmg
};
const linuxAppImageUploadParams = {
Bucket: process.env.BUILD_BUCKET,
Key: `${currentCommit}/homegames-x64.AppImage`,
Body: x64Dmg
};
s3.upload(armUploadParams, function (_err, _data) {
if (_err) {
console.log("Error", _err);
}
if (_data) {
console.log("Upload Success", _data.Location);
s3.upload(x64UploadParams, (uh1, uh2) => {
if (uh1) {
console.log('x64 fail' + uh1);
}
if (uh2) {
s3.upload(linuxSnapUploadParams, (_uh1, _uh2) => {
s3.upload(linuxAppImageUploadParams, (_uh3, _uh4) => {
const sqs = new aws.SQS({ region: process.env.SQS_REGION });
const messageBody = JSON.stringify({ commit: currentCommit });
const sqsParams = {
MessageBody: messageBody,
QueueUrl: process.env.SQS_QUEUE_URL,
MessageGroupId: Date.now() + '',
MessageDeduplicationId: Date.now() + ''
};
sqs.sendMessage(sqsParams, (err, sqsResponse) => {
console.log(err);
console.log(sqsResponse);
if (err) {
console.error(err);
} else {
s3.copyObject({
CopySource: `${process.env.BUILD_BUCKET}/${currentCommit}/homegames-arm64.dmg`,
Bucket: process.env.BUILD_BUCKET,
Key: `stable/homegames-arm64.dmg`
}, (e1, e2) => {
s3.copyObject({
CopySource: `${process.env.BUILD_BUCKET}/${currentCommit}/homegames-x64.dmg`,
Bucket: process.env.BUILD_BUCKET,
Key: `stable/homegames-x64.dmg`
}, (e3, e4) => {
s3.copyObject({
CopySource: `${process.env.BUILD_BUCKET}/${currentCommit}/homegames-x64.snap`,
Bucket: process.env.BUILD_BUCKET,
Key: `stable/homegames-x64.snap`
}, (e5, e6) => {
s3.copyObject({
CopySource: `${process.env.BUILD_BUCKET}/${currentCommit}/homegames-x64.AppImage`,
Bucket: process.env.BUILD_BUCKET,
Key: `stable/homegames-x64.AppImage`
}, (e7, e8) => {
console.log('done!');
});
});
});
});
}
});
});
});
}
});
}
});
});
});
});
}
});
});
});
});
}
});
});