aboutsummarylogtreecommitdiffstats
path: root/Gruntfile.js
blob: 452b0b99cf2286ff7b414b6b864512acd58f9b67 (plain)
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
'strict-mode';
module.exports = function (grunt) {
  var config = {
    pkg:  grunt.file.readJSON("package.json"),
    gta: {
      options: {
        stdout: true,
        stderr: true,
      },
      hook: {
        // Adjust this git command to only add the files needed.
        command: 'add package.json README.md .gitignore Gruntfile.js PKGBUILD .SRCINFO',
      },
      tag: {
        command: 'tag v<%= pkg.version %> -sm "Releasing v<%= pkg.version %>"',
      },
      archive: {
        // Adjust this command to only archive what is needed. It currently adds
        // all files.
        command: 'archive --format="tar.gz" --prefix="<%= pkg.name %>-v<%= pkg.version %>/" --output="<%= pkg.name %>-v<%= pkg.version %>.tgz" HEAD -- ./',
      },
      init: {
        command: 'init',
      },
      origin: {
        command: 'remote add origin vcs:/~/enchant-aur.git',
      },
    },
    githooks: {
      all: {
        // Adjust this hook to execute all needed grunt tasks.
        'pre-commit': "shell:hook gta:hook",
      }
    },
    bump: {
      options: {
        files: ['package.json'],
        updateConfigs: ['pkg'],
        commit: true,
        commitFiles: ['package.json'],
        createTag: false,
        push: false,
        prereleaseName: 'prev',
      },
    },
    shell:{
      options: {
        stderr: false
      },
      hook: {
        command: [
          'folder="$(pwd)"',
          'gitroot=$(git rev-parse --show-toplevel)',
          'cd "${gitroot}"',
          'updpkgsums',
          'mksrcinfo',
          'cd "${folder}"'
        ].join('&&')
      },
    },
  };

  // Loading the configuration.
  grunt.initConfig(config);

  // Loading the modules:
  grunt.loadNpmTasks('grunt-git-them-all');
  grunt.loadNpmTasks('grunt-githooks');
  grunt.loadNpmTasks('grunt-bump');
  grunt.loadNpmTasks('grunt-shell');

  // Registering the default task.
  grunt.registerTask('default', ['githooks:all']);
  grunt.registerTask('hooks', ['githooks:all']);
  grunt.registerTask('init', ['gta:init', 'gta:origin']);
  grunt.registerTask('archive', ['gta:archive']);
  grunt.registerTask('release', ['bump:patch', 'gta:tag', 'gta:archive']);
  grunt.registerTask('releaseminor', ['bump:minor', 'gta:tag', 'gta:archive']);
  grunt.registerTask('releasemajor', ['bump:major', 'gta:tag', 'gta:archive']);
  grunt.registerTask('prerelease', ['bump:prerelease', 'gta:tag', 'gta:archive']);
  grunt.registerTask('prepatch', ['bump:prepatch', 'gta:tag', 'gta:archive']);
  grunt.registerTask('preminor', ['bump:preminor', 'gta:tag', 'gta:archive']);
  grunt.registerTask('premajor', ['bump:premajor', 'gta:tag', 'gta:archive']);
};