Browse Source

Workflow updates and fixes (#5785)

* Port https://github.com/open-telemetry/opentelemetry-java/pull/4353

* Port https://github.com/open-telemetry/opentelemetry-java/pull/4359

* Port https://github.com/open-telemetry/opentelemetry-java/pull/4361

* Port https://github.com/open-telemetry/opentelemetry-java/pull/4362

* More syncing

* And sync markdown link check

Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
Trask Stalnaker 2 years ago
parent
commit
bfd456addc

+ 13 - 0
.github/scripts/markdown-link-check-with-retry.sh

@@ -0,0 +1,13 @@
+#!/bin/bash -e
+
+for file in "$@"; do
+  for i in 1 2 3; do
+    if markdown-link-check --config "$(dirname "$0")/markdown-link-check-config.json" \
+                           "$file"; then
+      break
+    elif [[ $i == 3 ]]; then
+      exit 1
+    fi
+    sleep 5
+  done
+done

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

@@ -13,7 +13,6 @@ 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

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

@@ -12,7 +12,7 @@ jobs:
     steps:
       - uses: actions/checkout@v3
         with:
-          # history is needed in order to do cherry-pick
+          # history is needed to run git cherry-pick below
           fetch-depth: 0
 
       - name: Set git user

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

@@ -76,7 +76,8 @@ jobs:
       - gradle-plugins
       - examples
     runs-on: ubuntu-latest
-    if: ${{ github.repository == 'open-telemetry/opentelemetry-java-instrumentation' }}
+    # skipping release branches because the versions in those branches are not snapshots
+    if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-instrumentation' }}
     steps:
       - uses: actions/checkout@v3
 

+ 34 - 0
.github/workflows/merge-change-log-to-main.yml

@@ -0,0 +1,34 @@
+name: Merge change log to main
+on:
+  workflow_dispatch:
+
+jobs:
+  create-pull-request:
+    runs-on: ubuntu-20.04
+    steps:
+      - uses: actions/checkout@v3
+        with:
+          # this workflow is run against the release branch (see usage of GITHUB_REF_NAME below)
+          # but it is creating a pull request against main
+          ref: main
+          # history is needed to run format-patch below
+          fetch-depth: 0
+
+      - 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 will fail if there have been conflicting change log updates introduced in main
+      - name: Create pull request against main
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          git format-patch --stdout HEAD..origin/$GITHUB_REF_NAME CHANGELOG.md | git apply
+          msg="Merge change log updates from $GITHUB_REF_NAME to main"
+          git commit -a -m "$msg"
+          git push origin HEAD:merge-change-log-updates-to-main
+          gh pr create --title "$msg" \
+                       --body "$msg" \
+                       --head merge-change-log-updates-to-main \
+                       --base main

+ 4 - 8
.github/workflows/prepare-release-branch.yml

@@ -19,20 +19,16 @@ jobs:
           echo "VERSION=$version" >> $GITHUB_ENV
           echo "RELEASE_BRANCH_NAME=$release_branch_name" >> $GITHUB_ENV
 
-      - name: Bump version
+      - name: Drop snapshot from version
         run: |
-          .github/scripts/update-versions.sh "$VERSION-SNAPSHOT" "$VERSION-alpha-SNAPSHOT" "$VERSION" "$VERSION-alpha"
-
-      - name: Bump download link version
-        run: |
-          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
+          sed -ri "s/val snapshot = true/val snapshot = false/" version.gradle.kts
 
       - 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
+      - name: Create pull request against the release branch
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
@@ -60,7 +56,7 @@ jobs:
             exit 1
           fi
           next_version="$major.$((minor + 1)).0"
-          .github/scripts/update-versions.sh "$version-SNAPSHOT" "$version-alpha-SNAPSHOT" "$next_version-SNAPSHOT" "$next_version-alpha-SNAPSHOT"
+          sed -ri "s/$version-SNAPSHOT/$next_version-SNAPSHOT/" version.gradle.kts
 
       - name: Set git user
         run: |

+ 38 - 43
.github/workflows/release.yml

@@ -100,18 +100,19 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
-          if [[ $version == *.0 ]]; then
-            cat > release-notes.txt << EOF
-            This release targets the OpenTelemetry SDK $VERSION.
+          # conditional blocks not indented because of the heredoc
+          if [[ $VERSION == *.0 ]]; then
+          cat > release-notes.txt << EOF
+          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.
+          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
+          EOF
           else
-            cat > release-notes.txt << EOF
-            This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
+          cat > release-notes.txt << EOF
+          This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
 
-            EOF
+          EOF
           fi
 
           sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \
@@ -123,15 +124,16 @@ jobs:
             | perl -0pe 's/\n +/ /g' \
             >> release-notes.txt
 
-          if [[ $version == *.0 ]]; then
-            cat >> release-notes.txt << EOF
+          # conditional block not indented because of the heredoc
+          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:
+          ### 🙇 Thank you
+          This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
 
-            EOF
+          EOF
 
-            .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION v$VERSION >> release-notes.txt
+          .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION $GITHUB_REF_NAME >> release-notes.txt
           fi
 
       - name: Create GitHub release
@@ -146,6 +148,28 @@ jobs:
                             v$VERSION \
                             opentelemetry-javaagent.jar
 
+      - name: Update the change log with the release date
+        run: |
+          date=$(gh release view v$VERSION --json publishedAt --jq .publishedAt | sed 's/T.*//')
+          sed -ri "s/## Version $VERSION .*/## Version $VERSION ($date)/" CHANGELOG.md
+
+      - 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 the release branch
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          msg="Add $VERSION release date to the change log"
+          git commit -a -m "$msg"
+          git push origin HEAD:add-$VERSION-release-date
+          gh pr create --title "[$GITHUB_REF_NAME] $msg" \
+                       --body "$msg" \
+                       --head add-$VERSION-release-date \
+                       --base $GITHUB_REF_NAME
+
       - uses: actions/checkout@v3
         with:
           repository: opentelemetry-java-bot/opentelemetry-operator
@@ -185,32 +209,3 @@ jobs:
                        --body "$msg" \
                        --repo open-telemetry/opentelemetry-operator
                        --base main
-
-      - uses: actions/checkout@v3
-        with:
-          ref: main
-          # history is needed in order to run git format-patch below
-          fetch-depth: 0
-
-      - 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 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 }}
-        run: |
-          git format-patch --stdout main..$GITHUB_REF_NAME CHANGELOG.md > patch
-          if [ -s patch ]; then
-            git apply patch
-            msg="Merge change log updates from $GITHUB_REF_NAME to main"
-            git commit -a -m "$msg"
-            git push origin HEAD:merge-change-log-updates-to-main
-            gh pr create --title "$msg" \
-                         --body "$msg" \
-                         --head merge-change-log-updates-to-main \
-                         --base main
-          fi

