Skip to content

Commit

Permalink
ci: 👷 enhance github actions for the release
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdihadeli committed Sep 18, 2024
1 parent 4b3ff61 commit 44a0808
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 96 deletions.
83 changes: 42 additions & 41 deletions .github/multi-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,83 +5,84 @@ version: v1
labels:
- label: "feature"
matcher:
title: '^(feat)(\([a-z ]+\))?: .'
commits: '^(feat)(\([a-z ]+\))?: .'
branch: '^(feat)(\([a-z ]+\))?\/.'
title: '/^(feat)(\([a-z ]+\))?: .+/'
commits: '/^(feat)(\([a-z ]+\))?: .+/'
branch: '/^(feat)(\([a-z ]+\))?\/.+/'

- label: "bug"
matcher:
title: '^(fix)(\([a-z ]+\))?: .'
commits: '^(fix)(\([a-z ]+\))?: .'
branch: '^(fix)(\([a-z ]+\))?\/.'
title: '/^(fix)(\([a-z ]+\))?: .+/'
commits: '/^(fix)(\([a-z ]+\))?: .+/'
branch: '/^(fix)(\([a-z ]+\))?\/.+/'

- label: "chore"
matcher:
title: '^(chore)(\([a-z ]+\))?: .'
commits: '^(chore)(\([a-z ]+\))?: .'
branch: '^(chore)(\([a-z ]+\))?\/.'
title: '/^(chore)(\([a-z ]+\))?: .+/'
commits: '/^(chore)(\([a-z ]+\))?: .+/'
branch: '/^(chore)(\([a-z ]+\))?\/.+/'

- label: "documentation"
matcher:
title: '^(docs)(\([a-z ]+\))?: .'
commits: '^(docs)(\([a-z ]+\))?: .'
branch: '^(docs)(\([a-z ]+\))?\/.'
title: '/^(docs)(\([a-z ]+\))?: .+/'
commits: '/^(docs)(\([a-z ]+\))?: .+/'
branch: '/^(docs)(\([a-z ]+\))?\/.+/'

- label: "devops"
matcher:
title: '^(ci)(\([a-z ]+\))?: .'
commits: '^(ci)(\([a-z ]+\))?: .'
branch: '^(ci)(\([a-z ]+\))?\/.'
title: '/^(ci)(\([a-z ]+\))?: .+/'
commits: '/^(ci)(\([a-z ]+\))?: .+/'
branch: '/^(ci)(\([a-z ]+\))?\/.+/'

- label: "ci-cd"
matcher:
title: '^(ci)(\([a-z ]+\))?: .'
commits: '^(ci)(\([a-z ]+\))?: .'
branch: '^(ci)(\([a-z ]+\))?\/.'
title: '/^(ci)(\([a-z ]+\))?: .+/'
commits: '/^(ci)(\([a-z ]+\))?: .+/'
branch: '/^(ci)(\([a-z ]+\))?\/.+/'

- label: "enhancement"
matcher:
title: '^(refactor)(\([a-z ]+\))?: .'
commits: '^(refactor)(\([a-z ]+\))?: .'
branch: '^(refactor)(\([a-z ]+\))?\/.'
title: '/^(refactor)(\([a-z ]+\))?: .+/'
commits: '/^(refactor)(\([a-z ]+\))?: .+/'
branch: '/^(refactor)(\([a-z ]+\))?\/.+/'

- label: "style"
matcher:
title: '^(style)(\([a-z ]+\))?: .'
commits: '^(style)(\([a-z ]+\))?: .'
branch: '^(style)(\([a-z ]+\))?\/.'
title: '/^(style)(\([a-z ]+\))?: .+/'
commits: '/^(style)(\([a-z ]+\))?: .+/'
branch: '/^(style)(\([a-z ]+\))?\/.+/'

- label: "performance"
matcher:
title: '^(perf)(\([a-z ]+\))?: .'
commits: '^(perf)(\([a-z ]+\))?: .'
branch: '^(perf)(\([a-z ]+\))?\/.'
title: '/^(perf)(\([a-z ]+\))?: .+/'
commits: '/^(perf)(\([a-z ]+\))?: .+/'
branch: '/^(perf)(\([a-z ]+\))?\/.+/'

