Add build support for expiring old releases

Builds expire after 90 days.
This commit is contained in:
lilia 2016-04-03 19:34:34 -07:00
parent 5faee2d61c
commit c442a02cb6
4 changed files with 25 additions and 3 deletions

View File

@ -125,6 +125,14 @@ module.exports = function(grunt) {
'textsecure-service-ca.whispersystems.org:4433').replace(
/whispersystems-textsecure-attachments-staging.s3.amazonaws.com/g,
'whispersystems-textsecure-attachments.s3.amazonaws.com');
} else if (srcpath.match('expire.js')) {
var gitinfo = grunt.config.get('gitinfo');
var commited = gitinfo.local.branch.current.lastCommitTime;
var time = Date.parse(commited) + 1000 * 60 * 60 * 24 * 90;
return content.replace(
/var BUILD_EXPIRATION = 0/,
"var BUILD_EXPIRATION = " + time
);
} else {
return content;
}
@ -157,7 +165,7 @@ module.exports = function(grunt) {
},
dist: {
files: ['<%= dist.src %>', '<%= dist.res %>'],
tasks: ['copy']
tasks: ['copy_dist']
},
scripts: {
files: ['<%= jshint.files %>', './js/**/*.js'],
@ -198,7 +206,8 @@ module.exports = function(grunt) {
'tx-pull': {
cmd: 'tx pull'
}
}
},
gitinfo: {} // to be populated by grunt gitinfo
});
Object.keys(grunt.config.get('pkg').devDependencies).forEach(function(key) {
@ -232,6 +241,7 @@ module.exports = function(grunt) {
grunt.registerTask('tx', ['exec:tx-pull', 'locale-patch']);
grunt.registerTask('dev', ['default', 'connect', 'watch']);
grunt.registerTask('test', ['jshint', 'jscs', 'connect', 'saucelabs-mocha']);
grunt.registerTask('default', ['concat', 'sass', 'copy']);
grunt.registerTask('copy_dist', ['gitinfo', 'copy']);
grunt.registerTask('default', ['concat', 'sass', 'copy_dist']);
};

View File

@ -382,6 +382,7 @@
<script type='text/javascript' src='js/models/conversations.js'></script>
<script type='text/javascript' src='js/chromium.js'></script>
<script type='text/javascript' src='js/expire.js'></script>
<script type='text/javascript' src='js/conversation_controller.js'></script>
<script type='text/javascript' src='js/panel_controller.js'></script>
<script type='text/javascript' src='js/emoji_util.js'></script>

10
js/expire.js Normal file
View File

@ -0,0 +1,10 @@
;(function() {
'use strict';
var BUILD_EXPIRATION = 0;
window.extension = window.extension || {};
extension.expired = function() {
return (BUILD_EXPIRATION && Date.now() > BUILD_EXPIRATION);
};
})();

View File

@ -13,6 +13,7 @@
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-exec": "^0.4.6",
"grunt-gitinfo": "^0.1.7",
"grunt-jscs": "^1.1.0",
"grunt-preen": "^1.0.0",
"grunt-saucelabs": "^8.3.3"