Skip to content

Commit

Permalink
fix: wrong output set
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed May 25, 2022
1 parent 1b6b2f9 commit a96905c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/bumper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const { promises } = require('fs');
const core = require('@actions/core');
const {
exitSuccess,
findPreReleaseId,
Expand Down Expand Up @@ -40,12 +41,17 @@ module.exports = async (
pathToDocument = path.join(workspace, pathToDocument);
logInfo(`Path to document: ${pathToDocument}`);
const projectFile = getProjectContent(pathToDocument);
logInfo(`projectFile: ${projectFile}`);
let currentVersion;
if (type === 'csproj') {
currentVersion = getCurrentVersionCsproj(projectFile);
} else if (type === 'assembly') {
currentVersion = getCurrentVersionAssembly(projectFile);
} else {
logInfo(`Type not recognized: ${type}`);
return false;
}
core.setOutput('oldVersion', currentVersion);
logInfo(`Current version: ${currentVersion}`);

const commitMessages = await getCommitMessages(gitEvents, token);
Expand Down Expand Up @@ -85,15 +91,19 @@ module.exports = async (

//Bump version
const newVersion = bumpVersion(currentVersion, doMajorVersion, doMinorVersion, doPatchVersion, doPreReleaseVersion, preReleaseId);
core.setOutput('newVersion', `${newVersion}`);
logInfo(`New version: ${newVersion}`);
let newContent;
if (type === 'csproj') {
newContent = getNewProjectContentCsproj(newVersion, projectFile);
} else if (type === 'assembly') {
newContent = getCurrentVersionAssembly(projectFile);
}
logInfo(`new project file: ${newContent}`);
// eslint-disable-next-line security/detect-non-literal-fs-filename
await promises.writeFile(pathToDocument, newContent);
logInfo('New project file written');
await commitChanges(newVersion, skipCommit, skipTag, skipPush, commitMessageToUse);
logInfo('Changes committed');
return true;
};
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const { exitSuccess, logError, exitFailure } = require('./utils');
const commitMessageToUse = core.getInput('commit-message');
const releaseCommitMessageRegex = core.getInput('release-commit-message-regex');
const type = core.getInput('type');
const newVersion = await bumpVersion(tagPrefix,
const wasBumped = await bumpVersion(tagPrefix,
minorWording,
majorWording,
patchWording,
Expand All @@ -34,8 +34,8 @@ const { exitSuccess, logError, exitFailure } = require('./utils');
commitMessageToUse,
type,
releaseCommitMessageRegex || commitMessageToUse);
if (newVersion) {
core.setOutput('newVersion', newVersion);
if (wasBumped) {
core.setOutput('wasBumped', wasBumped);
exitSuccess('Version bumped!');
}
} catch (err) {
Expand Down

0 comments on commit a96905c

Please sign in to comment.