-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
137 lines (127 loc) · 3.72 KB
/
Gruntfile.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
// Task configurations
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("manifest.json"),
bumpup: {
options: {
updateProps: {
pkg: "manifest.json",
},
},
files: ["manifest.json", "package.json"],
},
release: {
options: {
bump: false,
file: "manifest.json",
additionalFiles: ["package.json"],
push: false,
pushTags: false,
npm: false,
tagName: "v-<%= version %>",
commitMessage: "Release <%= version %>",
tagMessage: "Release <%= version %>",
},
},
rollup: {
options: {
format: "iife",
},
dist: {
files: {
"./dist/content.js": "./src/content/index.js",
"./dist/common.js": "./src/common/index.js",
"./dist/background.js": "./src/background/index.js",
},
},
},
watch: {
scripts: {
files: ["src/**/*.js"],
tasks: ["rollup"],
options: {
spawn: false,
},
},
},
zip: {
"long-format": {
src: [
"img/**",
"dist/**",
"vendors/**",
"manifest.json",
"LICENSE",
"!Gruntfile.js",
"!package.json",
],
dest: 'builds/<%= pkg.name + "-" + pkg.version %>.zip',
},
},
exec: {
copy_options: "cp -r src/options dist/",
fork_release: "git checkout -b release/<%= pkg.version %>",
push_release: "git push origin release/<%= pkg.version %>",
merge_release_back:
"git checkout develop && git merge release/<%= pkg.version %> && git push",
help_text:
'echo "For development (will compile js and start watcher):\n$ grunt pack && grunt\n\nTo start release flow:\n$ grunt makeRelease"',
},
webstore_upload: {
accounts: {
default: {
publish: true,
client_id: process.env.ChromeAPI_clientId,
client_secret: process.env.ChromeAPI_clientSecret,
refresh_token: process.env.ChromeAPI_refreshToken,
},
defaultNoPublish: {
publish: false,
client_id: process.env.ChromeAPI_clientId,
client_secret: process.env.ChromeAPI_clientSecret,
refresh_token: process.env.ChromeAPI_refreshToken,
},
},
extensions: {
StoPlay: {
appID: process.env.extensionId,
zip: 'builds/<%= pkg.name + "-" + pkg.version %>.zip',
},
},
onComplete: function (result) {
console.log("webstore_upload result", result);
var firstResult = result[0];
if (firstResult.success !== true) {
grunt.fail.fatal(firstResult.errorMsg);
}
},
},
});
// Loading the plugins
grunt.loadNpmTasks("grunt-exec");
grunt.loadNpmTasks("grunt-bumpup");
grunt.loadNpmTasks("grunt-release");
grunt.loadNpmTasks("grunt-zip");
grunt.loadNpmTasks("grunt-rollup");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-webstore-upload");
// Prepare release branch
grunt.registerTask("makeRelease", function (type) {
type = type ? type : "patch"; // Default release type
grunt.task.run("bumpup:" + type);
grunt.task.run("exec:fork_release");
grunt.task.run("release");
grunt.task.run("exec:push_release");
});
grunt.registerTask("default", ["watch"]);
grunt.registerTask("pack", ["rollup", "exec:copy_options", "zip"]);
grunt.registerTask("help", ["exec:help_text"]);
// to start release run this one
grunt.registerTask("build", ["makeRelease"]);
// only should be run by CI, not manually
grunt.registerTask("deploy", [
"pack",
"webstore_upload",
"exec:merge_release_back",
]);
};