release.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # Releases a new major / minor / patch version from a release branch
  2. name: Release Build
  3. on:
  4. workflow_dispatch:
  5. jobs:
  6. test:
  7. uses: ./.github/workflows/reusable-test.yml
  8. # testLatestDeps is intentionally not included in the release workflows
  9. # because any time a new library version is released to maven central
  10. # it can fail due to test code incompatibility with the new library version,
  11. # or due to slight changes in emitted telemetry
  12. smoke-test:
  13. uses: ./.github/workflows/reusable-smoke-test.yml
  14. # muzzle is intentionally not included in the release workflows
  15. # because any time a new library version is released to maven central it can fail,
  16. # and this is not a reason to hold up the release
  17. examples:
  18. uses: ./.github/workflows/reusable-examples.yml
  19. release:
  20. needs: [ test, smoke-test, examples ]
  21. runs-on: ubuntu-latest
  22. steps:
  23. - uses: actions/checkout@v3
  24. with:
  25. ref: ${{ github.ref_name }}
  26. # tags are needed for the generate-release-contributors.sh script
  27. fetch-depth: 0
  28. - name: Set up JDK for running Gradle
  29. uses: actions/setup-java@v2
  30. with:
  31. distribution: temurin
  32. java-version: 17
  33. - name: Build and publish artifacts
  34. uses: gradle/gradle-build-action@v2
  35. with:
  36. arguments: assemble publishToSonatype closeAndReleaseSonatypeStagingRepository
  37. env:
  38. SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
  39. SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
  40. GRGIT_USER: ${{ github.actor }}
  41. GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
  42. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  43. GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
  44. - name: Build and publish gradle plugins
  45. uses: gradle/gradle-build-action@v2
  46. env:
  47. SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
  48. SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
  49. GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
  50. GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
  51. GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
  52. GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
  53. with:
  54. # Don't use publishToSonatype since we don't want to publish the marker artifact
  55. arguments: build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
  56. build-root-directory: gradle-plugins
  57. - name: Set versions
  58. id: set-versions
  59. run: |
  60. v=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1)
  61. if [[ $v =~ ([0-9]+).([0-9]+).([0-9]+) ]]; then
  62. major="${BASH_REMATCH[1]}"
  63. minor="${BASH_REMATCH[2]}"
  64. patch="${BASH_REMATCH[3]}"
  65. else
  66. echo "unexpected version: $v"
  67. exit 1
  68. fi
  69. if [[ $patch == 0 ]]; then
  70. if [[ $minor == 0 ]]; then
  71. prior_major=$((major - 1))
  72. prior_minor=$(grep -Po "^## Version $prior_major.\K([0-9]+)" CHANGELOG.md | head -1)
  73. prior="$prior_major.$prior_minor"
  74. else
  75. prior="$major.$((minor - 1)).0"
  76. fi
  77. else
  78. prior="$major.$minor.$((patch - 1))"
  79. fi
  80. echo "::set-output name=release-version::$v"
  81. echo "::set-output name=prior-version::$prior"
  82. echo "::set-output name=patch-version::$patch"
  83. - name: Generate release notes
  84. if: ${{ steps.set-versions.outputs.patch-version == 0 }}
  85. env:
  86. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  87. run: |
  88. cat > release-notes.txt << EOF
  89. 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.
  90. EOF
  91. sed -n '/^## Version ${{ steps.set-versions.outputs.release-version }}/,/^## Version /p' CHANGELOG.md \
  92. | tail -n +2 \
  93. | head -n -1 \
  94. | perl -0pe 's/^\n+//g' \
  95. | perl -0pe 's/\n+$/\n/g' \
  96. | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/[0-9]+\),#\1,' \
  97. | perl -0pe 's/\n +/ /g' \
  98. >> release-notes.txt
  99. cat >> release-notes.txt << EOF
  100. ### 🙇 Thank you
  101. This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests:
  102. EOF
  103. .github/scripts/generate-release-contributors.sh v${{ steps.set-versions.outputs.prior-version }} v${{ steps.set-versions.outputs.release-version }} >> release-notes.txt
  104. - name: Generate patch release notes
  105. if: ${{ steps.set-versions.outputs.patch-version != 0 }}
  106. env:
  107. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  108. run: |
  109. cat > release-notes.txt << EOF
  110. This is a patch release on the previous ${{ steps.set-versions.outputs.prior-version }} release, fixing the issue(s) below.
  111. EOF
  112. sed -n '/^## Version ${{ steps.set-versions.outputs.release-version }}/,/^## Version /p' CHANGELOG.md \
  113. | tail -n +2 \
  114. | head -n -1 \
  115. | perl -0pe 's/^\n+//g' \
  116. | perl -0pe 's/\n+$/\n/g' \
  117. | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/[0-9]+\),#\1,' \
  118. | perl -0pe 's/\n +/ /g' \
  119. >> release-notes.txt
  120. - name: Create GitHub release
  121. env:
  122. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  123. run: |
  124. cp javaagent/build/libs/opentelemetry-javaagent-${{ steps.set-versions.outputs.release-version }}.jar opentelemetry-javaagent.jar
  125. gh release create --target ${{ github.ref_name }} \
  126. --title "Version ${{ steps.set-versions.outputs.release-version }}" \
  127. --notes-file release-notes.txt \
  128. --discussion-category announcements \
  129. v${{ steps.set-versions.outputs.release-version }} \
  130. opentelemetry-javaagent.jar