Skip to content

Commit

Permalink
Development (#5)
Browse files Browse the repository at this point in the history
* moved bash script, added try catch for async await

* Copying bash script to diff dir
  • Loading branch information
jessicalostinspace authored Jan 6, 2020
1 parent 621ce2b commit fb48178
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/cut-release-branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

regexString=$1

semanticVersion=''
branchName=''
if [ $regexString ]; then
branchName=$(echo $(git branch -a | grep $regexString | grep -E '([0-9]+\.){2}[0-9]+' | sort --version-sort | tail -n 1 | sed 's@.*/@@'))
semanticVersion=$(echo $(git branch -a | grep $regexString | egrep -o '([0-9]+\.){2}[0-9]+' | sort --version-sort | tail -n 1))
else
branchName=$(echo $(git branch -a | grep -E '([0-9]+\.){2}[0-9]+' | sort --version-sort | tail -n 1 | sed 's@.*/@@'))
semanticVersion=$(echo $(git branch -a | egrep -o '([0-9]+\.){2}[0-9]+' | sort --version-sort | tail -n 1))
fi

echo '{"semanticVersion": "'$semanticVersion'", "branchName": "'$branchName'"}'
31 changes: 17 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ try {

async function getSemVerBranches(command) {
// Get all the branches with the regex prefix and return the last version
const { err, stdout, stderr } = await exec(command, [{ shell: "bash" }]);
try{
const { err, stdout, stderr } = await exec(command, [{ shell: "bash" }]);

if (err) {
console.log('\x1b[33m%s\x1b[0m', 'Could not find any branches because: ');
console.log('\x1b[31m%s\x1b[0m', stderr);
process.exit(1);

return;
}

const data = JSON.parse(stdout);
if (data) {
return data;
if (err) {
console.log('\x1b[33m%s\x1b[0m', 'Could not find any branches because: ');
console.log('\x1b[31m%s\x1b[0m', stderr);
process.exit(1);

return;
}

const data = JSON.parse(stdout);
if (data) {
return data;
}
} catch (err) {
console.log(err);
process.exit(0);
}

process.exit(0);
}

0 comments on commit fb48178

Please sign in to comment.