Skip to content

Commit

Permalink
chore: Automate release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjjaramillo committed Apr 25, 2024
1 parent 28b078c commit 38426d8
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/draft-image-release-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
# A known prefix used to filter release tags. For matching tags,
# this prefix is stripped before attempting to parse the version
tag-prefix: 'v'

categories:
- title: '💥 Breaking Changes'
label: 'Release/break'
- title: '🚀 Features'
label: 'Release/feat'
- title: '🐛 Bug Fixes'
label: 'Release/fix'
- title: '📝 Other'
label: 'Release/other'
exclude-labels:
- 'Release/skip'

autolabeler:
- label: 'Release/break'
title:
- '/!:/'
- label: 'Release/feat'
title:
- '/^feat/i'
- label: 'Release/fix'
title:
- '/^fix/i'
- label: 'Release/other'
title:
- '/^(build|chore|ci|docs|perf|refactor|revert|style|test)/i'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&'
replacers:
# Remove conventional commit prefix
- search: '/^- [a-zA-Z]+(\([a-zA-Z]+\))?!?:\s*/gm'
replace: '- '

version-resolver:
major:
labels:
- 'Release/break'
minor:
labels:
- 'Release/feat'
patch:
labels:
- 'Release/fix'
default: minor

template: |
$CHANGES
**Full Changelog**: https://github.com/newrelic/k8s-agents-operator/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
50 changes: 50 additions & 0 deletions .github/workflows/draft-image-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Draft Image Release

on:
push:
branches:
- main
pull_request:
types: [opened, reopened, edited, synchronize]

permissions:
contents: read

jobs:
update_release_draft:
name: Autolabeler and release drafter
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
# Command `gh pr edit` needs to run in a repository,
# so fetch a single file to make next step succeed
- name: Checkout GitHub Repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
if: github.event_name == 'pull_request'
with:
sparse-checkout: |
README.md
sparse-checkout-cone-mode: false

- name: Remove labels in preparation for autolabeler
if: github.event_name == 'pull_request'
run: |
gh pr edit ${{ github.event.number }} \
--remove-label "Release/break,Release/feat,Release/fix,Release/other" \
|| exit 0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Release drafter
uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
id: draft-image-release
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
with:
# To achive consistent results with different branches
# Source: https://github.com/release-drafter/release-drafter/issues/1061#issuecomment-1032888355
commitish: "${{ github.ref_name }}"
config-name: draft-image-release-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "Lint PR"

on:
pull_request:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Lint PR title
uses: amannn/action-semantic-pull-request@cfb60706e18bc85e8aec535e3c577abe8f70378e # v5.5.2
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Write error message if lint fails
if: failure() && (steps.lint_pr_title.outputs.error_message != null)
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-title-lint-error
message: |
Thank you for opening this pull request. We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).
Your proposed title needs to be adjusted:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
- name: Delete resolved issues
if: ${{ steps.lint_pr_title.outputs.error_message == null }}
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
with:
header: pr-title-lint-error
delete: true

0 comments on commit 38426d8

Please sign in to comment.