Skip to content

Commit

Permalink
feat: add commit input.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 27, 2024
1 parent d731860 commit 39c73e3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Auto create tags from commit or package.json
- `token` Your `GITHUB_TOKEN`. This is required. Why do we need `token`? Read more here: [About the GITHUB_TOKEN secret](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/authenticating-with-the-github_token#about-the-github_token-secret). Default: `${{ github.token }}`
- `version` Create tag for specified version. Exampe: `version: v1.0.0`
- `test` The regular expression matches the submitted content. Exampe: `test: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'`
- `commit` The regular expression matches the submitted content. Default: `{github.context.payload?.head_commit?.message}`
- `package-path` The path of the `package.json` file. Default `package.json`.
- `release` Optionally marks this tag as `release`. Set to `true` to enable.
- `prerelease` Optionally marks this release as `prerelease`. Set to `true` to enable.
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ inputs:
default: ''
required: false

commit:
description: 'Compare the tag `version` number in the `commit content` with the last tag and automatically generate tags'
default: ''
required: false

package-path:
description: 'The path of the package.json file.'
default: 'package.json'
Expand Down
4 changes: 2 additions & 2 deletions dist/main.js

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

3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ async function run(): Promise<void> {
const prerelease = core.getBooleanInput('prerelease') || false
/** Optionally marks this release as a draft release. Set to true to enable. */
const draft = core.getBooleanInput('draft') || false
/** Compare the tag `version` number in the `commit content` with the last tag and automatically generate tags */
const commit: string = core.getInput('commit') || github.context.payload?.head_commit?.message || ''
/** The path of the `package.json` file. Default `package.json`. */
const packagePath = core.getInput('package-path')
// Example: v1.0.0
const inputVersion = core.getInput('version')
const octokit = github.getOctokit(myToken)
const {owner, repo} = github.context.repo
const commit: string = github.context.payload?.head_commit?.message || ''
core.info(`commit: ${commit || '\x1b[31;1mNo commit found\x1b[0m'}`)
const latestRelease = await octokit.rest.repos.getLatestRelease({
owner,
Expand Down

0 comments on commit 39c73e3

Please sign in to comment.