release.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. const gulp = require('gulp');
  9. const bump = require('gulp-bump');
  10. const filter = require('gulp-filter');
  11. const semver = require('semver');
  12. const {
  13. getPackageVersion,
  14. } = require('./helpers');
  15. let newVer = null;
  16. const packageJson = filter(['package.json']); // locate where is the package.json
  17. // BUILD AND RELEASE TASKS
  18. // to set the build or release version during the CI build/release
  19. // bump versions for a development
  20. gulp.task('bump:dev', ['newVer_dev', 'writeJson']);
  21. // bump versions for a release candidate
  22. gulp.task('bump:rc', ['newVer_rc', 'writeJson']);
  23. // crops versions for a release
  24. gulp.task('bump:release', ['newVer_release', 'writeJson']);
  25. gulp.task('newVer_dev', function () {
  26. newVer = semver.inc(getPackageVersion(), 'prerelease', Date.now().toString());
  27. });
  28. gulp.task('newVer_rc', function () {
  29. newVer = semver.inc(getPackageVersion(), 'prerelease', 'rc');
  30. });
  31. gulp.task('newVer_release', function () {
  32. newVer = semver.coerce(getPackageVersion());
  33. });
  34. // DEVELOPMENT TASKS
  35. // to set the new development iteration version after creating the release branch
  36. // bump versions to next development iteration
  37. gulp.task('bump:next', ['newVer_minor', 'writeJson']);
  38. gulp.task('newVer_minor', function () {
  39. newVer = semver.inc(getPackageVersion(), 'minor');
  40. });
  41. // write the package.json to the new version
  42. gulp.task('writeJson', function () {
  43. return gulp.src(['./package.json'])
  44. .pipe(bump({
  45. version: newVer,
  46. }))
  47. .pipe(packageJson)
  48. .pipe(gulp.dest('./'));
  49. });