|
| 1 | +name: Release 1.33.6 |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + |
| 5 | +jobs: |
| 6 | + required-jobs: |
| 7 | + uses: ./.github/workflows/build-common.yml |
| 8 | + |
| 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 | + |
| 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 | + |
| 18 | + release: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + needs: |
| 21 | + - required-jobs |
| 22 | + outputs: |
| 23 | + version: ${{ steps.create-github-release.outputs.version }} |
| 24 | + steps: |
| 25 | + - run: | |
| 26 | + if [[ $GITHUB_REF_NAME != release/* ]]; then |
| 27 | + echo this workflow should only be run against release branches |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | +
|
| 31 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 32 | + |
| 33 | + - name: Set environment variables |
| 34 | + run: | |
| 35 | + version=$(.github/scripts/get-version.sh) |
| 36 | + if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then |
| 37 | + major="${BASH_REMATCH[1]}" |
| 38 | + minor="${BASH_REMATCH[2]}" |
| 39 | + patch="${BASH_REMATCH[3]}" |
| 40 | + else |
| 41 | + echo "unexpected version: $version" |
| 42 | + exit 1 |
| 43 | + fi |
| 44 | + if [[ $patch == 0 ]]; then |
| 45 | + if [[ $minor == 0 ]]; then |
| 46 | + prior_major=$((major - 1)) |
| 47 | + prior_minor=$(grep -Po "^## Version $prior_major.\K[0-9]+" CHANGELOG.md | head -1) |
| 48 | + prior_version="$prior_major.$prior_minor" |
| 49 | + else |
| 50 | + prior_version="$major.$((minor - 1)).0" |
| 51 | + fi |
| 52 | + else |
| 53 | + prior_version="$major.$minor.$((patch - 1))" |
| 54 | + fi |
| 55 | + echo "VERSION=$version" >> $GITHUB_ENV |
| 56 | + echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + # check out main branch to verify there won't be problems with merging the change log |
| 59 | + # at the end of this workflow |
| 60 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 61 | + with: |
| 62 | + ref: main |
| 63 | + |
| 64 | + - name: Check that change log update was merged to main |
| 65 | + run: | |
| 66 | + if [[ $VERSION == *.0 ]]; then |
| 67 | + # not making a patch release |
| 68 | + if ! grep --quiet "^## Version $VERSION " CHANGELOG.md; then |
| 69 | + echo the pull request generated by prepare-release-branch.yml needs to be merged first |
| 70 | + exit 1 |
| 71 | + fi |
| 72 | + fi |
| 73 | +
|
| 74 | + # back to the release branch |
| 75 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 76 | + with: |
| 77 | + # tags are needed for the generate-release-contributors.sh script |
| 78 | + fetch-depth: 0 |
| 79 | + |
| 80 | + - name: Free disk space |
| 81 | + run: .github/scripts/gha-free-disk-space.sh |
| 82 | + |
| 83 | + - uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 |
| 84 | + with: |
| 85 | + distribution: temurin |
| 86 | + java-version-file: .java-version |
| 87 | + |
| 88 | + - name: Setup Gradle |
| 89 | + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 |
| 90 | + |
| 91 | + - name: Build and publish artifacts |
| 92 | + env: |
| 93 | + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} |
| 94 | + SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} |
| 95 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 96 | + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} |
| 97 | + # Skip publishing, it was already done with the previous release attempt. We need to run |
| 98 | + # the steps that follow to complete the release. |
| 99 | + # run: ./gradlew assemble spdxSbom publishToSonatype closeAndReleaseSonatypeStagingRepository |
| 100 | + run: ./gradlew assemble spdxSbom |
| 101 | + |
| 102 | + - name: Build and publish gradle plugins |
| 103 | + env: |
| 104 | + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} |
| 105 | + SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} |
| 106 | + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} |
| 107 | + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} |
| 108 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 109 | + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} |
| 110 | + # Don't use publishToSonatype since we don't want to publish the marker artifact |
| 111 | + run: ./gradlew build publishPlugins publishPluginMavenPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository |
| 112 | + working-directory: gradle-plugins |
| 113 | + |
| 114 | + - name: Collect SBOMs |
| 115 | + run: | |
| 116 | + mkdir sboms |
| 117 | + cp javaagent/build/spdx/*.spdx.json sboms |
| 118 | + zip opentelemetry-java-instrumentation-SBOM.zip sboms/* |
| 119 | +
|
| 120 | + - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 |
| 121 | + name: Upload SBOMs |
| 122 | + with: |
| 123 | + name: opentelemetry-java-instrumentation-SBOM |
| 124 | + path: "sboms/*.json" |
| 125 | + |
| 126 | + - name: Generate release notes |
| 127 | + env: |
| 128 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 129 | + run: | |
| 130 | + sdk_version=$(grep -Po "val otelSdkVersion = \"\K[0-9]+.[0-9]+.[0-9]+" dependencyManagement/build.gradle.kts) |
| 131 | +
|
| 132 | + # conditional blocks not indented because of the heredoc |
| 133 | + if [[ $VERSION == *.0 ]]; then |
| 134 | + cat > /tmp/release-notes.txt << EOF |
| 135 | + This release targets the OpenTelemetry SDK $sdk_version. |
| 136 | +
|
| 137 | + Note that many artifacts 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. |
| 138 | +
|
| 139 | + EOF |
| 140 | + else |
| 141 | + cat > /tmp/release-notes.txt << EOF |
| 142 | + This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below. |
| 143 | +
|
| 144 | + EOF |
| 145 | + fi |
| 146 | +
|
| 147 | + # CHANGELOG_SECTION.md is also used at the end of the release workflow |
| 148 | + # for copying the change log updates to main |
| 149 | + sed -n "0,/^## Version $VERSION /d;/^## Version /q;p" CHANGELOG.md \ |
| 150 | + > /tmp/CHANGELOG_SECTION.md |
| 151 | +
|
| 152 | + # the complex perl regex is needed because markdown docs render newlines as soft wraps |
| 153 | + # while release notes render them as line breaks |
| 154 | + perl -0pe 's/(?<!\n)\n *(?!\n)(?![-*] )(?![1-9]+\. )/ /g' /tmp/CHANGELOG_SECTION.md \ |
| 155 | + >> /tmp/release-notes.txt |
| 156 | +
|
| 157 | + # conditional block not indented because of the heredoc |
| 158 | + if [[ $VERSION == *.0 ]]; then |
| 159 | + cat >> /tmp/release-notes.txt << EOF |
| 160 | + ### 🙇 Thank you |
| 161 | +
|
| 162 | + This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests: |
| 163 | +
|
| 164 | + EOF |
| 165 | +
|
| 166 | + .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION >> /tmp/release-notes.txt |
| 167 | + fi |
| 168 | +
|
| 169 | + - id: create-github-release |
| 170 | + name: Create GitHub release |
| 171 | + env: |
| 172 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 173 | + run: | |
| 174 | + cp javaagent/build/libs/opentelemetry-javaagent-${VERSION}.jar opentelemetry-javaagent.jar |
| 175 | + gh release create --target $GITHUB_REF_NAME \ |
| 176 | + --title "Version $VERSION" \ |
| 177 | + --notes-file /tmp/release-notes.txt \ |
| 178 | + v$VERSION \ |
| 179 | + opentelemetry-javaagent.jar \ |
| 180 | + opentelemetry-java-instrumentation-SBOM.zip |
| 181 | +
|
| 182 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 183 | +
|
| 184 | + merge-change-log-to-main: |
| 185 | + runs-on: ubuntu-latest |
| 186 | + needs: |
| 187 | + - release |
| 188 | + steps: |
| 189 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 190 | + |
| 191 | + - name: Copy change log section from release branch |
| 192 | + env: |
| 193 | + VERSION: ${{ needs.release.outputs.version }} |
| 194 | + run: | |
| 195 | + sed -n "0,/^## Version $VERSION /d;/^## Version /q;p" CHANGELOG.md \ |
| 196 | + > /tmp/changelog-section.md |
| 197 | +
|
| 198 | + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 199 | + with: |
| 200 | + ref: main |
| 201 | + |
| 202 | + - name: Merge change log to main |
| 203 | + env: |
| 204 | + VERSION: ${{ needs.release.outputs.version }} |
| 205 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 206 | + run: | |
| 207 | + release_date=$(gh release view v$VERSION --json publishedAt --jq .publishedAt | sed 's/T.*//') |
| 208 | + RELEASE_DATE=$release_date .github/scripts/merge-change-log-after-release.sh |
| 209 | +
|
| 210 | + - name: Use CLA approved github bot |
| 211 | + run: .github/scripts/use-cla-approved-github-bot.sh |
| 212 | + |
| 213 | + - name: Create pull request against main |
| 214 | + env: |
| 215 | + VERSION: ${{ needs.release.outputs.version }} |
| 216 | + # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows |
| 217 | + GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} |
| 218 | + run: | |
| 219 | + if git diff --quiet; then |
| 220 | + if [[ $VERSION == *.0 ]]; then |
| 221 | + echo there are no updates to merge, not creating pull request |
| 222 | + exit 0 # success |
| 223 | + else |
| 224 | + echo patch release notes did not get applied for some reason |
| 225 | + exit 1 # failure |
| 226 | + fi |
| 227 | + fi |
| 228 | +
|
| 229 | + message="Merge change log updates from $GITHUB_REF_NAME" |
| 230 | + body="Merge change log updates from \`$GITHUB_REF_NAME\`." |
| 231 | + branch="opentelemetrybot/merge-change-log-updates-from-${GITHUB_REF_NAME//\//-}" |
| 232 | +
|
| 233 | + git checkout -b $branch |
| 234 | + git commit -a -m "$message" |
| 235 | + git push --set-upstream origin $branch |
| 236 | + gh pr create --title "$message" \ |
| 237 | + --body "$body" \ |
| 238 | + --base main |
0 commit comments