release.yml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. name: Release
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. assemble:
  6. uses: ./.github/workflows/reusable-assemble.yml
  7. test:
  8. uses: ./.github/workflows/reusable-test.yml
  9. # test-latest-deps is intentionally not included in the release workflows
  10. # because any time a new library version is released to maven central
  11. # it can fail due to test code incompatibility with the new library version,
  12. # or due to slight changes in emitted telemetry
  13. smoke-test:
  14. uses: ./.github/workflows/reusable-smoke-test.yml
  15. # muzzle is intentionally not included in the release workflows
  16. # because any time a new library version is released to maven central it can fail,
  17. # and this is not a reason to hold up the release
  18. gradle-plugins:
  19. uses: ./.github/workflows/reusable-gradle-plugins.yml
  20. examples:
  21. uses: ./.github/workflows/reusable-examples.yml
  22. release:
  23. needs:
  24. - assemble
  25. - test
  26. - smoke-test
  27. - gradle-plugins
  28. - examples
  29. runs-on: ubuntu-latest
  30. steps:
  31. - uses: actions/checkout@v3
  32. with:
  33. # tags are needed for the generate-release-contributors.sh script
  34. fetch-depth: 0
  35. - name: Set up JDK for running Gradle
  36. uses: actions/setup-java@v2
  37. with:
  38. distribution: temurin
  39. java-version: 17
  40. - name: Build and publish artifacts
  41. uses: gradle/gradle-build-action@v2
  42. with:
  43. arguments: assemble publishToSonatype closeAndReleaseSonatypeStagingRepository
  44. env:
  45. SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
  46. SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
  47. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  48. GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
  49. - name: Build and publish gradle plugins
  50. uses: gradle/gradle-build-action@v2
  51. env:
  52. SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
  53. SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
  54. GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
  55. GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
  56. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  57. GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
  58. with:
  59. # Don't use publishToSonatype since we don't want to publish the marker artifact
  60. arguments: build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
  61. build-root-directory: gradle-plugins
  62. - name: Set environment variables
  63. run: |
  64. version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
  65. if [[ $version =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
  66. major="${BASH_REMATCH[1]}"
  67. minor="${BASH_REMATCH[2]}"
  68. patch="${BASH_REMATCH[3]}"
  69. else
  70. echo "unexpected version: $version"
  71. exit 1
  72. fi
  73. if [[ $patch == 0 ]]; then
  74. if [[ $minor == 0 ]]; then
  75. prior_major=$((major - 1))
  76. prior_minor=$(grep -Po "^## Version $prior_major.\K([0-9]+)" CHANGELOG.md | head -1)
  77. prior_version="$prior_major.$prior_minor"
  78. else
  79. prior_version="$major.$((minor - 1)).0"
  80. fi
  81. else
  82. prior_version="$major.$minor.$((patch - 1))"
  83. fi
  84. echo "VERSION=$version" >> $GITHUB_ENV
  85. echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV
  86. - name: Generate release notes
  87. env:
  88. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  89. run: |
  90. # conditional blocks not indented because of the heredoc
  91. if [[ $VERSION == *.0 ]]; then
  92. cat > release-notes.txt << EOF
  93. This release targets the OpenTelemetry SDK $VERSION.
  94. 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.
  95. EOF
  96. else
  97. cat > release-notes.txt << EOF
  98. This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below.
  99. EOF
  100. fi
  101. sed -n "/^## Version $VERSION/,/^## Version /p" CHANGELOG.md \
  102. | tail -n +2 \
  103. | head -n -1 \
  104. | perl -0pe 's/^\n+//g' \
  105. | perl -0pe 's/\n+$/\n/g' \
  106. | sed -r "s,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1," \
  107. | perl -0pe 's/\n +/ /g' \
  108. >> release-notes.txt
  109. # conditional block not indented because of the heredoc
  110. if [[ $VERSION == *.0 ]]; then
  111. cat >> release-notes.txt << EOF
  112. ### 🙇 Thank you
  113. This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
  114. EOF
  115. .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION $GITHUB_REF_NAME >> release-notes.txt
  116. fi
  117. - name: Create GitHub release
  118. env:
  119. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  120. run: |
  121. cp javaagent/build/libs/opentelemetry-javaagent-$VERSION.jar opentelemetry-javaagent.jar
  122. gh release create --target $GITHUB_REF_NAME \
  123. --title "Version $VERSION" \
  124. --notes-file release-notes.txt \
  125. --discussion-category announcements \
  126. v$VERSION \
  127. opentelemetry-javaagent.jar
  128. - name: Update the change log with the release date
  129. run: |
  130. date=$(gh release view v$VERSION --json publishedAt --jq .publishedAt | sed 's/T.*//')
  131. sed -ri "s/## Version $VERSION .*/## Version $VERSION ($date)/" CHANGELOG.md
  132. - name: Set git user
  133. run: |
  134. git config user.name opentelemetry-java-bot
  135. git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
  136. - name: Create pull request against the release branch
  137. env:
  138. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  139. run: |
  140. msg="Add $VERSION release date to the change log"
  141. git commit -a -m "$msg"
  142. git push origin HEAD:add-$VERSION-release-date
  143. gh pr create --title "[$GITHUB_REF_NAME] $msg" \
  144. --body "$msg" \
  145. --head add-$VERSION-release-date \
  146. --base $GITHUB_REF_NAME
  147. - uses: actions/checkout@v3
  148. with:
  149. repository: opentelemetry-java-bot/opentelemetry-operator
  150. # this is the PAT used for "git push" below
  151. token: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}
  152. - name: Initialize pull request branch
  153. run: |
  154. git remote add upstream https://github.com/open-telemetry/opentelemetry-operator.git
  155. git fetch upstream
  156. git checkout -b update-opentelemetry-javaagent-to-$VERSION upstream/main
  157. - name: Bump version
  158. run: |
  159. echo $VERSION > autoinstrumentation/java/version.txt
  160. - name: Set git user
  161. run: |
  162. git config user.name opentelemetry-java-bot
  163. git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
  164. - name: Create pull request against opentelemetry-operator
  165. env:
  166. # this is the PAT used for "gh pr create" below
  167. GITHUB_TOKEN: ${{ secrets.OPENTELEMETRY_JAVA_BOT_TOKEN }}
  168. run: |
  169. msg="Update opentelemetry-javaagent version to $VERSION"
  170. git commit -a -m "$msg"
  171. # gh pr create doesn't have a way to explicitly specify different head and base
  172. # repositories currently, but it will implicitly pick up the head from a different
  173. # repository if you set up a tracking branch
  174. git push --set-upstream origin update-opentelemetry-javaagent-to-$VERSION
  175. gh pr create --title "$msg" \
  176. --body "$msg" \
  177. --repo open-telemetry/opentelemetry-operator
  178. --base main