Просмотр исходного кода

Add workflow to prepare release branch (#5143)

* Add workflow to prepare release branch

* Avoid third party action

* Use PAT

* Delete the branches

* Revert "Use PAT"

This reverts commit 6f0c1b11b6c7cc577228ea23ae1c7ec03c34d589.
Trask Stalnaker 3 лет назад
Родитель
Сommit
b337f68640
3 измененных файлов с 121 добавлено и 16 удалено
  1. 25 0
      .github/scripts/update-versions.sh
  2. 92 0
      .github/workflows/prepare-release-branch.yml
  3. 4 16
      RELEASING.md

+ 25 - 0
.github/scripts/update-versions.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Bumps versions in these files
+# - version.gradle.kts
+# - examples/distro/build.gradle
+# - examples/extension/build.gradle
+
+current_version=$1
+current_alpha_version=$2
+new_version=$3
+new_alpha_version=$4
+
+echo "updating from $current_version to $new_version and from $current_alpha_version to $new_alpha_version"
+
+sed -ri "s/$current_version/$new_version/" version.gradle.kts
+sed -ri "s/$current_alpha_version/$new_alpha_version/" version.gradle.kts
+
+sed -ri "s/(opentelemetryJavaagent *: \")$current_version/\1$new_version/" examples/distro/build.gradle
+sed -ri "s/(opentelemetryJavaagentAlpha *: \")$current_alpha_version/\1$new_alpha_version/" examples/distro/build.gradle
+
+sed -ri "s/(opentelemetryJavaagent *: \")$current_version/\1$new_version/" examples/extension/build.gradle
+sed -ri "s/(opentelemetryJavaagentAlpha *: \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle
+
+sed -ri "s/(io.opentelemetry.instrumentation.muzzle-generation\" version \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle
+sed -ri "s/(io.opentelemetry.instrumentation.muzzle-check\" version \")$current_alpha_version/\1$new_alpha_version/" examples/extension/build.gradle

+ 92 - 0
.github/workflows/prepare-release-branch.yml

@@ -0,0 +1,92 @@
+name: Prepare Release Branch
+on:
+  workflow_dispatch:
+
+jobs:
+  prepare-release-branch:
+    runs-on: ubuntu-latest
+    outputs:
+      release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
+    steps:
+      - uses: actions/checkout@v2.3.4
+
+      - name: Set release branch name
+        id: set-release-branch-name
+        run: |
+          release_branch_name=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts | sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT/v\1.\2.x/')
+          echo "::set-output name=release-branch-name::$release_branch_name"
+
+      - name: Create release branch
+        run: |
+          git checkout -b ${{ steps.set-release-branch-name.outputs.release-branch-name }}
+          git push origin ${{ steps.set-release-branch-name.outputs.release-branch-name }}
+
+  create-pull-request-against-release-branch:
+    needs: prepare-release-branch
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2.3.4
+        with:
+          ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
+
+      - name: Remove SNAPSHOT from version
+        run: |
+          v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
+          .github/scripts/update-versions.sh "$v-SNAPSHOT" "$v-alpha-SNAPSHOT" "$v" "$v-alpha"
+
+      - name: Bump download link version
+        run: |
+          new_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
+          sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v[0-9]+.[0-9]+.[0-9]+/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$new_version/," README.md
+
+      - name: Setup git name
+        run: |
+          git config user.name github-actions
+          git config user.email github-actions@github.com
+
+      - name: Create pull request
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          msg="Prepare release branch ${{ needs.prepare-release-branch.outputs.release-branch-name }}"
+          git add -u
+          git commit -m "$msg"
+          git push origin HEAD:prepare-release-branch-${{ needs.prepare-release-branch.outputs.release-branch-name }}
+          gh pr create --title "$msg" \
+                       --body "$msg" \
+                       --head prepare-release-branch-${{ needs.prepare-release-branch.outputs.release-branch-name }} \
+                       --base ${{ needs.prepare-release-branch.outputs.release-branch-name }}
+
+  create-pull-request-against-main:
+    needs: prepare-release-branch
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2.3.4
+
+      - name: Bump SNAPSHOT version
+        run: |
+          v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
+          if [[ $v =~ ([0-9]+).([0-9]+).0 ]]; then
+            major="${BASH_REMATCH[1]}"
+            minor="${BASH_REMATCH[2]}"
+          else
+            echo "unexpected version: $v"
+            exit 1
+          fi
+          bump="$major.$((minor + 1)).0"
+          .github/scripts/update-versions.sh "$v-SNAPSHOT" "$v-alpha-SNAPSHOT" "$bump-SNAPSHOT" "$bump-alpha-SNAPSHOT"
+
+      - name: Setup git name
+        run: |
+          git config user.name github-actions
+          git config user.email github-actions@github.com
+
+      - name: Create pull request
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          msg="Bump snapshot version"
+          git add -u
+          git commit -m "$msg"
+          git push origin HEAD:bump-snapshot-version
+          gh pr create --title "$msg" --body "$msg" --head bump-snapshot-version --base main

+ 4 - 16
RELEASING.md

@@ -14,17 +14,9 @@ as the last step, which publishes a snapshot build to
 Before making the release:
 
 * Merge a PR to `main` updating the `CHANGELOG.md`
-* Create a release branch, e.g. `v1.9.x`
-  ```
-  git checkout -b v1.9.x upstream/main
-  git push upstream v1.9.x
-  ```
-* Merge a PR to the release branch with the following changes
-  * Remove `-SNAPSHOT` from the version in these files:
-    * version.gradle.kts
-    * examples/distro/build.gradle
-    * examples/extension/build.gradle
-  * Bump the version in the download link in the root `README.md` file
+* Run the [Prepare Release Branch workflow](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/prepare-release-branch.yml).
+* Review and merge the two PRs that it creates (one is targeted to the release branch and one is targeted to the `main` branch)
+* Delete the branches from these two PRs since they are created in the main repo
 
 Open the [Release workflow](https://github.com/open-telemetry/opentelemetry-java-instrumentation/actions/workflows/release.yml).
 
@@ -36,11 +28,7 @@ and pushes a git tag with the version number.
 
 After making the release:
 
-* Merge a PR to `main` with the following changes
-  * Bump version in these files to the next `-SNAPSHOT` version (e.g. from `1.9.0-SNAPSHOT` to `1.10.0-SNAPSHOT`)
-    * version.gradle.kts
-    * examples/distro/build.gradle
-    * examples/extension/build.gradle
+* Merge a PR to `main` with the following change
   * Bump the version in the download link in the root `README.md` file
 
 ## Announcement