+ 1 - 2
.github/workflows/reusable-markdown-link-check.yml

@@ -14,9 +14,8 @@ jobs:
 
       - name: Run markdown-link-check
         run: |
-          # --quiet displays errors only, making them easier to find in the log
           find . -type f \
                  -name '*.md' \
                  -not -path './CHANGELOG.md' \
                  -not -path './licenses/*' \
-                 | xargs markdown-link-check --quiet --config .github/scripts/markdown-link-check-config.json
+               | xargs .github/scripts/markdown-link-check-with-retry.sh

+ 24 - 22
CHANGELOG.md

@@ -1,6 +1,8 @@
 # Changelog
 
-## Version 1.12.1 - 2022-03-17
+## Version 1.13.0 (unreleased)
+
+## Version 1.12.1 (2022-03-17)
 
 ### 🛠️ Bug fixes
 
@@ -9,7 +11,7 @@
 - Fix possible deadlock
   ([#5585](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/5585))
 
-## Version 1.12.0 - 2022-03-12
+## Version 1.12.0 (2022-03-12)
 
 ### 🌟 New javaagent instrumentation
 
@@ -83,14 +85,14 @@
 - Update to Groovy 4
   ([#5532](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/5532))
 
-## Version 1.11.1 - 2022-02-21
+## Version 1.11.1 (2022-02-21)
 
 ### 🛠️ Bug fixes
 
 - Regression in loading the prometheus exporter
   ([#5408](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/5408))
 
-## Version 1.11.0 - 2022-02-11
+## Version 1.11.0 (2022-02-11)
 
 ### Migration notes
 
@@ -213,7 +215,7 @@
 - Publish gradle-plugins to Maven Central
   ([#5333](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/5333))
 
-## Version 1.10.1 - 2022-01-27
+## Version 1.10.1 (2022-01-27)
 
 ### 🛠️ Bug fixes
 
@@ -226,7 +228,7 @@
 - Update to OTel SDK 1.10.1
   ([#5218](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/5218))
 
-## Version 1.10.0 - 2022-01-15
+## Version 1.10.0 (2022-01-15)
 
 ### Migration notes
 
@@ -357,21 +359,21 @@
 - Move SpanKey to internal package
   ([#4869](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4869))
 
-## Version 1.9.2 - 2022-01-07
+## Version 1.9.2 (2022-01-07)
 
 ### 🛠️ Bug fixes
 
 - Fix reactor-netty memory/connection leak
   ([#4867](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4867))
 
-## Version 1.9.1 - 2021-12-01
+## Version 1.9.1 (2021-12-01)
 
 ### 🛠️ Bug fixes
 
 - Shade class references within AWS SDK service files
   ([#4752](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4752))
 
-## Version 1.9.0 - 2021-11-25
+## Version 1.9.0 (2021-11-25)
 
 ### 📈 Enhancements
 
@@ -487,7 +489,7 @@
 
 Due to an issue in the publishing infrastructure, a bad release was published as 1.8.0. Do not use it.
 
-## Version 1.7.0 - 2021-10-19
+## Version 1.7.0 (2021-10-19)
 
 ### 📈 Enhancements
 
@@ -567,21 +569,21 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - rename `newBuilder()` to `builder()`
   ([#4407](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4407))
 
-## Version 1.6.2 - 2021-09-30
+## Version 1.6.2 (2021-09-30)
 
 ### 🛠️ Bug fixes
 
 - The 1.6.1 patch release was not backwards compatible with javaagent extensions built against 1.6.0
   ([#4245](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4245))
 
-## Version 1.6.1 - 2021-09-29
+## Version 1.6.1 (2021-09-29)
 
 ### 🛠️ Bug fixes
 
 - Fix possible JDBC instrumentation deadlock
   ([#4191](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4191))
 
-## Version 1.6.0 - 2021-09-18
+## Version 1.6.0 (2021-09-18)
 
 ### 🌟 New javaagent instrumentation
 
@@ -658,14 +660,14 @@ Due to an issue in the publishing infrastructure, a bad release was published as
   [#4084](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4084),
   [#4110](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4110))
 
-## Version 1.5.3 - 2021-08-31
+## Version 1.5.3 (2021-08-31)
 
 ### 🛠️ Bug fixes
 
 - Fix parsing of unclean map values in Config
   ([#4032](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/4032))
 
-## Version 1.5.2 - 2021-08-27
+## Version 1.5.2 (2021-08-27)
 
 ### 🛠️ Bug fixes
 
@@ -673,7 +675,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
   metrics exporter
   ([#3972](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3972))
 
-## Version 1.5.1 - 2021-08-25
+## Version 1.5.1 (2021-08-25)
 
 ### 🛠️ Bug fixes
 
@@ -684,7 +686,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - Fix maven central pom file for the opentelemetry-agent-for-testing artifact
   ([#3935](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3935))
 
-## Version 1.5.0 - 2021-08-22
+## Version 1.5.0 (2021-08-22)
 
 ### 🌟 New library instrumentation
 
@@ -789,7 +791,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - Rename Config get\*Property() methods to get\*()
   ([#3881](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3881))
 
-## Version 1.4.0 - 2021-07-20
+## Version 1.4.0 (2021-07-20)
 
 ### ☢️ Behavioral changes
 
@@ -846,7 +848,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - Rename `opentelemetry-javaagent-api` artifact to `opentelemetry-javaagent-instrumentation-api`
   ([#3513](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3513))
 
-## Version 1.3.1 - 2021-06-23
+## Version 1.3.1 (2021-06-23)
 
 ### 🛠️ Bug fixes
 
@@ -857,7 +859,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - Fix Spring JMS not being instrumented
   ([#3359](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3359))
 
-## Version 1.3.0 - 2021-06-17
+## Version 1.3.0 (2021-06-17)
 
 ### ☢️ Behavioral changes
 
@@ -959,7 +961,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
 - Move http client/server testing dependencies to internal package
   ([#3305](https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3305))
 
-## Version 1.2.0 - 2021-05-14
+## Version 1.2.0 (2021-05-14)
 
 ### ☢️ Behavioral changes
 
@@ -1056,7 +1058,7 @@ Due to an issue in the publishing infrastructure, a bad release was published as
   - `InstrumentationModule#getAllHelperClassNames()` has been removed; you can
     call `getMuzzleHelperClassNames()` to retrieve all helper class names instead.
 
-## Version 1.1.0 - 2021-04-14
+## Version 1.1.0 (2021-04-14)
 
 ### ☢️ Behavioral changes
 

+ 25 - 9
RELEASING.md

@@ -14,6 +14,8 @@ as the last step, which publishes a snapshot build to
 
 * Close the release milestone if there is one.
 * Merge a pull request to `main` updating the `CHANGELOG.md`.
+  * The heading for the release should include the release version but not the release date, e.g.
+  `## Version 1.9.0 (unreleased)`.
 * Run the [Prepare release branch workflow](.github/workflows/prepare-release-branch.yml).
 * Review and merge the two pull requests that it creates
   (one is targeted to the release branch and one is targeted to the `main` branch).
@@ -24,17 +26,19 @@ 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
+* Backport pull request(s) to the release branch.
   * Run the [Backport workflow](.github/workflows/backport.yml).
   * Press the "Run workflow" button, then select the release branch from the dropdown list,
     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`
+  * Review and merge the backport pull request that it generates.
+* Merge a pull request to the release branch updating the `CHANGELOG.md`.
+  * The heading for the release should include the release version but not the release date, e.g.
+  `## Version 1.9.0 (unreleased)`.
 * 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. `release/v1.9.x`, and click the "Run workflow" button below that.
-* Review and merge the pull request that it creates
+* Review and merge the pull request that it creates.
 
 ## Making the release
 
@@ -42,8 +46,20 @@ Run the [Release workflow](.github/workflows/release.yml).
 
 * Press the "Run workflow" button, then select the release branch from the dropdown list,
   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
-  the main branch, the workflow will create a pull request if the updates can be cleanly applied,
-  or it will fail this last step if the updates cannot be cleanly applied.
+* 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.
+* Review and merge the pull request that the release workflow creates against the release branch
+  which adds the release date to the change log.
+
+## After the release
+
+Run the [Merge change log to main workflow](.github/workflows/merge-change-log-to-main.yml).
+
+* Press the "Run workflow" button, then select the release branch from the dropdown list,
+  e.g. `release/v1.9.x`, and click the "Run workflow" button below that.
+* This will create a pull request that merges the change log updates from the release branch
+  back to main.
+* Review and merge the pull request that it creates.
+* This workflow will fail if there have been conflicting change log updates introduced in main,
+  in which case you will need to merge the change log updates manually and send your own pull
+  request against main.

+ 8 - 3
version.gradle.kts

@@ -1,7 +1,12 @@
+val snapshot = true
+
 allprojects {
+  var v = "1.13.0"
   if (findProperty("otel.stable") != "true") {
-    version = "1.13.0-alpha-SNAPSHOT"
-  } else {
-    version = "1.13.0-SNAPSHOT"
+    v += "-alpha"
   }
+  if (snapshot) {
+    v += "-SNAPSHOT"
+  }
+  version = v
 }