Browse Source

Workflow cleanup/sync (#5736)

* Workflow cleanup/sync

* more

* more

* more

* fix

* consistency

* Use simpler sharing of env vars across steps

* Simplify, merge related jobs

* Simplify

* More improvements

* Use release/* release branch naming
Trask Stalnaker 2 years ago
parent
commit
d908821072

+ 2 - 2
.github/scripts/generate-release-contributors.sh

@@ -12,7 +12,7 @@ from=$(git log --reverse --pretty=format:"%cI" $from_version..HEAD | head -1)
 # get the last commit on main that was in the to_version
 to=$(git merge-base HEAD $to_version | xargs git log -1 --pretty=format:"%cI")
 
-contributors1=$(gh api graphql --paginate -F q="repo:open-telemetry/opentelemetry-java-instrumentation is:pr base:main is:merged merged:$from..$to" -f query='
+contributors1=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
 query($q: String!, $endCursor: String) {
   search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
     edges {
@@ -49,7 +49,7 @@ query($q: String!, $endCursor: String) {
 
 # this query captures authors of issues which have had PRs in the current range reference the issue
 # but not necessarily through closingIssuesReferences (e.g. addressing just a part of an issue)
-contributors2=$(gh api graphql --paginate -F q="repo:open-telemetry/opentelemetry-java-instrumentation is:pr base:main is:merged merged:$from..$to" -f query='
+contributors2=$(gh api graphql --paginate -F q="repo:$GITHUB_REPOSITORY is:pr base:main is:merged merged:$from..$to" -f query='
 query($q: String!, $endCursor: String) {
   search(query: $q, type: ISSUE, first: 100, after: $endCursor) {
     edges {

+ 2 - 2
.github/workflows/backport-pull-request.yml → .github/workflows/backport.yml

@@ -1,4 +1,4 @@
-name: Backport a pull request
+name: Backport
 on:
   workflow_dispatch:
     inputs:
@@ -15,7 +15,7 @@ jobs:
           # history is needed in order to do cherry-pick
           fetch-depth: 0
 
-      - name: Set up git name
+      - name: Set git user
         run: |
           git config user.name opentelemetry-java-bot
           git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com

+ 1 - 1
.github/workflows/build.yml

@@ -4,7 +4,7 @@ on:
   push:
     branches:
       - main
-      - v[0-9]+.[0-9]+.x
+      - release/*
   workflow_dispatch:
 
 jobs:

+ 8 - 16
.github/workflows/prepare-patch-release.yml

@@ -8,8 +8,7 @@ jobs:
     steps:
       - uses: actions/checkout@v3
 
-      - name: Set versions
-        id: set-versions
+      - name: Set environment variables
         run: |
           prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
           if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then
@@ -19,37 +18,30 @@ jobs:
             echo "unexpected version: $prior_version"
             exit 1
           fi
-          echo "::set-output name=release-version::$major_minor.$((patch + 1))"
-          echo "::set-output name=prior-release-version::$prior_version"
+          echo "VERSION=$major_minor.$((patch + 1))" >> $GITHUB_ENV
+          echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
 
       - name: Bump version
-        env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
-          PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
         run: |
           .github/scripts/update-versions.sh "$PRIOR_VERSION" "$PRIOR_VERSION-alpha" "$VERSION" "$VERSION-alpha"
 
       - name: Bump download link version
-        env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
-          PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
         run: |
           sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$PRIOR_VERSION/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$VERSION/," README.md
 
-      - name: Set up git name
+      - name: Set git user
         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:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          msg="Prepare patch release $VERSION"
+          msg="Prepare release $VERSION"
           git commit -a -m "$msg"
-          git push origin HEAD:prepare-patch-release-$VERSION
-          gh pr create --title "$msg" \
+          git push origin HEAD:prepare-release-$VERSION
+          gh pr create --title "[$GITHUB_REF_NAME] $msg" \
                        --body "$msg" \
-                       --head prepare-patch-release-$VERSION \
+                       --head prepare-release-$VERSION \
                        --base $GITHUB_REF_NAME

+ 17 - 36
.github/workflows/prepare-release-branch.yml

@@ -3,67 +3,48 @@ on:
   workflow_dispatch:
 
 jobs:
-  prepare-release-branch:
+  create-pull-request-against-release-branch:
     runs-on: ubuntu-latest
-    outputs:
-      release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
     steps:
       - uses: actions/checkout@v3
 
-      - name: Set release branch name
-        id: set-release-branch-name
-        run: |
-          version=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts)
-          release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/')
-          echo "::set-output name=release-branch-name::$release_branch_name"
-
       - name: Create release branch
-        env:
-          RELEASE_BRANCH_NAME: ${{ steps.set-release-branch-name.outputs.release-branch-name }}
+        id: create-release-branch
         run: |
-          git checkout -b $RELEASE_BRANCH_NAME
-          git push origin $RELEASE_BRANCH_NAME
+          version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
+          release_branch_name=$(echo $version | sed -E 's,([0-9]+)\.([0-9]+)\.0,release/v\1.\2.x,')
 
-  create-pull-request-against-release-branch:
-    needs: prepare-release-branch
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout@v3
-        with:
-          ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
+          git push origin HEAD:$release_branch_name
 
-      - name: Bump version on release branch
+          echo "VERSION=$version" >> $GITHUB_ENV
+          echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
+
+      - name: Bump version
         run: |
-          version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//')
-          .github/scripts/update-versions.sh "$version-SNAPSHOT" "$version-alpha-SNAPSHOT" "$version" "$version-alpha"
+          .github/scripts/update-versions.sh "$VERSION-SNAPSHOT" "$VERSION-alpha-SNAPSHOT" "$VERSION" "$VERSION-alpha"
 
       - name: Bump download link version
         run: |
-          new_version=$(grep -Eo "[0-9]+.[0-9]+.0" version.gradle.kts | head -1)
-          sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$new_version/," README.md
+          sed -Ei "s,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/,https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v$VERSION/," README.md
 
-      - name: Set up git name
+      - name: Set git user
         run: |
           git config user.name opentelemetry-java-bot
           git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
 
       - name: Create pull request against release branch
         env:
-          RELEASE_BRANCH_NAME: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          msg="Prepare release branch $RELEASE_BRANCH_NAME"
+          msg="Prepare release $VERSION"
           git commit -a -m "$msg"
-          git push origin HEAD:prepare-release-branch-$RELEASE_BRANCH_NAME
-          gh pr create --title "$msg" \
+          git push origin HEAD:prepare-release-$VERSION
+          gh pr create --title "[$RELEASE_BRANCH_NAME] $msg" \
                        --body "$msg" \
-                       --head prepare-release-branch-$RELEASE_BRANCH_NAME \
+                       --head prepare-release-$VERSION \
                        --base $RELEASE_BRANCH_NAME
 
   create-pull-request-against-main:
-    needs:
-      - prepare-release-branch
-      - create-pull-request-against-release-branch
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
@@ -81,7 +62,7 @@ jobs:
           next_version="$major.$((minor + 1)).0"
           .github/scripts/update-versions.sh "$version-SNAPSHOT" "$version-alpha-SNAPSHOT" "$next_version-SNAPSHOT" "$next_version-alpha-SNAPSHOT"
 
-      - name: Set up git name
+      - name: Set git user
         run: |
           git config user.name opentelemetry-java-bot
           git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com

+ 17 - 24
.github/workflows/release.yml

@@ -71,8 +71,7 @@ jobs:
           arguments: build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
           build-root-directory: gradle-plugins
 
-      - name: Set versions
-        id: set-versions
+      - name: Set environment variables
         run: |
           version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
           if [[ $version =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
@@ -94,13 +93,11 @@ jobs:
           else
               prior_version="$major.$minor.$((patch - 1))"
           fi
-          echo "::set-output name=release-version::$version"
-          echo "::set-output name=prior-release-version::$prior_version"
+          echo "VERSION=$version" >> $GITHUB_ENV
+          echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
 
       - name: Generate release notes
         env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
-          PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
           if [[ $version == *.0 ]]; then
@@ -108,38 +105,37 @@ jobs:
             This release targets the OpenTelemetry SDK $VERSION.
 
             Note that all artifacts other than \`io.opentelemetry.javaagent:opentelemetry-javaagent\` have the \`-alpha\` suffix attached to their version number, reflecting that they are still alpha quality and will continue to have breaking changes. Please see the [VERSIONING.md](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/VERSIONING.md#opentelemetry-java-instrumentation-versioning) for more details.
-          
+
             EOF
           else
             cat > release-notes.txt << EOF
             This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
-          
+
             EOF
           fi
 
-          sed -n '/^## Version $VERSION/,/^## Version /p' CHANGELOG.md \
+          sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \
             | tail -n +2 \
             | head -n -1 \
             | perl -0pe 's/^\n+//g' \
             | perl -0pe 's/\n+$/\n/g' \
-            | sed -r 's,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1,' \
+            | sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \
             | perl -0pe 's/\n +/ /g' \
             >> release-notes.txt
 
           if [[ $version == *.0 ]]; then
             cat >> release-notes.txt << EOF
-          
+
             ### 🙇 Thank you
             This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
-          
+
             EOF
-          
+
             .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION v$VERSION >> release-notes.txt
           fi
 
       - name: Create GitHub release
         env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
           cp javaagent/build/libs/opentelemetry-javaagent-$VERSION.jar opentelemetry-javaagent.jar
@@ -157,27 +153,22 @@ jobs:
           token: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}
 
       - name: Initialize pull request branch
-        env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
         run: |
           git remote add upstream https://github.com/open-telemetry/opentelemetry-operator.git
           git fetch upstream
           git checkout -b update-opentelemetry-javaagent-to-$VERSION upstream/main
 
       - name: Bump version
-        env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
         run: |
           echo $VERSION > autoinstrumentation/java/version.txt
 
-      - name: Set up git name
+      - name: Set git user
         run: |
           git config user.name opentelemetry-java-bot
           git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
 
       - name: Create pull request against opentelemetry-operator
         env:
-          VERSION: ${{ steps.set-versions.outputs.release-version }}
           # this is the PAT used for "gh pr create" below
           GITHUB_TOKEN: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}
         run: |
@@ -193,6 +184,7 @@ jobs:
           gh pr create --title "$msg" \
                        --body "$msg" \
                        --repo open-telemetry/opentelemetry-operator
+                       --base main
 
       - uses: actions/checkout@v3
         with:
@@ -200,12 +192,13 @@ jobs:
           # history is needed in order to run git format-patch below
           fetch-depth: 0
 
-      - name: Set up git name
+      - name: Set git user
         run: |
           git config user.name opentelemetry-java-bot
           git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
 
-        # this step should be last since it will fail if conflicting change log updates on main
+        # this step should be last since it will fail if there have been conflicting
+        # change log updates introduced on the main branch
       - name: Create pull request to merge any change log updates to main
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -215,9 +208,9 @@ jobs:
             git apply patch
             msg="Merge change log updates from $GITHUB_REF_NAME to main"
             git commit -a -m "$msg"
-            git push origin HEAD:opentelemetry-java-bot/merge-change-log-updates
+            git push origin HEAD:merge-change-log-updates-to-main
             gh pr create --title "$msg" \
                          --body "$msg" \
-                         --head opentelemetry-java-bot/merge-change-log-updates \
+                         --head merge-change-log-updates-to-main \
                          --base main
           fi

+ 4 - 4
RELEASING.md

@@ -25,15 +25,15 @@ All patch releases should include only bug-fixes, and must avoid adding/modifyin
 In general, patch releases are only made for regressions, memory leaks and deadlocks.
 
 * Backport pull request(s) to the release branch
-  * Run the [Backport pull request workflow](.github/workflows/backport-pull-request.yml).
+  * Run the [Backport workflow](.github/workflows/backport.yml).
   * Press the "Run workflow" button, then select the release branch from the dropdown list,
-    e.g. `v1.9.x`, then enter the pull request number that you want to backport,
+    e.g. `release/v1.9.x`, then enter the pull request number that you want to backport,
     then click the "Run workflow" button below that.
   * Review and merge the backport pull request that it generates
 * Merge a pull request to the release branch updating the `CHANGELOG.md`
 * Run the [Prepare patch release workflow](.github/workflows/prepare-patch-release.yml).
   * Press the "Run workflow" button, then select the release branch from the dropdown list,
-    e.g. `v1.9.x`, and click the "Run workflow" button below that.
+    e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
 * Review and merge the pull request that it creates
 
 ## Making the release
@@ -41,7 +41,7 @@ In general, patch releases are only made for regressions, memory leaks and deadl
 Run the [Release workflow](.github/workflows/release.yml).
 
 * Press the "Run workflow" button, then select the release branch from the dropdown list,
-  e.g. `v1.9.x`, and click the "Run workflow" button below that.
+  e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
 * This workflow will publish the artifacts to maven central and will publish a GitHub release with
   release notes based on the change log and with the javaagent jar attached.
 * Lastly, if there were any change log updates in the release branch that need to be merged back to