- label: "build"
matcher:
title: '^(build)(\([a-z ]+\))?: .'
commits: '^(build)(\([a-z ]+\))?: .'
branch: '^(build)(\([a-z ]+\))?\/.'
title: '/^(build)(\([a-z ]+\))?: .+/'
commits: '/^(build)(\([a-z ]+\))?: .+/'
branch: '/^(build)(\([a-z ]+\))?\/.+/'

- label: "test"
matcher:
title: '^(test)(\([a-z ]+\))?: .'
commits: '^(test)(\([a-z ]+\))?: .'
branch: '^(test)(\([a-z ]+\))?\/.'
title: '/^(test)(\([a-z ]+\))?: .+/'
commits: '/^(test)(\([a-z ]+\))?: .+/'
branch: '/^(test)(\([a-z ]+\))?\/.+/'

- label: "dependencies"
matcher:
title: '^build\(deps\): .'
commits: '^build\(deps\): .'
title: '/^(build)(\([a-z ]+\))?: .+/'
commits: '/^(build)(\([a-z ]+\))?: .+/'
branch: '/^(build)(\([a-z ]+\))?\/.+/'

- label: "minor"
matcher:
title: '^(feat)(\([a-z ]+\))?: .'
commits: '^(feat)(\([a-z ]+\))?: .'
branch: '^(feat)(\([a-z ]+\))?\/.'
title: '/^(feat)(\([a-z ]+\))?: .+/'
commits: '/^(feat)(\([a-z ]+\))?: .+/'
branch: '/^(feat)(\([a-z ]+\))?\/.+/'

- label: "patch"
matcher:
title: '^(fix)(\([a-z ]+\))?: .'
commits: '^(fix)(\([a-z ]+\))?: .'
branch: '^(fix)(\([a-z ]+\))?\/.'
title: '/^(fix)(\([a-z ]+\))?: .+/'
commits: '/^(fix)(\([a-z ]+\))?: .+/'
branch: '/^(fix)(\([a-z ]+\))?\/.+/'
91 changes: 56 additions & 35 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,48 +70,69 @@ categories:
# https://www.trywilco.com/post/wilco-ci-cd-github-heroku
# https://github.com/release-drafter/release-drafter#autolabeler
# https://github.com/fuxingloh/multi-labeler

