Skip to content

Commit

Permalink
Added update to support build_version, also issue with node-semver @ n…
Browse files Browse the repository at this point in the history
…pm/node-semver#685 bypassed for now.
  • Loading branch information
Bioblaze committed Mar 6, 2024
1 parent 4607c15 commit 5a10b8e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 14 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ The `Game-Semver-Action` is a GitHub Action designed to automatically generate a

## Outputs

### `build_version`

Example: 0.0.298-alpha+build.ee9050469dca1f407c6f21361054e05181d6a9e9

```yaml
steps:
- name: Generate Semver/w Build SHA
id: semver
uses: Bioblaze/game-semver-action@v1
with:
personal_github_token: ${{ secrets.PGITHUB_TOKEN }}
include_commit_sha: true

- name: Use the Generated Version
run: echo "The new version is ${{ steps.semver.outputs.build_version }}"
```
### `version`

The generated semantic version based on your commit history and action inputs. This version can be used in subsequent workflow steps, for example, to tag a release or to update version files within your project.
Expand Down
14 changes: 10 additions & 4 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.

14 changes: 10 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,22 @@ function getAndLogCommits() {
if (identifier) {
version.prerelease = [identifier.trim().replace(/[^a-zA-Z0-9-]+/g, '')];
}
let newVersion = version.format();
let NewVersion = version.format();
var newBuildVersion = NewVersion;
if (includeCommitSha) {
const sha = getEventSHA();
core.debug(`SHA: ${sha}`);
if (sha) {
newVersion = `${newVersion}+build.${sha}`;
version.build = [`build.${sha}`];
newBuildVersion = `${NewVersion}+build.${sha}`;
}
}
core.exportVariable('version', newVersion);
core.setOutput('version', newVersion);
// https://github.com/npm/node-semver/issues/685
//let newVersion = version.format();
core.exportVariable('version', NewVersion);
core.setOutput('version', NewVersion);
core.exportVariable('build_version', newBuildVersion);
core.setOutput('build_version', newBuildVersion);
}
catch (error) {
if (error instanceof Error) {
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,23 @@ async function getAndLogCommits(): Promise<void> {
version.prerelease = [identifier.trim().replace(/[^a-zA-Z0-9-]+/g, '')];
}

let newVersion = version.format();

let NewVersion = version.format();
var newBuildVersion = NewVersion;
if (includeCommitSha) {
const sha = getEventSHA();
core.debug(`SHA: ${sha}`);
if (sha) {
newVersion = `${newVersion}+build.${sha}`
version.build = [`build.${sha}`]
newBuildVersion = `${NewVersion}+build.${sha}`
}
}
core.exportVariable('version', newVersion);
core.setOutput('version', newVersion);

// https://github.com/npm/node-semver/issues/685
//let newVersion = version.format();
core.exportVariable('version', NewVersion);
core.setOutput('version', NewVersion);
core.exportVariable('build_version', newBuildVersion);
core.setOutput('build_version', newBuildVersion);
} catch (error: unknown) {
if (error instanceof Error) {
core.setFailed(`An error occurred: ${error.message}`);
Expand Down

0 comments on commit 5a10b8e

Please sign in to comment.