Skip to content

Commit

Permalink
feat: add reverseOrder option to list commits from newer to older
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Mar 17, 2023
1 parent d47b63a commit 01c1b24
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,26 @@ jobs:
```

## Inputs
* `token`: Your GitHub token (e.g. `${{ github.token }}`) - **REQUIRED**
* `tag`: The latest tag which triggered the job. (e.g. `${{ github.ref_name }}`) - **REQUIRED (unless using `fromTag` and `toTag`)**
* `fromTag`: The tag from which the changelog is to be determined (latest) - **REQUIRED (unless using `tag`)**
* `toTag`: The tag up to which the changelog is to be determined (oldest) - **REQUIRED (unless using `tag`)**
* `excludeTypes`: A comma-separated list of commit types you want to exclude from the changelog (e.g. `doc,chore,perf`) - **Optional** - Default: `build,docs,other,style`
* `writeToFile`: Should CHANGELOG.md be updated with latest changelog - **Optional** - Default: `true`
* `includeRefIssues`: Should the changelog include the issues referenced for each PR. - **Optional** - Default: `true`
* `useGitmojis`: Should type headers be prepended with their related gitmoji - **Optional** - Default: `true`
* `includeInvalidCommits`: Whether to include commits that don't respect the Conventional Commits format - **Optional** - Default: `false`

| Field | Description | Required | Default |
|-------|-------------|:--------:|---------|
| `token` | Your GitHub token (e.g. `${{ github.token }}`) | :white_check_mark: | |
| `tag` | The latest tag which triggered the job. (e.g. `${{ github.ref_name }}`) | :white_check_mark: *(unless using `fromTag` and `toTag`)* | |
| `fromTag` | The tag from which the changelog is to be determined (latest) | :white_check_mark: *(unless using `tag`)* | |
| `toTag` | The tag up to which the changelog is to be determined (oldest) | :white_check_mark: *(unless using `tag`)* | |
| `excludeTypes` | A comma-separated list of commit types you want to exclude from the changelog (e.g. `doc,chore,perf`) | :x: | `build,docs,other,style` |
| `writeToFile` | Should CHANGELOG.md be updated with latest changelog | :x: | `true` |
| `includeRefIssues` | Should the changelog include the issues referenced for each PR. | :x: | `true` |
| `useGitmojis` | Should type headers be prepended with their related gitmoji | :x: | `true` |
| `includeInvalidCommits` | Whether to include commits that don't respect the Conventional Commits format | :x: | `false` |
| `reverseOrder` | List commits in reverse order (from newer to older) instead of the default (older to newer). | :x: | `false` |

## Outputs
* `changes`: Generated CHANGELOG changes for the latest tag, without the version / date header (for use in GitHub Releases).

## Important
| Field | Description |
|-------|-------------|
| `changes` | Generated CHANGELOG changes for the latest tag, without the version / date header *(for use in GitHub Releases)*. |

## :warning: Important :warning:

You must already have 2 tags in your repository (1 previous tag + the current latest tag triggering the job). The job will exit with an error if it can't find the previous tag!
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
description: Whether to include commits that don't respect the Conventional Commits format
required: false
default: 'false'
reverseOrder:
description: List commits in reverse order (from newer to older) instead of the default (older to newer).
required: false
default: 'false'
outputs:
changelog:
description: Generated changelog
Expand Down
5 changes: 5 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28154,6 +28154,7 @@ async function main () {
const includeRefIssues = core.getBooleanInput('includeRefIssues')
const useGitmojis = core.getBooleanInput('useGitmojis')
const includeInvalidCommits = core.getBooleanInput('includeInvalidCommits')
const reverseOrder = core.getBooleanInput('reverseOrder')
const gh = github.getOctokit(token)
const owner = github.context.repo.owner
const repo = github.context.repo.repo
Expand Down Expand Up @@ -28293,6 +28294,10 @@ async function main () {
return core.setFailed('No valid commits parsed since previous tag.')
}

if (reverseOrder) {
commitsParsed.reverse()
}

// BUILD CHANGELOG

const changesFile = []
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async function main () {
const includeRefIssues = core.getBooleanInput('includeRefIssues')
const useGitmojis = core.getBooleanInput('useGitmojis')
const includeInvalidCommits = core.getBooleanInput('includeInvalidCommits')
const reverseOrder = core.getBooleanInput('reverseOrder')
const gh = github.getOctokit(token)
const owner = github.context.repo.owner
const repo = github.context.repo.repo
Expand Down Expand Up @@ -208,6 +209,10 @@ async function main () {
return core.setFailed('No valid commits parsed since previous tag.')
}

if (reverseOrder) {
commitsParsed.reverse()
}

// BUILD CHANGELOG

const changesFile = []
Expand Down

0 comments on commit 01c1b24

Please sign in to comment.