# Using regex for defining rules - https://regexr.com/
# https://stackoverflow.com/questions/58899999/regexp-to-match-conventional-commit-syntax
# Auto-labeler: Assign labels based on branch names or PR titles that follow Conventional Commits
# Note: because of escaping logic inside of release drafter our regex should be escaped correctly and drafter wil un-escape it internally
# - Escaped regex: When writing a regular expression as a string in code, special characters like (, ), and : need to be escaped with a backslash (\) because these characters have special meanings in regex.
# - Unescaped regex: If you use a raw regex literal (i.e., surrounded by slashes /.../), the regex engine interprets it directly, and you don’t need to double-escape the special characters.
autolabeler:
- label: "chore"
branch:
- '^(chore)(\([a-z ]+\))?\/.'
title:
- '^(chore)(\([a-z ]+\))?: .'
- label: "bug"
branch:
- '^(fix)(\([a-z ]+\))?\/.'
title:
- '^(fix)(\([a-z ]+\))?: .'
- label: "feature"
branch:
- '^(feat)(\([a-z ]+\))?\/.'
title:
- '^(feat)(\([a-z ]+\))?: .'
- label: "style"
branch:
- '^(style)(\([a-z ]+\))?\/.'
title:
- '^(style)(\([a-z ]+\))?: .'
- label: "ci-cd"
branch:
- '^(ci)(\([a-z ]+\))?\/.'
title:
- '^(ci)(\([a-z ]+\))?: .'
- label: "minor"
- label: 'chore'
branch:
- '/^(chore)(\([a-z ]+\))?\/.+/'
title:
- '/^(chore)(\([a-z ]+\))?: .+/'
- label: 'enhancement'
branch:
- '/^(refactor)(\([a-z ]+\))?\/.+/'
title:
- '/^(refactor)(\([a-z ]+\))?: .+/'
- label: 'documentation'
branch:
- '/^(docs)(\([a-z ]+\))?\/.+/'
title:
- '/^(docs)(\([a-z ]+\))?: .+/'
- label: 'ci-cd'
branch:
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(ci)(\([a-z ]+\))?: .+/'
- label: 'devops'
branch:
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '/^(ci)(\([a-z ]+\))?: .+/'
- label: 'test'
branch:
- '/^(test)(\([a-z ]+\))?\/.+/'
title:
- '/^(test)(\([a-z ]+\))?: .+/'
- label: 'bug'
branch:
- '/^(fix)(\([a-z ]+\))?\/.+/'
title:
- '/^(fix)(\([a-z ]+\))?: .+/'
- label: 'style'
branch:
- '/^(style)(\([a-z ]+\))?\/.+/'
title:
- '/^(style)(\([a-z ]+\))?: .+/'
- label: 'feature'
branch:
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '/^(feat)(\([a-z ]+\))?: .+/'
- label: 'minor'
branch:
- '^(feat)(\([a-z ]+\))?\/.'
- '/^(feat)(\([a-z ]+\))?\/.+/'
title:
- '^(feat)(\([a-z ]+\))?: .'
- label: "patch"
- '/^(feat)(\([a-z ]+\))?: .+/'
- label: 'patch'
branch:
- '^(fix)(\([a-z ]+\))?\/.'
- '^(ci)(\([a-z ]+\))?\/.'
- '/^(fix)(\([a-z ]+\))?\/.+/'
- '/^(ci)(\([a-z ]+\))?\/.+/'
title:
- '^(fix)(\([a-z ]+\))?: .'
- '^(ci)(\([a-z ]+\))?: .'
- '/^(fix)(\([a-z ]+\))?: .+/'
- '/^(ci)(\([a-z ]+\))?: .+/'

change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Auto Labeler

on:
pull_request:
types: [opened, edited, synchronize, ready_for_review]

pull_request_target:
types:
- opened
- synchronize
- reopened
- labeled
- unlabeled
# pull_request_target:

jobs:
auto-labeler:
Expand All @@ -20,28 +24,27 @@ jobs:
# checks: write

steps:
## doesn't work
# - uses: release-drafter/release-drafter@v6
# with:
# config-name: release-drafter.yml
# disable-releaser: true # releaser mode is disabled.
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
disable-releaser: true # releaser mode is disabled.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - uses: fuxingloh/multi-labeler@v1
# name: conventional-commits-pull-request-labeler
# with:
# github-token: ${{secrets.GITHUB_TOKEN}} # optional, default to '${{ github.token }}'
# config-path: .github/multi-labeler.yml # optional, default to '.github/labeler.yml'

# https://github.com/actions/labeler
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
# # https://github.com/actions/labeler
# - uses: actions/labeler@v5
# with:
# repo-token: "${{ secrets.GITHUB_TOKEN }}"
# sync-labels: true

# https://docs.github.com/en/actions/using-workflows/about-workflows#creating-dependent-jobs
# https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow
# https://docs.github.com/en/actions/using-workflows/about-workflows#creating-dependent-jobs
# https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow
- name: check-conventional-commits-labels
uses: docker://agilepathway/pull-request-label-checker:latest
if: success()
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ name: Release Drafter
on:
push:
branches:
- main
- "main"

jobs:
update_release_draft:
update-release-draft:
name: Release drafter
runs-on: ubuntu-latest

permissions:
# write permission is required to create a github release
contents: write

steps:
- name: Update Release Draft
uses: release-drafter/release-drafter@v6
id: semantic
with:
config-name: release-drafter.yml
disable-autolabeler: true
## Default versioning just increase the path version as default. but the can use minor, patch and breaking-changes labels to apply semver
# version: 1.29.1
env:
Expand Down

0 comments on commit 44a0808

Please sign in to comment.