Skip to content

Commit 71429e1

Browse files
authored
ci: Add auto-labeler and release (#88)
1 parent d1ece9e commit 71429e1

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "rn-pr-labeler"
2+
author: "@gmuloc"
3+
description: "Parse a conventional commit compliant PR title and add it as a label to the PR with the prefix 'rn: '"
4+
inputs:
5+
auto_create_label:
6+
description: "Boolean to indicate if the label should be auto created"
7+
required: false
8+
default: false
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: 'Looking up existing "rn:" label'
13+
run: |
14+
echo "OLD_LABEL=$(gh pr view ${{ github.event.pull_request.number }} --json labels -q .labels[].name | grep 'rn: ')" >> $GITHUB_ENV
15+
shell: bash
16+
- name: 'Delete existing "rn:" label if found'
17+
run: gh pr edit ${{ github.event.pull_request.number }} --remove-label "${{ env.OLD_LABEL }}"
18+
shell: bash
19+
if: ${{ env.OLD_LABEL }}
20+
- name: Set Label
21+
# Using toJSON to support ' and " in commit messages
22+
# https://stackoverflow.com/questions/73363167/github-actions-how-to-escape-characters-in-commit-message
23+
run: echo "LABEL=$(echo ${{ toJSON(github.event.pull_request.title) }} | cut -d ':' -f 1 | tr -d ' ')" >> $GITHUB_ENV
24+
shell: bash
25+
# an alternative to verifying if the target label already exist is to
26+
# create the label with --force in the next step, it will keep on changing
27+
# the color of the label though so it may not be desirable.
28+
- name: Check if label exist
29+
run: |
30+
EXIST=$(gh label list -L 100 --search "rn:" --json name -q '.[] | select(.name=="rn: ${{ env.LABEL }}").name')
31+
echo "EXIST=$EXIST" >> $GITHUB_ENV
32+
shell: bash
33+
- name: Create Label if auto-create and label does not exist already
34+
run: |
35+
gh label create "rn: ${{ env.LABEL }}"
36+
shell: bash
37+
if: ${{ inputs.auto_create_label && ! env.EXIST }}
38+
- name: Labelling PR
39+
run: |
40+
gh pr edit ${{ github.event.pull_request.number }} --add-label "rn: ${{ env.LABEL }}"
41+
shell: bash

.github/release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- 'rn: test'
5+
- 'rn: ci'
6+
categories:
7+
- title: Breaking Changes
8+
labels:
9+
- 'rn: feat!'
10+
- 'rn: feat(cli)!'
11+
- 'rn: fix!'
12+
- 'rn: fix(cli)!'
13+
- 'rn: cut!'
14+
- 'rn: cut(cli)!'
15+
- 'rn: revert!'
16+
- 'rn: revert(cli)!'
17+
- 'rn: refactor!'
18+
- 'rn: refactor(cli)!'
19+
- 'rn: bump!'
20+
- 'rn: bump(cli)!'
21+
- 'rn: feat!'
22+
- 'rn: fix!'
23+
- 'rn: cut!'
24+
- 'rn: revert!'
25+
- 'rn: refactor!'
26+
- 'rn: bump!'
27+
- title: New features and enhancements
28+
labels:
29+
- 'rn: feat'
30+
- 'rn: feat(cli)'
31+
- title: Fixed issues
32+
labels:
33+
- 'rn: fix'
34+
- 'rn: fix(cli)'
35+
- title: Documentation
36+
labels:
37+
- 'rn: doc!'
38+
- title: Other Changes
39+
labels:
40+
- '*'

0 commit comments

Comments
 (0)