Ver Fonte

Automate backports (#5686)

* Automate backports

* Update releasing doc

* updates
Trask Stalnaker há 3 anos atrás
pai
commit
ec97a438d5
2 ficheiros alterados com 44 adições e 1 exclusões
  1. 38 0
      .github/workflows/backport-pull-request.yml
  2. 6 1
      RELEASING.md

+ 38 - 0
.github/workflows/backport-pull-request.yml

@@ -0,0 +1,38 @@
+name: Backport a pull request
+on:
+  workflow_dispatch:
+    inputs:
+      pr:
+        description: "The pull request # to backport"
+        required: true
+
+jobs:
+  backport:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          # need full tree in order to do cherry-pick
+          fetch-depth: 0
+
+      - name: Setup git name
+        run: |
+          git config user.name opentelemetry-java-bot
+          git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
+
+      - name: Create pull request
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          PR: ${{ github.event.inputs.pr }}
+        run: |
+          commit=$(gh pr view $PR --json mergeCommit --jq .mergeCommit.oid)
+          title=$(gh pr view $PR --json title --jq .title)
+          url=$(gh pr view $PR --json url --jq .url)
+
+          git cherry-pick $commit
+          git push origin HEAD:backport-$PR-to-$GITHUB_REF_NAME
+
+          gh pr create --title "[$GITHUB_REF_NAME] $title" \
+                       --body "Clean cherry-pick of #$PR to the $GITHUB_REF_NAME branch." \
+                       --head backport-$PR-to-$GITHUB_REF_NAME \
+                       --base $GITHUB_REF_NAME

+ 6 - 1
RELEASING.md

@@ -40,7 +40,12 @@ In general, patch releases are only made for bug-fixes for the following types o
 
 Before making the release:
 
-* Merge PR(s) containing the desired patches to the release branch
+* Backport PR(s) to the release branch
+  * Run the [Backport workflow](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/prepare-patch-release.yml).
+  * Press the "Run workflow" button, then select the release branch from the dropdown list,
+    e.g. `v1.9.x`, then enter the PR number that you wan to backport,
+    then click the "Run workflow" button below that.
+  * Review and merge the backport PR that it generates
 * Merge a PR to the release branch updating the `CHANGELOG.md`
 * Run the [Prepare Patch Release workflow](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/prepare-patch-release.yml).
   * Press the "Run workflow" button, then select the release branch from the dropdown list,