Skip to content
This repository has been archived by the owner on Sep 27, 2022. It is now read-only.

Commit

Permalink
added get and set only functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatdet committed Feb 16, 2022
1 parent fff8aba commit e12f6a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ inputs:
description: 'The path to the manifest file'
default: 'src/manifestShared.json'
required: true
new-verison:
description: 'New manifest version'
required: false
mode:
description: 'Can be get, set or ignored if you want to both get the file and set the new value'
required: false
outputs:
version:
description: The bumped version
Expand Down
23 changes: 14 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ const path = require("path");
async function main(){
try {
const pathToManifest = core.getInput('path-to-manifest', { required: true });
// const onlyGetVersion = core.getInput('only-get-version');
// const oldVersion = core.getInput('old-verison');
const mode = core.getInput('mode');
let newManifestVersion = core.getInput('new-verison');

const jsonData = getJsonFromManifest(pathToManifest);
const oldManifestVersion = jsonData.version;

const newManifestVersion = await updatedManifestVersion(oldManifestVersion);

jsonData.version = newManifestVersion;

updateManifest(pathToManifest, jsonData);
if(mode != 'set'){
const oldManifestVersion = jsonData.version;
newManifestVersion = await updatedManifestVersion(oldManifestVersion);
}

core.setOutput('version', newManifestVersion);

if(mode != 'get'){
jsonData.version = newManifestVersion;
updateManifest(pathToManifest, jsonData);
}

} catch (error) {
core.error(error.message);
}
Expand Down Expand Up @@ -53,7 +59,6 @@ async function updatedManifestVersion(version){

const versionString = `${versionNumbers[0]}.${versionNumbers[1]}.${versionNumbers[2]}`;

core.setOutput('version', versionString);
return versionString;
}

Expand Down

0 comments on commit e12f6a1

Please sign in to comment.