Skip to content

Commit

Permalink
Add .travis.yml & scripts for automatic build and release
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemhall committed Dec 1, 2017
1 parent 4ad797a commit 49c4e14
Show file tree
Hide file tree
Showing 8 changed files with 3,281 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
language: node_js
node_js:
- "8"

install:
- echo $TRAVIS_BRANCH
- echo $TRAVIS_JOB_ID
- echo $TRAVIS_JOB_NUMBER
- git log -1 --pretty=oneline

before_script:
- npm install -g gulp-cli
- npm install jsonfile

script:
- bash deploy.sh
2 changes: 1 addition & 1 deletion Koha/Plugin/Com/ByWaterSolutions/AuthCheck.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use C4::Search;
use MARC::Record;

## Here we set our plugin version
our $VERSION = 1.50;
our $VERSION = "{VERSION}";

## Here is our metadata, some keys are required, some are optional
our $metadata = {
Expand Down
18 changes: 18 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if git log -1 --pretty=oneline | grep -v 'Version auto-incremented'
then
if echo $TRAVIS_BRANCH | grep master
then
echo "Building release"
node increment_version.js
git commit -a -m "Version auto-incremented - $TRAVIS_JOB_NUMBER"
gulp build
gulp release
git remote add github https://$GITHUB_TOKEN@github.com/bywatersolutions/koha-plugin-unused-authority-check
git fetch --all
git push github HEAD:master
fi
else
echo "No release needing."
fi
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const today = dt.format('Y-m-d');
const package_json = JSON.parse(fs.readFileSync('./package.json'));
const release_filename = `${package_json.name}-v${package_json.version}.kpz`;

const pm_file = 'KitchenSink.pm';
const pm_file = 'AuthCheck.pm';
const pm_file_path = 'Koha/Plugin/Com/ByWaterSolutions/';
const pm_file_path_full = pm_file_path + pm_file;
const pm_file_path_dist = 'dist/' + pm_file_path;
Expand Down
44 changes: 44 additions & 0 deletions increment_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const jsonfile = require('jsonfile')
const file = 'package.json'

let json = jsonfile.readFileSync(file);

console.log("Version: " + json.version );
console.log("Previous Version: " + json.previous_version );

const version = json.version;
const version_parts = version.split('.');
let major = parseInt( version_parts[0] );
let minor = parseInt( version_parts[1] );
let patch = parseInt( version_parts[2] );

const prev_version = json.previous_version;
const prev_version_parts = prev_version.split('.');
let prev_major = parseInt( version_parts[0] );
let prev_minor = parseInt( version_parts[1] );
let prev_patch = parseInt( version_parts[2] );

let new_version;

// No version jumps, just increment patch version
if ( major == prev_major && minor == prev_minor ) {
prev_major = major;
prev_minor = minor;
prev_patch = patch;

patch++;

new_version = major + '.' + minor + '.' + patch;
} else { // Version jumped, don't increment patch
new_version = version;
}

json.previous_version = version;
json.version = new_version;

jsonfile.writeFile(file, json, {spaces: 2}, function (err) {
if (err) console.error("ERROR: " + err);
})

console.log("New Version: " + json.version );
console.log("New Previous Version: " + json.previous_version );

0 comments on commit 49c4e14

Please sign in to comment.