patch-release-build.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. # Releases a patch by cherrypicking commits into a release branch based on the previous
  2. # release tag.
  3. name: Patch Release Build
  4. on:
  5. workflow_dispatch:
  6. inputs:
  7. version:
  8. description: The version to tag the release with, e.g., 1.2.1, 1.2.2
  9. required: true
  10. commits:
  11. description: Comma separated list of commit shas to cherrypick
  12. required: false
  13. jobs:
  14. prepare-release-branch:
  15. runs-on: ubuntu-latest
  16. outputs:
  17. release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }}
  18. steps:
  19. - id: parse-release-branch
  20. name: Parse release branch name
  21. run: |
  22. # Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v.
  23. echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')"
  24. # Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v
  25. echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')"
  26. - id: checkout-release-branch
  27. name: Check out release branch
  28. continue-on-error: true
  29. uses: actions/checkout@v2.3.4
  30. with:
  31. ref: ${{ steps.parse-release-branch.outputs.release-branch-name }}
  32. fetch-depth: 0
  33. - id: checkout-release-tag
  34. name: Check out release tag
  35. if: ${{ steps.checkout-release-branch.outcome == 'failure' }}
  36. uses: actions/checkout@v2.3.4
  37. with:
  38. ref: ${{ steps.parse-release-branch.outputs.release-tag-name }}
  39. fetch-depth: 0
  40. - name: Create release branch
  41. if: ${{ steps.checkout-release-tag.outcome == 'success' }}
  42. run: |
  43. git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }}
  44. git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }}
  45. test:
  46. runs-on: ubuntu-latest
  47. needs: prepare-release-branch
  48. strategy:
  49. matrix:
  50. java: [ 8, 11, 15 ]
  51. steps:
  52. - uses: actions/checkout@v2.3.4
  53. with:
  54. ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
  55. fetch-depth: 0
  56. - id: setup-test-java
  57. name: Set up JDK ${{ matrix.java }} for running tests
  58. uses: actions/setup-java@v2
  59. with:
  60. distribution: adopt
  61. java-version: ${{ matrix.java }}
  62. - name: Set up JDK 11 for running Gradle
  63. uses: actions/setup-java@v2
  64. with:
  65. distribution: adopt
  66. java-version: 11
  67. - name: Restore cache
  68. uses: burrunan/gradle-cache-action@v1.10
  69. with:
  70. job-id: jdk${{ matrix.java }}
  71. - name: Test
  72. run: ./gradlew test -PtestJavaVersion=${{ matrix.java }} --stacktrace -x :smoke-tests:test -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
  73. testLatestDeps:
  74. runs-on: ubuntu-latest
  75. needs: prepare-release-branch
  76. steps:
  77. - uses: actions/checkout@v2.3.4
  78. with:
  79. ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
  80. fetch-depth: 0
  81. - name: Set up JDK 11
  82. uses: actions/setup-java@v2
  83. with:
  84. distribution: adopt
  85. java-version: 11
  86. - name: Restore cache
  87. uses: burrunan/gradle-cache-action@v1.10
  88. with:
  89. job-id: latestDepTest
  90. - name: Test
  91. run: ./gradlew test -x :smoke-tests:test -PtestLatestDeps=true --stacktrace
  92. smoke-test:
  93. runs-on: ${{ matrix.os }}
  94. needs: prepare-release-branch
  95. strategy:
  96. matrix:
  97. os: [ windows-latest, ubuntu-latest ]
  98. suite: [ "glassfish", "jetty", "liberty", "tomcat", "tomee", "wildfly", "other" ]
  99. steps:
  100. - name: Support longpaths
  101. run: git config --system core.longpaths true
  102. if: matrix.os == 'windows-latest'
  103. - uses: actions/checkout@v2.3.4
  104. with:
  105. ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
  106. fetch-depth: 0
  107. - name: Set up JDK 11 for running Gradle
  108. uses: actions/setup-java@v2
  109. with:
  110. distribution: adopt
  111. java-version: 11
  112. - name: Restore cache
  113. uses: burrunan/gradle-cache-action@v1.10
  114. with:
  115. job-id: smokeTests
  116. - name: Test
  117. run: ./gradlew :smoke-tests:test -PsmokeTestSuite=${{ matrix.suite }}
  118. example-distro:
  119. runs-on: ubuntu-latest
  120. needs: prepare-release-branch
  121. steps:
  122. - uses: actions/checkout@v2.3.4
  123. with:
  124. ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
  125. fetch-depth: 0
  126. - name: Set up JDK 11 for running checks
  127. uses: actions/setup-java@v2
  128. with:
  129. distribution: adopt
  130. java-version: 11
  131. - name: Restore cache
  132. uses: burrunan/gradle-cache-action@v1.10
  133. with:
  134. job-id: jdk11
  135. - name: Build
  136. run: ./gradlew build --stacktrace
  137. working-directory: examples/distro
  138. release:
  139. runs-on: ubuntu-latest
  140. needs: prepare-release-branch
  141. steps:
  142. - uses: actions/checkout@v2.3.4
  143. with:
  144. ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }}
  145. fetch-depth: 0
  146. - uses: actions/setup-java@v2
  147. with:
  148. distribution: adopt
  149. java-version: 11
  150. - name: Setup git name
  151. run: |
  152. git config user.name github-actions
  153. git config user.email github-actions@github.com
  154. - name: Cherrypicks
  155. if: ${{ github.event.inputs.commits != '' }}
  156. run: |
  157. git fetch origin main
  158. echo ${{ github.event.inputs.commits }} | sed -n 1'p' | tr ',' '\n' | while read word; do
  159. # Trim whitespaces and cherrypick
  160. echo $word | sed 's/ *$//g' | sed 's/^ *//g' | git cherry-pick --stdin
  161. done
  162. - name: Build and publish artifacts
  163. uses: burrunan/gradle-cache-action@v1.10
  164. with:
  165. job-id: jdk11
  166. remote-build-cache-proxy-enabled: false
  167. arguments: build final closeAndReleaseRepository --stacktrace -x :smoke-tests:test -Prelease.version=${{ github.event.inputs.version }}
  168. env:
  169. SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
  170. SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
  171. GRGIT_USER: ${{ github.actor }}
  172. GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
  173. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  174. GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
  175. - name: Create Release
  176. id: create_release
  177. uses: actions/create-release@v1.1.4
  178. env:
  179. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  180. with:
  181. tag_name: v${{ github.event.inputs.version }}
  182. release_name: Release v${{ github.event.inputs.version }}
  183. draft: true
  184. prerelease: false
  185. - name: Upload Release Asset
  186. id: upload-release-asset
  187. uses: actions/upload-release-asset@v1.0.2
  188. env:
  189. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  190. with:
  191. upload_url: ${{ steps.create_release.outputs.upload_url }}
  192. asset_path: javaagent/build/libs/opentelemetry-javaagent-${{ github.event.inputs.version }}-all.jar
  193. asset_name: opentelemetry-javaagent-all.jar
  194. asset_content_type: application/java-archive