Skip to content

Commit

Permalink
fix(changelog): current date
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Nov 5, 2023
1 parent 5a84ce0 commit d932c9a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
run: node ./dist/cli.mjs bump -w ${{ needs.preflight.outputs.version }}
- id: changelog
name: Add CHANGELOG entry for ${{ needs.preflight.outputs.tag }}
env:
TZ: ${{ vars.TZ }}
run: |
echo "$(node ./dist/cli.mjs changelog)" >>$GITHUB_STEP_SUMMARY
node ./dist/cli.mjs changelog -sw
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ jobs:
run: yarn pack -o %s-%v.tgz
- id: release-notes
name: Generate release notes
env:
TZ: ${{ vars.TZ }}
run: |
node ./dist/cli.mjs changelog -wo $NOTES_FILE
echo "$(cat $NOTES_FILE)" >>$GITHUB_STEP_SUMMARY
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/changelog/today.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* @module tests/fixtures/changelog/today
*/

export default '2023-09-25'
export default '2023-09-25T00:00:00-04:00'
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('unit:changelog/models/ChangelogEntry', () => {
})

it('should set #date', () => {
expect(subject).to.have.property('date', today)
expect(subject).to.have.property('date', today.replace(/T.+/, ''))
})

it('should set #groups', () => {
Expand Down
14 changes: 13 additions & 1 deletion src/subdomains/changelog/models/changelog-entry.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,20 @@ class ChangelogEntry<T extends Commit = Commit> implements IChangelogEntry<T> {
*/
const key: Optional<T> = commits.find(c => c.version === release)

/**
* Current date.
*
* @const {string} today
*/
const today: string = new Intl.DateTimeFormat('fr-ca', {
day: '2-digit',
month: '2-digit',
timeZone: process.env.TZ,
year: 'numeric'
}).format(new Date())

// set entry date
this.date = get(key, 'date', new Date().toJSON()).replace(/T.+/, '')
this.date = get(key, 'date', today).replace(/T.+/, '')
this.key = fallback(key, at(commits, 0))

// throw if key commit was not found
Expand Down

0 comments on commit d932c9a

Please sign in to comment.