generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 146
ci: add conventional commits changelog generation and commit linting #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| name: Changelog | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: "Version tag to generate changelog for (e.g. v1.0.0)" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| changelog: | ||
| name: Generate Changelog | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| VERSION_TAG: ${{ inputs.version || github.ref_name }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Generate changelog | ||
| uses: orhun/git-cliff-action@v4 | ||
| id: git-cliff | ||
| with: | ||
| config: cliff.toml | ||
| args: --verbose --tag ${{ env.VERSION_TAG }} | ||
| env: | ||
| OUTPUT: CHANGELOG.md | ||
| GITHUB_REPO: ${{ github.repository }} | ||
|
|
||
| - name: Commit changelog | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add CHANGELOG.md | ||
| git commit -m "chore: update changelog for ${{ env.VERSION_TAG }}" || true | ||
| git push origin HEAD:main | ||
|
|
||
| - name: Create/update GitHub release body | ||
| uses: orhun/git-cliff-action@v4 | ||
| with: | ||
| config: cliff.toml | ||
| args: --verbose --latest --strip header | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GITHUB_REPO: ${{ github.repository }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| name: Commit Lint | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| commitlint: | ||
| name: Lint Commit Messages | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install commitlint | ||
| run: npm install --save-dev @commitlint/{cli,config-conventional} | ||
|
|
||
| - name: Lint commits | ||
| run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| [changelog] | ||
| header = """ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| This changelog is automatically generated based on [Conventional Commits](https://www.conventionalcommits.org/).\n | ||
| """ | ||
| body = """ | ||
| {%- macro remote_url() -%} | ||
| https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} | ||
| {%- endmacro -%} | ||
|
|
||
| {% if version -%} | ||
| ## [{{ version | trim_start_matches(pat="v") }}]\ | ||
| {% if commit_id %}({{ self::remote_url() }}/tree/{{ version }}){% endif %}\ | ||
| {% if timestamp %} - {{ timestamp | date(format="%Y-%m-%d") }}{% endif %} | ||
| {% else -%} | ||
| ## [Unreleased] | ||
| {% endif -%} | ||
|
|
||
| {% for group, commits in commits | group_by(attribute="group") %} | ||
| ### {{ group | striptags | trim | upper_first }} | ||
| {% for commit in commits | ||
| | filter(attribute="scope") | ||
| | sort(attribute="scope") %} | ||
| - *({{ commit.scope }})* {{ commit.message | upper_first }}\ | ||
| {% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%} | ||
| {% if commit.github.pr_number %} in \ | ||
| [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }})\ | ||
| {%- endif %} | ||
| {%- endfor -%} | ||
| {% for commit in commits %} | ||
| {%- if not commit.scope %} | ||
| - {{ commit.message | upper_first }}\ | ||
| {% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%} | ||
| {% if commit.github.pr_number %} in \ | ||
| [#{{ commit.github.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.github.pr_number }})\ | ||
| {%- endif %} | ||
| {%- endif -%} | ||
| {%- endfor -%} | ||
| {% endfor %} | ||
| """ | ||
| footer = "" | ||
| trim = true | ||
|
|
||
| [git] | ||
| conventional_commits = true | ||
| filter_unconventional = false | ||
| split_commits = false | ||
| commit_parsers = [ | ||
| { message = "^feat", group = "<!-- 0 -->🚀 Features" }, | ||
| { message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" }, | ||
| { message = "^perf", group = "<!-- 2 -->⚡ Performance" }, | ||
| { message = "^doc", group = "<!-- 3 -->📚 Documentation" }, | ||
| { message = "^example", group = "<!-- 4 -->📦 Examples" }, | ||
| { message = "^refactor", group = "<!-- 5 -->🔧 Refactoring" }, | ||
| { message = "^chore\\(deps\\)", group = "<!-- 6 -->📦 Dependencies" }, | ||
| { message = "^chore|^ci", group = "<!-- 7 -->🏗️ Maintenance" }, | ||
| { message = "^test", group = "<!-- 8 -->🧪 Testing" }, | ||
| { message = "^Bump ", group = "<!-- 6 -->📦 Dependencies" }, | ||
| { message = "^.*", group = "<!-- 9 -->🔀 Other" }, | ||
| ] | ||
| protect_breaking_commits = true | ||
| filter_commits = false | ||
| tag_pattern = "v[0-9].*" | ||
| sort_commits = "newest" | ||
|
|
||
| [remote.github] | ||
| owner = "awslabs" | ||
| repo = "aws-lambda-web-adapter" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| module.exports = { | ||
| extends: ['@commitlint/config-conventional'], | ||
| rules: { | ||
| 'type-enum': [ | ||
| 2, | ||
| 'always', | ||
| [ | ||
| 'feat', | ||
| 'fix', | ||
| 'docs', | ||
| 'example', | ||
| 'examples', | ||
| 'chore', | ||
| 'refactor', | ||
| 'perf', | ||
| 'test', | ||
| 'ci', | ||
| 'revert', | ||
| ], | ||
| ], | ||
| 'subject-case': [0], | ||
| 'body-max-line-length': [0], | ||
| 'footer-max-line-length': [0], | ||
| 'header-max-length': [2, 'always', 120], | ||
| }, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.