Skip to content

Commit

Permalink
Add sections output (#65)
Browse files Browse the repository at this point in the history
Adds a sections output object containing all the different sections in
the changelog and the list of changes
  • Loading branch information
lucacome authored Mar 31, 2023
1 parent 0caac4c commit 154068a
Show file tree
Hide file tree
Showing 7 changed files with 328 additions and 143 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
echo "Release Notes: ${{ steps.draft-release.outputs.release-notes }}"
echo "Release URL: ${{ steps.draft-release.outputs.release-url }}"
echo "Release ID: ${{ steps.draft-release.outputs.release-id }}"
echo "Release Sections: ${{ steps.draft-release.outputs.release-sections }}"
73 changes: 71 additions & 2 deletions __tests__/notes.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {describe, expect, test, it} from '@jest/globals'
import {parseNotes, generateReleaseNotes} from '../src/notes'
import {parseNotes, generateReleaseNotes, splitMarkdownSections} from '../src/notes'
import * as github from '@actions/github'
import {Inputs} from '../src/context'
import {helpers} from 'handlebars'
import {Category} from '../src/version'

jest.mock('@actions/core')
jest.mock('@actions/github')
Expand Down Expand Up @@ -143,7 +144,7 @@ describe('generateReleaseNotes', () => {
* doc 2
* doc 3
### 🧹 Chores
### 🔨 Maintenance
* chore 1
* chore 2
* chore 3
Expand Down Expand Up @@ -173,3 +174,71 @@ describe('generateReleaseNotes', () => {
expect(notes).not.toContain('<details><summary>3 changes</summary>')
})
})

const markdown = `
<!-- Release notes generated using configuration in .github/release.yml at main -->
## What's Changed
### 🐛 Bug Fixes
* Bump anchore/sbom-action from 0.13.1 to 0.13.4 by @dependabot in https://github.com/somerepo/pull/200
### 🧪 Tests
* update by @lucacome in https://github.com/somerepo/pull/205
### 🔨 Maintenance
* Bump aquasecurity/trivy-action from 0.8.0 to 0.9.2 by @dependabot in https://github.com/somerepo/pull/175
* Bump actions/setup-go from 3 to 4 by @dependabot in https://github.com/somerepo/pull/198
**Full Changelog**: https://github.com/somerepo/compare/v5.0.4...v5.0.5`

describe('splitMarkdownSections', () => {
it('splits sections correctly', async () => {
const expectedOutput = {
bug: ['* Bump anchore/sbom-action from 0.13.1 to 0.13.4 by @dependabot in https://github.com/somerepo/pull/200'],
tests: ['* update by @lucacome in https://github.com/somerepo/pull/205'],
chore: [
'* Bump aquasecurity/trivy-action from 0.8.0 to 0.9.2 by @dependabot in https://github.com/somerepo/pull/175',
'* Bump actions/setup-go from 3 to 4 by @dependabot in https://github.com/somerepo/pull/198',
],
dependencies: [],
'*': [],
documentation: [],
enhancement: [],
change: [],
}
const categories = [
{
title: 'Others', // default category
labels: ['*'],
},
{
title: '🐛 Bug Fixes',
labels: ['bug'],
},
{
title: '🧪 Tests',
labels: ['tests'],
},
{
title: '🔨 Maintenance',
labels: ['chore'],
},
{
title: '📦 Dependencies',
labels: ['dependencies'],
},
{
title: '📝 Documentation',
labels: ['documentation'],
},
{
title: '🚀 Features',
labels: ['enhancement'],
},
{
title: '💣 Breaking Changes',
labels: ['change'],
},
]
const result = await splitMarkdownSections(markdown, categories)
expect(result).toEqual(expectedOutput)
})
})
188 changes: 120 additions & 68 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.

Loading

0 comments on commit 154068a

Please sign in to comment.