diff --git a/.backportrc.json b/.backportrc.json new file mode 100644 index 00000000..72c9b85b --- /dev/null +++ b/.backportrc.json @@ -0,0 +1,16 @@ +// .backportrc.json -- for https://github.com/sorenlouv/backport +{ + // Required + "repoOwner": "mpmath", + "repoName": "mpmath", + // the branches available to backport to + "targetBranchChoices": ["mpmath-1.4.x"], + // Automatically detect which branches a pull request should be + // backported to based on the pull request labels. + "branchLabelMapping": { + "^backport-to-(.+)$": "mpmath-$1" + }, + "targetPRLabels": ["backport"], + "sourcePRLabels": ["backport-pr-created"], + "commitConflicts": true +} diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml new file mode 100644 index 00000000..56d58396 --- /dev/null +++ b/.github/workflows/backport.yml @@ -0,0 +1,37 @@ +name: Automatic backport action + +on: + pull_request_target: + types: ["labeled", "closed"] + +permissions: + contents: write # so it can comment + pull-requests: write # so it can create pull requests + +jobs: + backport: + name: Backport PR + if: github.event.pull_request.merged == true && !(contains(github.event.pull_request.labels.*.name, 'backport')) && !(contains(github.event.pull_request.labels.*.name, 'backport-pr-created')) + runs-on: ubuntu-24.04 + steps: + # Workaround not to fail the workflow if the PR does not need a backport + # https://github.com/sorenlouv/backport-github-action/issues/127#issuecomment-2277248320 + - name: Check for backport labels + id: check_labels + run: |- + labels='${{ toJSON(github.event.pull_request.labels.*.name) }}' + matched=$(echo "${labels}" | jq '. | map(select(startswith("backport-to-"))) | length') + echo "matched=$matched" + echo "matched=$matched" >> $GITHUB_OUTPUT + - name: Backport Action + if: fromJSON(steps.check_labels.outputs.matched) > 0 + uses: sorenlouv/backport-github-action@v10.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + auto_backport_label_prefix: backport-to- + - name: Info log + if: ${{ success() && fromJSON(steps.check_labels.outputs.matched) > 0 }} + run: cat ~/.backport/backport.info.log + - name: Debug log + if: ${{ failure() && fromJSON(steps.check_labels.outputs.matched) > 0 }} + run: cat ~/.backport/backport.debug.log diff --git a/CHANGES b/CHANGES index 6a5f5274..de514ace 100644 --- a/CHANGES +++ b/CHANGES @@ -201,6 +201,7 @@ Maintenance: * Build and publish wheel, see #913 (David Hotham) * Use the intended setuptools_scm integration pattern, see #940 (Ronny Pfannschmidt) +* Add backport action, see #1042 (Sergey B Kirpichev) See the release milestone (1.4) for a complete list of issues and pull requests involved in this release.