Skip to content

Commit

Permalink
feat: automated releases and auto labelling
Browse files Browse the repository at this point in the history
- [x] lint pr title adhering to conventional commits (helps with auto labelling)
  - [x] Update CONTRIBUTING.md notifying contributors of this change and new standard
  - [x] Update pull_request_template with new standard
- [x] setup autolabelling through release-drafter github action config
- [x] create auto-labeler workflow
- [x] change release-drafter workflow to release
  - [x] create release, including new tag
  - [x] create discussion announcement based on release
  - [x] build container images, tag them and release them

Signed-off-by: jmeridth <[email protected]>
  • Loading branch information
jmeridth committed Apr 18, 2024
1 parent 4dd12eb commit f845f0d
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 29 deletions.
11 changes: 9 additions & 2 deletions .github/pull_request-template.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Pull Request
<!-- PR title should be brief and descriptive for a good changelog entry -->
<!--
PR title needs to be prefixed with a conventional commit type
(build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test)
It should also be brief and descriptive for a good changelog entry
examples: "feat: add new logger" or "fix: remove unused imports"
-->

## Proposed Changes
<!-- Describe what the changes are and link to a GitHub Issue if one exists -->
Expand All @@ -14,4 +21,4 @@

### Reviewer

- [ ] Label as either `bug`, `documentation`, `enhancement`, `infrastructure`, or `breaking`
- [ ] Label as either `fix`, `documentation`, `enhancement`, `infrastructure`, or `breaking`
37 changes: 32 additions & 5 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ tag-template: 'v$RESOLVED_VERSION'
template: |
# Changelog
$CHANGES
See details of [all code changes](https://github.com/github/issue-metrics/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release
See details of [all code changes](https://github.com/github/issue-metrics/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION) since previous release
categories:
- title: '🚀 Features'
labels:
Expand All @@ -23,6 +23,8 @@ categories:
- 'automation'
- 'documentation'
- 'dependencies'
- 'maintenance'
- 'revert'
- title: '🏎 Performance'
label: 'performance'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
Expand All @@ -35,7 +37,32 @@ version-resolver:
- 'enhancement'
patch:
labels:
- 'bug'
- 'maintenance'
- 'fix'
- 'documentation'
- 'maintenance'
default: patch
autolabeler:
- label: 'automation'
title:
- '/^(build|ci|perf|refactor|test).*/i'
- label: 'enhancement'
title:
- '/^(style).*/i'
- label: 'documentation'
title:
- '/^(docs).*/i'
- label: 'feature'
title:
- '/^(feat).*/i'
- label: 'fix'
title:
- '/^(fix).*/i'
- label: 'infrastructure'
title:
- '/^(infrastructure).*/i'
- label: 'maintenance'
title:
- '/^(chore|maintenance).*/i'
- label: 'revert'
title:
- '/^(revert).*/i'
28 changes: 28 additions & 0 deletions .github/workflows/auto-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Auto Labeler

on:
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
# pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize]

permissions:
contents: read

jobs:
main:
permissions:
contents: write
pull-requests: write
name: Auto label pull requests
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config-name: release-drafter.yml
41 changes: 41 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Reference: https://github.com/amannn/action-semantic-pull-request
---
name: "Lint PR Title"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
contents: read

jobs:
main:
permissions:
pull-requests: read
statuses: write
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline-delimited).
# From: https://github.com/commitizen/conventional-commit-types/blob/master/index.json
# listing all below
types: |
build
chore
ci
docs
feat
fix
perf
refactor
revert
style
test
22 changes: 0 additions & 22 deletions .github/workflows/release-drafter.yml

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: Release

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: read

jobs:
create_release:
outputs:
full-tag: ${{ steps.release-drafter.outputs.tag_name }}
short-tag: ${{ steps.get_tag_name.outputs.SHORT_TAG }}
body: ${{ steps.release-drafter.outputs.body }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: release-drafter/release-drafter@v6
id: release-drafter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config-name: release-drafter.yml
publish: true
- name: Get the short tag
id: get_tag_name
run: |
short_tag=$(echo ${{ steps.release-drafter.outputs.tag_name }} | cut -d. -f1)
echo "SHORT_TAG=$short_tag" >> $GITHUB_OUTPUT
create_action_images:
needs: create_release
runs-on: ubuntu-latest
permissions:
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: issue_metrics # different than repo name (underscore instead of dash)
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Push Docker Image
if: ${{ success() }}
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.create_release.outputs.full-tag }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.create_release.outputs.short-tag }}
platforms: linux/amd64
provenance: false
sbom: false
create_discussion:
needs: create_release
runs-on: ubuntu-latest
permissions:
discussions: write
steps:
- name: Create an announcement discussion for release
uses: abirismyname/[email protected]
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: ${{ needs.create_release.outputs.full-tag }}
body: ${{ needs.create_release.outputs.body }}
repository-id: ${{ secrets.RELEASE_DISCUSSION_REPOSITORY_ID }}
category-id: ${{ secrets.RELEASE_DISCUSSION_CATEGORY_ID }}
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Enhancement suggestions are tracked as [GitHub issues](https://github.com/github
- You may want to **include screenshots and animated GIFs** which help you demonstrate the steps or point out the part which the suggestion is related to.
- **Explain why this enhancement would be useful** to most issue-metrics users.

### Pull Request Standards

We are using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) to standardize our pull request titles. This allows us to automatically generate labels and changelogs and follow semantic versioning. Please follow the commit message format when creating a pull request. What pull request title prefixes are expected are in the [pull_request_template.md](.github/pull_request_template.md) that is shown when creating a pull request.

## Releases

To release a new version, maintainers are to release new versions following semantic versioning and via GitHub Releases.
Expand Down

0 comments on commit f845f0d

Please sign in to comment.