From a28c4b55d3870a95a8854ad1417d4d5c1790fbb0 Mon Sep 17 00:00:00 2001 From: GabrielDuf Date: Fri, 30 Oct 2026 10:29:02 -0400 Subject: [PATCH] Label pull requests by changed files and linked issue type Pull requests were left unlabeled unless a bot opened them. Path rules now add the package-manager, translations and appearance labels, and a pull request that closes an issue inherits its bug / new-feature / enhancement label when the linked issues agree on one. translations only counts non-English language files, since most feature PRs add strings to lang_en.json. A PR touching more than three areas gets no area label. The workflow runs on pull_request_target and never checks out PR code, and the labeler reads its config from the base branch. release.yml groups generated release notes by those type labels and leaves Dependabot bumps out. Co-Authored-By: Claude Opus 5.5 --- .github/labeler.yml | 51 ++++++++++++++++++++++++++ .github/release.yml | 24 +++++++++++++ .github/workflows/pr-labeler.yml | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/release.yml create mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..114108a8bc --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,51 @@ +changed-files-labels-limit: 3 + +winget: + - changed-files: + - any-glob-to-any-file: + - src/UniGetUI.PackageEngine.Managers.WinGet/** + - src/WindowsPackageManager.Interop/** + +scoop: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Scoop/** + +chocolatey: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Chocolatey/** + +pip: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Pip/** + +npm: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Npm/** + +powershell: + - changed-files: + - any-glob-to-any-file: + - src/UniGetUI.PackageEngine.Managers.PowerShell/** + - src/UniGetUI.PackageEngine.Managers.PowerShell7/** + +cargo: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Cargo/** + +dotnet-tool: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Dotnet/** + +vcpkg: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.PackageEngine.Managers.Vcpkg/** + +translations: + - changed-files: + - all-globs-to-any-file: + - src/Languages/lang_*.json + - "!src/Languages/lang_en.json" + +appearance: + - changed-files: + - any-glob-to-any-file: src/UniGetUI.Avalonia/Assets/Styles/** diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000000..97e9456269 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,24 @@ +changelog: + exclude: + labels: + - dependencies + - github_actions + authors: + - dependabot + - dependabot[bot] + categories: + - title: New features + labels: + - new-feature + - title: Improvements + labels: + - enhancement + - title: Bug fixes + labels: + - bug + - title: Translations + labels: + - translations + - title: Other changes + labels: + - "*" diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 0000000000..62a5c1000b --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,62 @@ +name: Pull Request Labeler + +on: + pull_request_target: + types: [opened, reopened, edited, synchronize, ready_for_review] + +concurrency: + group: pr-labeler-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: write + issues: read + +jobs: + label: + runs-on: ubuntu-latest + + steps: + - name: Label by changed files + uses: actions/labeler@v7 + + - name: Copy the type label from linked issues + uses: actions/github-script@v9 + with: + script: | + const typeLabels = ['bug', 'new-feature', 'enhancement']; + const { owner, repo } = context.repo; + const number = context.payload.pull_request.number; + + const result = await github.graphql(` + query($owner: String!, $repo: String!, $number: Int!) { + repository(owner: $owner, name: $repo) { + pullRequest(number: $number) { + labels(first: 100) { nodes { name } } + closingIssuesReferences(first: 20) { + nodes { labels(first: 50) { nodes { name } } } + } + } + } + }`, { owner, repo, number }); + + const pr = result.repository.pullRequest; + if (pr.labels.nodes.some(l => typeLabels.includes(l.name))) { + core.info('The pull request already has a type label.'); + return; + } + + const found = new Set( + pr.closingIssuesReferences.nodes + .flatMap(issue => issue.labels.nodes.map(l => l.name)) + .filter(name => typeLabels.includes(name))); + + if (found.size !== 1) { + core.info(`Linked issues carry ${found.size} distinct type labels; adding none.`); + return; + } + + const [label] = found; + await github.rest.issues.addLabels({ owner, repo, issue_number: number, labels: [label] }); + core.info(`Added '${label}' from the linked issues.`);