Skip to content

Commit

Permalink
Merge pull request #50 from issue-ops/output-on-check
Browse files Browse the repository at this point in the history
Add output on check-only mode
  • Loading branch information
ncalteen authored Apr 16, 2024
2 parents 1e4290a + 648cc8e commit 67068f2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
19 changes: 10 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "semver",
"description": "Semantically version GitHub repository tags",
"version": "1.0.0",
"version": "1.1.0",
"author": "Nick Alteen <[email protected]>",
"homepage": "https://github.com/issue-ops/semver#readme",
"repository": {
Expand Down
15 changes: 7 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@ export async function run() {
if (version === undefined) return core.setFailed('Could not infer version')

// Stop now if we're only checking the version.
if (checkOnly)
if (await version.exists(workspace))
return core.setFailed("Version already exists and 'check-only' is true")
else return core.info("Version does not exist and 'check-only' is true")
if (checkOnly && (await version.exists(workspace)))
return core.setFailed("Version already exists and 'check-only' is true")

// Check if the tags already exist in the repository.
if (!overwrite && (await version.exists(workspace)))
if (!checkOnly && !overwrite && (await version.exists(workspace)))
return core.setFailed("Version already exists and 'overwrite' is false")

core.info(`Inferred Version: ${version.toString()}`)
core.info(`Tagging ${ref} with version ${version.toString()}`)

// Tag and push the version in the workspace
await version.tag(ref, workspace)
core.info('Tagging complete')
// If not running in checkOnly mode, tag and push the version in the
// workspace. Otherwise, just output the version information.
if (!checkOnly) await version.tag(ref, workspace)
else core.info("Version does not exist and 'check-only' is true")

// Output the various version formats
// [X.Y.Z-PRE+BUILD, X.Y.Z, X.Y, X, Y, Z, PRE, BUILD]
Expand Down
2 changes: 2 additions & 0 deletions src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ export class Version {
// Ignore stderr if the tag was pushed
if (tagOptions.stderr.includes('[new tag]') === false)
throw new Error(tagOptions.stderr)

core.info('Tagging complete')
}

/**
Expand Down

0 comments on commit 67068f2

Please sign in to comment.