Release #67
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| already-published: | |
| description: 'Skip publishing, download artifacts from Maven Central instead' | |
| default: false | |
| type: boolean | |
| permissions: | |
| contents: read | |
| jobs: | |
| common: | |
| uses: ./.github/workflows/build-common.yml | |
| release: | |
| permissions: | |
| contents: write # for creating the release | |
| id-token: write # for signing artifacts with Sigstore | |
| attestations: write # for uploading attestations | |
| runs-on: ubuntu-latest | |
| needs: | |
| - common | |
| outputs: | |
| version: ${{ steps.create-github-release.outputs.version }} | |
| steps: | |
| - run: | | |
| if [[ $GITHUB_REF_NAME != release/* ]]; then | |
| echo this workflow should only be run against release branches | |
| exit 1 | |
| fi | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Set environment variables | |
| run: | | |
| version=$(.github/scripts/get-version.sh) | |
| if [[ $version =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | |
| major="${BASH_REMATCH[1]}" | |
| minor="${BASH_REMATCH[2]}" | |
| patch="${BASH_REMATCH[3]}" | |
| else | |
| echo "unexpected version: $version" | |
| exit 1 | |
| fi | |
| if [[ $patch == 0 ]]; then | |
| if [[ $minor == 0 ]]; then | |
| prior_major=$((major - 1)) | |
| prior_minor=$(grep -Po "^## Version $prior_major.\K[0-9]+" CHANGELOG.md | head -1) | |
| prior_version="$prior_major.$prior_minor" | |
| else | |
| prior_version="$major.$((minor - 1)).0" | |
| fi | |
| else | |
| prior_version="$major.$minor.$((patch - 1))" | |
| fi | |
| echo "VERSION=$version" >> $GITHUB_ENV | |
| echo "PRIOR_VERSION=$prior_version" >> $GITHUB_ENV | |
| # check out main branch to verify there won't be problems with merging the change log | |
| # at the end of this workflow | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: main | |
| - name: Check that change log update was merged to main | |
| run: | | |
| if [[ $VERSION == *.0 ]]; then | |
| # not making a patch release | |
| if ! grep --quiet "^## Version $VERSION " CHANGELOG.md; then | |
| echo the pull request generated by prepare-release-branch.yml needs to be merged first | |
| exit 1 | |
| fi | |
| fi | |
| # back to the release branch | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| # tags are needed for the generate-release-contributors.sh script | |
| fetch-depth: 0 | |
| - name: Set up JDK for running Gradle | |
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Set up gradle | |
| uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 | |
| - name: Build and publish artifacts | |
| if: ${{ !inputs.already-published }} | |
| run: ./gradlew assemble publishToSonatype closeAndReleaseSonatypeStagingRepository | |
| env: | |
| SONATYPE_USER: ${{ secrets.SONATYPE_USER }} | |
| SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} | |
| - name: Download artifacts from Maven Central (when already published) | |
| if: ${{ inputs.already-published }} | |
| run: | | |
| mkdir -p jmx-metrics/build/libs | |
| mkdir -p jmx-scraper/build/libs | |
| curl -L -o jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar \ | |
| "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-metrics/$VERSION-alpha/opentelemetry-jmx-metrics-$VERSION-alpha.jar" | |
| curl -L -o jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc \ | |
| "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-metrics/$VERSION-alpha/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc" | |
| curl -L -o jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar \ | |
| "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-scraper/$VERSION-alpha/opentelemetry-jmx-scraper-$VERSION-alpha.jar" | |
| curl -L -o jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar.asc \ | |
| "https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-jmx-scraper/$VERSION-alpha/opentelemetry-jmx-scraper-$VERSION-alpha.jar.asc" | |
| - name: Generate release notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| instrumentation_version=$(grep -Po "val otelInstrumentationVersion = \"\K[0-9]+.[0-9]+.[0-9]+" dependencyManagement/build.gradle.kts) | |
| # conditional blocks not indented because of the heredoc | |
| if [[ $VERSION == *.0 ]]; then | |
| cat > /tmp/release-notes.txt << EOF | |
| This release targets the OpenTelemetry Java Instrumentation [$instrumentation_version](https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/tag/v$instrumentation_version). | |
| EOF | |
| else | |
| cat > /tmp/release-notes.txt << EOF | |
| This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below. | |
| EOF | |
| fi | |
| # CHANGELOG_SECTION.md is also used at the end of the release workflow | |
| # for copying the change log updates to main | |
| sed -n "0,/^## Version $VERSION /d;/^## Version /q;p" CHANGELOG.md \ | |
| > /tmp/CHANGELOG_SECTION.md | |
| # the complex perl regex is needed because markdown docs render newlines as soft wraps | |
| # while release notes render them as line breaks | |
| perl -0pe 's/(?<!\n)\n *(?!\n)(?![-*] )(?![1-9]+\. )/ /g' /tmp/CHANGELOG_SECTION.md \ | |
| >> /tmp/release-notes.txt | |
| # conditional block not indented because of the heredoc | |
| if [[ $VERSION == *.0 ]]; then | |
| cat >> /tmp/release-notes.txt << EOF | |
| ### 🙇 Thank you | |
| This release was possible thanks to the following contributors who shared their brilliant ideas and awesome pull requests: | |
| EOF | |
| .github/scripts/generate-release-contributors.sh v$PRIOR_VERSION >> /tmp/release-notes.txt | |
| fi | |
| - name: Simplify paths for attaching | |
| run: | | |
| cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar opentelemetry-jmx-metrics.jar | |
| cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION-alpha.jar.asc opentelemetry-jmx-metrics.jar.asc | |
| cp jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar opentelemetry-jmx-scraper.jar | |
| cp jmx-scraper/build/libs/opentelemetry-jmx-scraper-$VERSION-alpha.jar.asc opentelemetry-jmx-scraper.jar.asc | |
| - uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 | |
| with: | |
| subject-path: | | |
| opentelemetry-jmx-metrics.jar | |
| opentelemetry-jmx-scraper.jar | |
| - id: create-github-release | |
| name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create --target $GITHUB_REF_NAME \ | |
| --title "Version $VERSION" \ | |
| --notes-file /tmp/release-notes.txt \ | |
| v$VERSION \ | |
| opentelemetry-jmx-metrics.jar \ | |
| opentelemetry-jmx-metrics.jar.asc \ | |
| opentelemetry-jmx-scraper.jar \ | |
| opentelemetry-jmx-scraper.jar.asc | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| post-release-updates: | |
| permissions: | |
| contents: write # for git push to PR branch | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release | |
| steps: | |
| # add change log sync (if any) into this PR since the apidiff update | |
| # is required before any other PR can be merged anyway | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Copy change log section from release branch | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| run: | | |
| sed -n "0,/^## Version $VERSION /d;/^## Version /q;p" CHANGELOG.md \ | |
| > /tmp/changelog-section.md | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: main | |
| - name: Merge change log to main | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| release_date=$(gh release view v$VERSION --json publishedAt --jq .publishedAt | sed 's/T.*//') | |
| RELEASE_DATE=$release_date .github/scripts/merge-change-log-after-release.sh | |
| - name: Wait for release to be available in maven central | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| run: | | |
| until curl --silent \ | |
| --show-error \ | |
| --output /dev/null \ | |
| --head \ | |
| --fail \ | |
| https://repo1.maven.org/maven2/io/opentelemetry/contrib/opentelemetry-aws-xray/$VERSION/opentelemetry-aws-xray-$VERSION.jar | |
| do | |
| sleep 60 | |
| done | |
| - name: Set up JDK for running Gradle | |
| uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Set up Gradle | |
| uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 | |
| - name: Update apidiff baseline | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| PRIOR_VERSION: ${{ needs.release.outputs.prior-version }} | |
| run: | | |
| ./gradlew japicmp -PapiBaseVersion=$PRIOR_VERSION -PapiNewVersion=$VERSION | |
| ./gradlew --refresh-dependencies japicmp | |
| - name: Use CLA approved bot | |
| run: .github/scripts/use-cla-approved-bot.sh | |
| - uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 | |
| id: otelbot-token | |
| with: | |
| app-id: ${{ vars.OTELBOT_APP_ID }} | |
| private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} | |
| - name: Create pull request against main | |
| env: | |
| VERSION: ${{ needs.release.outputs.version }} | |
| # not using secrets.GITHUB_TOKEN since pull requests from that token do not run workflows | |
| GH_TOKEN: ${{ steps.otelbot-token.outputs.token }} | |
| run: | | |
| message="Post-release updates for $VERSION" | |
| body="Post-release updates for \`$VERSION\`." | |
| branch="otelbot/update-apidiff-baseline-to-released-version-${VERSION}" | |
| git checkout -b $branch | |
| git add CHANGELOG.md | |
| git add docs/apidiffs | |
| git commit -m "$message" | |
| git push --set-upstream origin $branch | |
| gh pr create --title "$message" \ | |
| --body "$body" \ | |
| --base main |