From cf4b8e9d2561cfe4cd64c1a1e85caec4923aff69 Mon Sep 17 00:00:00 2001 From: Aaron Steers Date: Wed, 23 Apr 2025 10:08:28 -0700 Subject: [PATCH] chore: add a release process (wip) --- .github/pr-prefix-labeler.yml | 14 +++++ .github/release-drafter-config.yml | 42 +++++++++++++ .github/workflows/release-drafter.yml | 24 +++++++ .github/workflows/semantic-pr-title-check.yml | 63 +++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 .github/pr-prefix-labeler.yml create mode 100644 .github/release-drafter-config.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/semantic-pr-title-check.yml diff --git a/.github/pr-prefix-labeler.yml b/.github/pr-prefix-labeler.yml new file mode 100644 index 0000000..40e898f --- /dev/null +++ b/.github/pr-prefix-labeler.yml @@ -0,0 +1,14 @@ +feat: 'feature' +Feat: 'feature' +fix: 'bug' +Fix: 'bug' +chore: 'chore' +Chore: 'chore' +docs: 'documentation' +Docs: 'documentation' +test: 'test' +Test: 'test' +ci: 'ci' +CI: 'ci' +refactor: 'chore' +Refactor: 'chore' diff --git a/.github/release-drafter-config.yml b/.github/release-drafter-config.yml new file mode 100644 index 0000000..1c4b5c5 --- /dev/null +++ b/.github/release-drafter-config.yml @@ -0,0 +1,42 @@ +# Configuration for Release Drafter workflow +name-template: "v$RESOLVED_VERSION" +tag-template: "v$RESOLVED_VERSION" +categories: + - title: "🚀 Features" + labels: + - "feature" + - "enhancement" + - title: "🐛 Bug Fixes" + labels: + - "fix" + - "bugfix" + - "bug" + - title: "🧰 Maintenance" + labels: + - "chore" + - "maintenance" + - "documentation" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +change-title-escapes: '\<*_&' +# You can add # and @ to disable mentions, and add ` to disable code blocks +version-resolver: + default: patch + major: + labels: + # We don't auto-bump major versions. Needs to be done manually. + minor: + labels: + - "feature" + - "enhancement" + patch: + labels: + - "patch" + - "bugfix" + - "bug" + - "chore" + - "maintenance" + - "documentation" +template: | + ## Changes + + $CHANGES diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..104520f --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,24 @@ +name: Release Drafter + +on: + push: + branches: + - main + pull_request: + types: [opened, reopened, synchronize] + +jobs: + update_release_draft: + permissions: + # write permission is required to create a github release + contents: write + # write permission is required for autolabeler + # otherwise, read permission is required at least + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v6 + with: + config-name: release-drafter-config.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/semantic-pr-title-check.yml b/.github/workflows/semantic-pr-title-check.yml new file mode 100644 index 0000000..71388a5 --- /dev/null +++ b/.github/workflows/semantic-pr-title-check.yml @@ -0,0 +1,63 @@ +name: "Semantic PR Title Check" + +on: + pull_request_target: + types: + - opened + - reopened + - edited + - synchronize + - ready_for_review + +permissions: + pull-requests: read + +jobs: + validate_pr_title: + name: Validate PR title + runs-on: ubuntu-24.04 + steps: + - uses: amannn/action-semantic-pull-request@v5 + if: ${{ github.event.pull_request.draft == false }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # Configure which types are allowed (newline-delimited). + # These are intentionally case-insensitive, allowing title casing or all lowercase. + # See: https://github.com/commitizen/conventional-commit-types/blob/master/index.json + types: | + fix + Fix + feat + Feat + docs + Docs + ci + CI + chore + Chore + build + Build + tests + Tests + refactor + Refactor + + - name: Check for "do not merge" in PR title + if: ${{ github.event.pull_request.draft == false }} + uses: actions/github-script@v7 + with: + script: | + const title = context.payload.pull_request.title.toLowerCase(); + if (title.includes('do not merge') || title.includes('do-not-merge')) { + core.setFailed('PR title contains "do not merge" or "do-not-merge". Please remove this before merging.'); + } + +jobs: + pr-labeler: + runs-on: ubuntu-latest + steps: + - name: Label the PR + uses: gerrymanoim/pr-prefix-labeler@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}