Skip to content
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

ci: automate releases by relying on conventional commits #99

Merged
merged 3 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@ updates:
schedule:
interval: monthly
day: saturday
commit-message:
prefix: ci
labels:
- dependencies
# Update Go dependencies
- directory: /
package-ecosystem: gomod
schedule:
interval: monthly
day: saturday
commit-message:
prefix: build(go)
labels:
- dependencies
# Update Docker base images
- directory: /
package-ecosystem: docker
schedule:
interval: monthly
day: saturday
commit-message:
prefix: build(docker)
labels:
- dependencies
87 changes: 87 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# >>> PULL REQUEST LABELS
autolabeler:
# Conventional Commit Types (https://github.com/commitizen/conventional-commit-types)
- label: build
title:
- '/^build(\(.*\))?(\!)?\:/'
- label: chore
title:
- '/^chore(\(.*\))?(\!)?\:/'
- label: ci
title:
- '/^ci(\(.*\))?(\!)?\:/'
- label: documentation
title:
- '/^docs(\(.*\))?(\!)?\:/'
- label: enhancement
title:
- '/^feat(\(.*\))?(\!)?\:/'
- label: fix
title:
- '/^fix(\(.*\))?(\!)?\:/'
- label: performance
title:
- '/^perf(\(.*\))?(\!)?\:/'
- label: refactor
title:
- '/^refactor(\(.*\))?(\!)?\:/'
- label: revert
title:
- '/^revert(\(.*\))?(\!)?\:/'
- label: style
title:
- '/^style(\(.*\))?(\!)?\:/'
- label: test
title:
- '/^test(\(.*\))?(\!)?\:/'
# Custom Types
- label: breaking
title:
- '/^[a-z]+(\(.*\))?\!\:/'
# >>> AUTOMATIC VERSIONING (PRE 1.0)
version-resolver:
minor:
labels:
- breaking
default: patch
# >>> RELEASE CONFIGURATION
name-template: "v$RESOLVED_VERSION"
tag-template: "v$RESOLVED_VERSION"
change-template: "- $TITLE by @$AUTHOR in [#$NUMBER]($URL)"
replacers:
# remove conventional commit tag & scope from change list
- search: '/- [a-z]+(\(.*\))?(\!)?\: /g'
replace: "- "
template: |
# What's Changed

$CHANGES

**Full Changelog:** [$PREVIOUS_TAG...v$RESOLVED_VERSION](https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION)
categories:
- title: ⚠️ Breaking Changes
labels:
- breaking
- title: ✨ New Features
labels:
- enhancement
- title: 🐞 Bug Fixes
labels:
- fix
- title: 🏎️ Performance Improvements
labels:
- performance
- title: 🏗️ Testing
labels:
- test
- title: 📝 Documentation
labels:
- documentation
- title: 🪵 Miscellaneous
labels:
- build
- chore
- ci
- refactor
- revert
- style
61 changes: 61 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Pull Request
on:
pull_request:
branches: [main]
types: [opened, reopened, edited, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write

jobs:
check-title:
name: Check Title
runs-on: ubuntu-latest
steps:
- name: Check valid conventional commit message
id: lint
uses: amannn/action-semantic-pull-request@v5
with:
subjectPattern: ^(?![A-Z]).+$ # subject should not start with uppercase letter
scopes: |
go
helm
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Post comment about invalid PR title
if: failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: conventional-commit-pr-title
message: |
Thank you for opening this pull request! 👋🏼

This repository requires pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.

<details><summary>**Details**</summary>

```
${{ steps.lint.outputs.error_message }}
```

</details>
- name: Delete comment about invalid PR title
uses: marocchino/sticky-pull-request-comment@v2
with:
header: conventional-commit-pr-title
delete: true

assign-labels:
name: Assign Labels
runs-on: ubuntu-latest
steps:
- name: Assign labels based on conventional commits
uses: release-drafter/release-drafter@v5
with:
disable-releaser: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release
on:
push:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write

jobs:
update:
name: Update Draft
runs-on: ubuntu-latest
steps:
- name: Update draft release
uses: release-drafter/release-drafter@v5
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ci:
autofix_prs: false
skip: [golangci-lint]
autoupdate_commit_msg: "style: pre-commit autoupdate"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down