Skip to content

Commit

Permalink
Added grunt for git and svn deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
soderlind committed Jul 20, 2016
1 parent 1e8719c commit 29bdb65
Show file tree
Hide file tree
Showing 2 changed files with 257 additions and 0 deletions.
223 changes: 223 additions & 0 deletions Gruntfile.js
@@ -0,0 +1,223 @@
/*
* Based on http://torquemag.io/automating-wordpress-plugin-updates-releases-grunt/
*
* added:
* copy:svn_assets task
* makepot, creates wp-anchor-header.pot
*/
module.exports = function (grunt) {

/**
* Files added to WordPress SVN, don't include 'assets/**' here.
* @type {Array}
*/
svn_files_list = [
'readme.txt',
'acf-date-time-picker.php',
'date-time-picker-v3.php',
'date-time-picker-v4.php',
'js/**',
'css/**',
'languages/**'
];

/**
* Let's add a couple of more files to GitHub
* @type {Array}
*/
git_files_list = svn_files_list.concat([
'README.md',
'LICENSE',
'composer.json',
'package.json',
'Gruntfile.js',
'.travis.yml',
'.codeclimate.yml',
'.eslint*',
'assets/**'

]);

// Project configuration.
grunt.initConfig({
pkg : grunt.file.readJSON( 'package.json' ),
clean: {
post_build: [
'build'
]
},
copy: {
svn_assets: {
options : {
mode :true
},
expand: true,
cwd: 'assets/',
src: '**',
dest: 'build/<%= pkg.name %>/assets/',
flatten: true,
filter: 'isFile'
},
svn_trunk: {
options : {
mode :true
},
expand: true,
src: svn_files_list,
dest: 'build/<%= pkg.name %>/trunk/'
},
svn_tag: {
options : {
mode :true
},
expand: true,
src: svn_files_list,
dest: 'build/<%= pkg.name %>/tags/<%= pkg.version %>/'
}
},
gittag: {
addtag: {
options: {
tag: '<%= pkg.version %>',
message: 'Version <%= pkg.version %>'
}
}
},
gitcommit: {
commit: {
options: {
message: 'Version <%= pkg.version %>',
noVerify: true,
noStatus: false,
allowEmpty: true
},
files: {
src: git_files_list
}
}
},
gitpush: {
push: {
options: {
tags: true,
remote: 'origin',
branch: 'master'
}
}
},
replace: {
readme_txt: {
src: [ 'readme.txt' ],
overwrite: true,
replacements: [{
from: /Stable tag: (.*)/,
to: "Stable tag: <%= pkg.version %>"
}]

},
plugin_php: {
src: [ '<%= pkg.main %>' ],
overwrite: true,
replacements: [{
from: /Version:\s*(.*)/,
to: "Version: <%= pkg.version %>"
}, {
from: /define\(\s*'ACFFIELDDATETIMEPICKER_VERSION',\s*'(.*)'\s*\);/,
to: "define( 'ACFFIELDDATETIMEPICKER_VERSION', '<%= pkg.version %>' );"
}]
}
},
svn_export: {
dev: {
options: {
repository: 'http://plugins.svn.wordpress.org/<%= pkg.name %>',
output: 'build/<%= pkg.name %>'
}
}
},
push_svn: {
options: {
remove: true
},
main: {
src: 'build/<%= pkg.name %>',
dest: 'http://plugins.svn.wordpress.org/<%= pkg.name %>',
tmp: 'build/make_svn'
}
},
changelog: {
sample: {
options: {
fileHeader: '# Changelog',
dest: 'CHANGELOG.md',
after: '2013-03-01',
logArguments: [
'--pretty=- [%ad](https://github.com/soderlind/<%= pkg.name %>/commit/%h): %s (committer: %cn)',
'--no-merges',
'--date=short'
],
template: '{{> features}}',
featureRegex: /^(.*)$/gim,
partials: {
features: '{{#if features}}{{#each features}}{{> feature}}{{/each}}{{else}}{{> empty}}{{/if}}\n',
feature: '{{this}} {{this.date}}\n'
}
}
}
},
makepot: {
target: {
options: {
domainPath: '/languages',
potHeaders: {
poedit: true,
'x-poedit-keywordslist': true
},
bugsurl: '<%= pkg.bugs.url%>',
processPot: function( pot, options ) {
pot.headers['report-msgid-bugs-to'] = options.bugsurl;
/*pot.headers['language-team'] = 'Team Name <team@example.com>';*/
return pot;
},
type: 'wp-plugin',
updateTimestamp: true,
exclude: [
'languages/.*',
'js/.*',
'node_modules/.*'
]
}
}
}
});



//load modules
// grunt.loadNpmTasks( 'grunt-glotpress' );
grunt.loadNpmTasks( 'grunt-contrib-clean' );
grunt.loadNpmTasks( 'grunt-contrib-copy' );
grunt.loadNpmTasks( 'grunt-git' );
grunt.loadNpmTasks( 'grunt-text-replace' );
grunt.loadNpmTasks( 'grunt-svn-export' );
grunt.loadNpmTasks( 'grunt-push-svn' );
grunt.loadNpmTasks( 'grunt-remove' );
grunt.loadNpmTasks( 'grunt-wp-i18n' );
grunt.loadNpmTasks( 'grunt-changelog' );

grunt.registerTask('syntax', 'default task description', function(){
console.log('Syntax:\n' +
'\tgrunt release (version_number, do_svn, do_git, clean:post_build)\n' +
'\tgrunt version_number (update plugin version number in files)\n' +
'\tgrunt do_svn (svn_export, copy:svn_trunk, copy:svn_tag, push_svn)\n' +
'\tgrunt do_git (gitcommit, gittag, gitpush)'
);
});

grunt.registerTask( 'default', ['syntax'] );
grunt.registerTask( 'version_number', [ 'replace:readme_txt', 'replace:plugin_php' ] );
grunt.registerTask( 'do_svn', [ 'svn_export', 'copy:svn_assets', 'copy:svn_trunk', 'copy:svn_tag', 'push_svn' ] );
grunt.registerTask( 'do_git', [ 'gitcommit', 'gittag', 'gitpush' ] );
grunt.registerTask( 'release', [ /*'makepot',*/ 'version_number', 'do_svn', 'do_git', 'clean:post_build' ] );

};
34 changes: 34 additions & 0 deletions package.json
@@ -0,0 +1,34 @@
{
"name": "acf-field-date-time-picker",
"title": "Date and Time Picker Field",
"version": "2.1.0",
"git_tag": "2.1.0",
"description": "Date and Time Picker field for Advanced Custom Fields",
"main": "acf-date-time-picker.php",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"repository": {
"type": "git",
"url": "git://github.com/soderlind/acf-field-date-time-picker.git"
},
"license": "GPL",
"bugs": {
"url": "https://github.com/soderlind/acf-field-date-time-picker/issues/new"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-changelog": "^0.3.1",
"grunt-cli": "~0.1.13",
"grunt-composer": "^0.4.4",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-git": "^0.3.4",
"grunt-push-svn": "^0.2.1",
"grunt-remove": "^0.1.0",
"grunt-svn-export": "^0.1.7",
"grunt-text-replace": "^0.4.0",
"grunt-wp-i18n": "^0.5.2"
}
}

0 comments on commit 29bdb65

Please sign in to comment.