diff --git a/.github/scripts/markdown-link-check-config.json b/.github/scripts/markdown-link-check-config.json new file mode 100644 index 00000000..52165915 --- /dev/null +++ b/.github/scripts/markdown-link-check-config.json @@ -0,0 +1,3 @@ +{ + "retryOn429": true +} diff --git a/.github/scripts/markdown_link_check_config.json b/.github/scripts/markdown_link_check_config.json deleted file mode 100644 index b8f7f88f..00000000 --- a/.github/scripts/markdown_link_check_config.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "^https://github\\.com/open-telemetry/opentelemetry-java-contrib/pull/" - } - ], - "retryOn429": true -} diff --git a/.github/templates/workflow-failed.md b/.github/templates/workflow-failed.md deleted file mode 100644 index 79c36b6d..00000000 --- a/.github/templates/workflow-failed.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: "{{ env.GITHUB_WORKFLOW }} #{{ env.GITHUB_RUN_NUMBER }} failed" -labels: bug ---- - -{{ env.GITHUB_WORKFLOW }} #{{ env.GITHUB_RUN_NUMBER }} failed. Please take a look and fix it ASAP. diff --git a/.github/workflows/assign-reviewers.yml b/.github/workflows/assign-reviewers.yml new file mode 100644 index 00000000..255fdd9c --- /dev/null +++ b/.github/workflows/assign-reviewers.yml @@ -0,0 +1,15 @@ +# assigns reviewers to pull requests in a similar way as CODEOWNERS, but doesn't require reviewers +# to have write access to the repository +# see .github/component_owners.yaml for the list of components and their owners +name: Assign reviewers + +on: + # pull_request_target is needed instead of just pull_request + # because repository write permission is needed to assign reviewers + pull_request_target: + +jobs: + assign-reviewers: + runs-on: ubuntu-latest + steps: + - uses: dyladan/component-owners@main diff --git a/.github/workflows/backport-pull-request.yml b/.github/workflows/backport-pull-request.yml new file mode 100644 index 00000000..9712c286 --- /dev/null +++ b/.github/workflows/backport-pull-request.yml @@ -0,0 +1,38 @@ +name: Backport a pull request +on: + workflow_dispatch: + inputs: + number: + description: "The pull request # to backport" + required: true + +jobs: + backport: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # history is needed in order to do cherry-pick + fetch-depth: 0 + + - name: Set up git name + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request + env: + NUMBER: ${{ github.event.inputs.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid) + title=$(gh pr view $NUMBER --json title --jq .title) + url=$(gh pr view $NUMBER --json url --jq .url) + + git cherry-pick $commit + git push origin HEAD:backport-$NUMBER-to-$GITHUB_REF_NAME + + gh pr create --title "[$GITHUB_REF_NAME] $title" \ + --body "Clean cherry-pick of #$NUMBER to the $GITHUB_REF_NAME branch." \ + --head backport-$NUMBER-to-$GITHUB_REF_NAME \ + --base $GITHUB_REF_NAME diff --git a/.github/workflows/pr-build.yml b/.github/workflows/build-pull-request.yml similarity index 58% rename from .github/workflows/pr-build.yml rename to .github/workflows/build-pull-request.yml index 9654e592..dfdb194e 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/build-pull-request.yml @@ -1,20 +1,15 @@ -name: "PR Build" +name: Build pull request on: pull_request: - branches: - - main jobs: build: - name: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Java 17 + - name: Set up JDK for running Gradle uses: actions/setup-java@v3 with: distribution: temurin @@ -34,42 +29,46 @@ jobs: path: jmx-metrics/build/reports/tests/test integration-test: - name: integration-test runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Setup Java 17 + - name: Set up JDK for running Gradle uses: actions/setup-java@v3 with: distribution: temurin java-version: 17 - uses: gradle/gradle-build-action@v2 - name: Integration Tests + name: Integration test with: arguments: --stacktrace integrationTest cache-read-only: true - uses: actions/upload-artifact@v2 - name: Save integrationTest results + name: Save integration test results if: always() with: name: integration-test-results path: jmx-metrics/build/reports/tests/integrationTest - # markdown-link-check is not included in the PR build because links to external urls can break at - # any time, which can be confusing for contributors + # this is not a required check to avoid blocking pull requests if external links break + markdown-link-check: + uses: ./.github/workflows/reusable-markdown-link-check.yml - markdown-misspell-check: + # this is not a required check to avoid blocking pull requests if new misspellings are added + # to the misspell dictionary + misspell-check: + uses: ./.github/workflows/reusable-misspell-check.yml + + required-status-check: + needs: + - build + - integration-test runs-on: ubuntu-latest + if: always() steps: - - uses: actions/checkout@v3 - - - name: Check markdown for common misspellings - run: | - curl -L -o ./install-misspell.sh https://git.io/misspell - sh ./install-misspell.sh - ./bin/misspell -error ./**/* + - if: | + needs.build.result != 'success' || + needs.integration-test.result != 'success' + run: exit 1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..a5104ff6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,92 @@ +name: Build + +on: + push: + branches: + - main + - v[0-9]+.[0-9]+.x + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - name: Build + uses: gradle/gradle-build-action@v2 + with: + arguments: --stacktrace build + + - name: Save unit test results + uses: actions/upload-artifact@v2 + if: always() + with: + name: test-results + path: jmx-metrics/build/reports/tests/test + + integration-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - name: Integration test + uses: gradle/gradle-build-action@v2 + with: + arguments: --stacktrace integrationTest + + - name: Save integration test results + uses: actions/upload-artifact@v2 + if: always() + with: + name: integration-test-results + path: jmx-metrics/build/reports/tests/integrationTest + + markdown-link-check: + # release branches are excluded to avoid unnecessary maintenance if external links break + if: ${{ !startsWith(github.ref_name, 'v') }} + uses: ./.github/workflows/reusable-markdown-link-check.yml + + misspell-check: + # release branches are excluded to avoid unnecessary maintenance if new misspellings are added + # to the misspell dictionary + if: ${{ !startsWith(github.ref_name, 'v') }} + uses: ./.github/workflows/reusable-misspell-check.yml + + publish-snapshots: + needs: + # intentionally not blocking snapshot publishing on markdown-link-check, or misspell-check + - build + - integration-test + runs-on: ubuntu-latest + if: ${{ github.repository == 'open-telemetry/opentelemetry-java-contrib' }} + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - uses: gradle/gradle-build-action@v2 + name: Publish + with: + arguments: --stacktrace snapshot + env: + SONATYPE_USER: ${{ secrets.SONATYPE_USER }} + SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} diff --git a/.github/workflows/nightly-codeql-analysis.yml b/.github/workflows/codeql-daily.yml similarity index 57% rename from .github/workflows/nightly-codeql-analysis.yml rename to .github/workflows/codeql-daily.yml index d19c4e17..e73cee1d 100644 --- a/.github/workflows/nightly-codeql-analysis.yml +++ b/.github/workflows/codeql-daily.yml @@ -1,9 +1,9 @@ name: Nightly CodeQL analysis on: - workflow_dispatch: schedule: - cron: '30 1 * * *' + workflow_dispatch: jobs: analyze: @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Java 17 + - name: Set up Java 17 uses: actions/setup-java@v2 with: distribution: temurin @@ -31,24 +31,10 @@ jobs: # skipping build cache is needed so that all modules will be analyzed arguments: assemble --no-build-cache - - name: Perform CodeQL Analysis + - name: Perform CodeQL analysis uses: github/codeql-action/analyze@v1 issue: - name: Open issue on failure needs: analyze - runs-on: ubuntu-latest - if: always() - steps: - # run this action to get workflow conclusion - # You can get conclusion by env (env.WORKFLOW_CONCLUSION) - - uses: technote-space/workflow-conclusion-action@v2.2 - - - uses: actions/checkout@v3 - - - uses: JasonEtco/create-an-issue@v2.6 - if: env.WORKFLOW_CONCLUSION == 'failure' # notify only if failure - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - filename: .github/templates/workflow-failed.md + if: failure() + uses: ./.github/workflows/reusable-create-issue-for-failure.yml diff --git a/.github/workflows/component-owners.yml b/.github/workflows/component-owners.yml deleted file mode 100644 index 0107b7ef..00000000 --- a/.github/workflows/component-owners.yml +++ /dev/null @@ -1,14 +0,0 @@ -# This action assigns and requires approval from owners of components for -# PRs that are open against those components. Components are defined in -# .github/component_owners.yaml as individual paths within this repository. -name: Component Owners - -on: - pull_request_target: - -jobs: - run_self: - runs-on: ubuntu-latest - name: Auto Assign Owners - steps: - - uses: dyladan/component-owners@main diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 00000000..e407efce --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,16 @@ +name: Gradle wrapper validation +on: + pull_request: + paths: + - '**/gradle/wrapper/**' + push: + paths: + - '**/gradle/wrapper/**' + +jobs: + validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: gradle/wrapper-validation-action@v1.0.4 diff --git a/.github/workflows/main-build.yml b/.github/workflows/main-build.yml deleted file mode 100644 index 8be67f70..00000000 --- a/.github/workflows/main-build.yml +++ /dev/null @@ -1,118 +0,0 @@ -name: "Main Build" - -on: - push: - branches: - - main - -jobs: - build: - name: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Build - with: - arguments: --stacktrace build - - - uses: actions/upload-artifact@v2 - name: Save unit test results - if: always() - with: - name: test-results - path: jmx-metrics/build/reports/tests/test - - integration-test: - name: integration-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Integration Tests - with: - arguments: --stacktrace integrationTest - - - uses: actions/upload-artifact@v2 - name: Save integrationTest results - if: always() - with: - name: integration-test-results - path: jmx-metrics/build/reports/tests/integrationTest - - markdown-link-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Check markdown links - # using retry because of sporadic external site failures - uses: nick-invision/retry@v2.6.0 - with: - # timing out has not been a problem - timeout_minutes: 15 - # give external site some time to hopefully recover - retry_wait_seconds: 120 - max_attempts: 5 - command: | - npm install -g markdown-link-check - find . -type f \ - -name '*.md' \ - -not -path './.github/*' \ - -not -path './node_modules/*' \ - -print0 \ - | xargs -0 -n1 markdown-link-check --config .github/scripts/markdown_link_check_config.json - - markdown-misspell-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Check markdown for common misspellings - run: | - curl -L -o ./install-misspell.sh https://git.io/misspell - sh ./install-misspell.sh - ./bin/misspell -error ./**/* - - publish-snapshots: - name: publish-snapshots - runs-on: ubuntu-latest - needs: [build, integration-test] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Publish - with: - arguments: --stacktrace snapshot - env: - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} diff --git a/.github/workflows/patch-release-build.yml b/.github/workflows/patch-release-build.yml deleted file mode 100644 index 56a79090..00000000 --- a/.github/workflows/patch-release-build.yml +++ /dev/null @@ -1,162 +0,0 @@ -name: Patch Release Build -on: - workflow_dispatch: - inputs: - version: - description: The version to tag the release with, e.g., 1.2.1, 1.2.2 - required: true - -jobs: - # TODO (trask) remove this after 1.13.0 since release branch is now created proactively - prepare-release-branch: - runs-on: ubuntu-latest - outputs: - release-branch-name: ${{ steps.parse-release-branch.outputs.release-branch-name }} - steps: - - id: parse-release-branch - name: Parse release branch name - run: | - # Sets the release-branch-name output to the version number with the last non-period element replaced with an 'x' and preprended with v. - echo "::set-output name=release-branch-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.x/')" - # Sets the release-tag-name output to the version number with the last non-period element replace with a '0' and prepended with v - echo "::set-output name=release-tag-name::$(echo '${{ github.event.inputs.version }}' | sed -E 's/([^.]+)\.([^.]+)\.([^.]+)/v\1.\2.0/')" - - - id: checkout-release-branch - name: Check out release branch - continue-on-error: true - uses: actions/checkout@v3 - with: - ref: ${{ steps.parse-release-branch.outputs.release-branch-name }} - fetch-depth: 0 - - - id: checkout-release-tag - name: Check out release tag - if: ${{ steps.checkout-release-branch.outcome == 'failure' }} - uses: actions/checkout@v3 - with: - ref: ${{ steps.parse-release-branch.outputs.release-tag-name }} - fetch-depth: 0 - - - name: Create release branch - if: ${{ steps.checkout-release-tag.outcome == 'success' }} - run: | - git checkout -b ${{ steps.parse-release-branch.outputs.release-branch-name }} - git push --set-upstream origin ${{ steps.parse-release-branch.outputs.release-branch-name }} - - build: - name: build - needs: prepare-release-branch - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Build - with: - arguments: --stacktrace build - - - uses: actions/upload-artifact@v2 - name: Save unit test results - if: always() - with: - name: test-results - path: jmx-metrics/build/reports/tests/test - - integration-test: - name: integration-test - needs: prepare-release-branch - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Integration Tests - with: - arguments: --stacktrace integrationTest - - - uses: actions/upload-artifact@v2 - name: Save integrationTest results - if: always() - with: - name: integration-test-results - path: jmx-metrics/build/reports/tests/integrationTest - - publish: - name: publish - runs-on: ubuntu-latest - needs: [ build, integration-test ] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Publish - with: - arguments: --stacktrace final closeAndReleaseSonatypeStagingRepository -Prelease.version=${{ github.event.inputs.version }} - env: - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} - - - name: Set SDK version - id: set-sdk-version - run: | - v=$(grep -Po "io.opentelemetry:opentelemetry-bom:\K[0-9]+.[0-9]+.0" dependencyManagement/build.gradle.kts) - echo "::set-output name=sdk-version::$v" - - - name: Generate Release Notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cat > release-notes.txt << EOF - This release targets the OpenTelemetry SDK ${{ steps.set-sdk-version.outputs.sdk-version }}. - - EOF - - sed -n '/^## Version ${{ github.event.inputs.version }}/,/^## Version /p' CHANGELOG.md \ - | head -n -1 \ - | perl -0pe 's/^\n+//g' \ - | perl -0pe 's/\n+$/\n/g' \ - | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-contrib/pull/[0-9]+\),#\1,' \ - | perl -0pe 's/\n +/ /g' \ - >> release-notes.txt - - cat >> release-notes.txt << EOF - - EOF - - - name: Create GitHub release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-${{ github.event.inputs.version }}.jar opentelemetry-jmx-metrics.jar - gh release create --target ${{ github.ref_name }} \ - --title "Version ${{ github.event.inputs.version }}" \ - --notes-file release-notes.txt \ - --discussion-category announcements \ - v${{ github.event.inputs.version }} \ - opentelemetry-javaagent.jar diff --git a/.github/workflows/prepare-patch-release.yml b/.github/workflows/prepare-patch-release.yml new file mode 100644 index 00000000..4d52807b --- /dev/null +++ b/.github/workflows/prepare-patch-release.yml @@ -0,0 +1,48 @@ +name: Prepare patch release +on: + workflow_dispatch: + +jobs: + prepare-patch-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set versions + id: set-versions + run: | + prior_version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1) + if [[ $prior_version =~ ([0-9]+.[0-9]+).([0-9]+) ]]; then + major_minor="${BASH_REMATCH[1]}" + patch="${BASH_REMATCH[2]}" + else + echo "unexpected version: $prior_version" + exit 1 + fi + echo "::set-output name=release-version::$major_minor.$((patch + 1))" + echo "::set-output name=prior-release-version::$prior_version" + + - name: Bump version + env: + VERSION: ${{ needs.set-versions.outputs.release-version }} + PRIOR_VERSION: ${{ needs.set-versions.outputs.prior-release-version }} + run: | + sed -ri "s/$PRIOR_VERSION/$VERSION/" version.gradle.kts + + - name: Set up git name + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request + env: + VERSION: ${{ needs.set-versions.outputs.release-version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Prepare patch release $VERSION" + git commit -a -m "$msg" + git push origin HEAD:prepare-patch-release-$VERSION + gh pr create --title "$msg" \ + --body "$msg" \ + --head prepare-patch-release-$VERSION \ + --base $GITHUB_REF_NAME diff --git a/.github/workflows/prepare-release-branch.yml b/.github/workflows/prepare-release-branch.yml new file mode 100644 index 00000000..ef46c4f2 --- /dev/null +++ b/.github/workflows/prepare-release-branch.yml @@ -0,0 +1,96 @@ +name: Prepare release branch +on: + workflow_dispatch: + +jobs: + prepare-release-branch: + runs-on: ubuntu-latest + outputs: + release-branch-name: ${{ steps.set-release-branch-name.outputs.release-branch-name }} + steps: + - uses: actions/checkout@v3 + + - name: Set release branch name + id: set-release-branch-name + run: | + version=$(grep -Eo "[0-9.]+-SNAPSHOT" version.gradle.kts) + release_branch_name=$(echo $version | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/') + echo "::set-output name=release-branch-name::$release_branch_name" + + - name: Create release branch + env: + RELEASE_BRANCH_NAME: ${{ steps.set-release-branch-name.outputs.release-branch-name }} + run: | + git checkout -b $RELEASE_BRANCH_NAME + git push origin $RELEASE_BRANCH_NAME + + create-pull-request-against-release-branch: + needs: prepare-release-branch + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ needs.prepare-release-branch.outputs.release-branch-name }} + + - name: Bump version on release branch + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//') + sed -ri "s/$version-SNAPSHOT/$version/" version.gradle.kts + sed -ri "s/$version-alpha-SNAPSHOT/$version-alpha/" version.gradle.kts + + - name: Set up git name + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request against release branch + env: + RELEASE_BRANCH_NAME: ${{ needs.prepare-release-branch.outputs.release-branch-name }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Prepare release branch $RELEASE_BRANCH_NAME" + git commit -a -m "$msg" + git push origin HEAD:prepare-release-branch-$RELEASE_BRANCH_NAME + gh pr create --title "$msg" \ + --body "$msg" \ + --head prepare-release-branch-$RELEASE_BRANCH_NAME \ + --base $RELEASE_BRANCH_NAME + + create-pull-request-against-main: + needs: + - prepare-release-branch + - create-pull-request-against-release-branch + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Bump snapshot version + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.0-SNAPSHOT" version.gradle.kts | sed 's/-SNAPSHOT//') + if [[ $version =~ ([0-9]+).([0-9]+).0 ]]; then + major="${BASH_REMATCH[1]}" + minor="${BASH_REMATCH[2]}" + else + echo "unexpected version: $version" + exit 1 + fi + next_version="$major.$((minor + 1)).0" + sed -ri "s/$version-SNAPSHOT/$next_version-SNAPSHOT/" version.gradle.kts + sed -ri "s/$version-apha-SNAPSHOT/$next_version-apha-SNAPSHOT/" version.gradle.kts + + - name: Set up git name + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + - name: Create pull request against main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + msg="Bump version" + git commit -a -m "$msg" + git push origin HEAD:bump-snapshot-version + gh pr create --title "$msg" \ + --body "$msg" \ + --head bump-snapshot-version \ + --base main diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml deleted file mode 100644 index 2309add1..00000000 --- a/.github/workflows/release-build.yml +++ /dev/null @@ -1,133 +0,0 @@ -# Releases a new minor / major version from the HEAD of the main branch -name: Release Build -on: - workflow_dispatch: - inputs: - version: - description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 - required: true - -jobs: - build: - name: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Build - with: - arguments: --stacktrace build - - - uses: actions/upload-artifact@v2 - name: Save unit test results - if: always() - with: - name: test-results - path: jmx-metrics/build/reports/tests/test - - integration-test: - name: integration-test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Integration Tests - with: - arguments: --stacktrace integrationTest - - - uses: actions/upload-artifact@v2 - name: Save integrationTest results - if: always() - with: - name: integration-test-results - path: jmx-metrics/build/reports/tests/integrationTest - - publish: - name: publish - runs-on: ubuntu-latest - needs: [build, integration-test] - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - distribution: temurin - java-version: 17 - - - uses: gradle/gradle-build-action@v2 - name: Publish - with: - arguments: --stacktrace final closeAndReleaseSonatypeStagingRepository -Prelease.version=${{ github.event.inputs.version }} - env: - SONATYPE_USER: ${{ secrets.SONATYPE_USER }} - SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }} - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} - - - name: Set SDK version - id: set-sdk-version - run: | - v=$(grep -Po "io.opentelemetry:opentelemetry-bom:\K[0-9]+.[0-9]+.0" dependencyManagement/build.gradle.kts) - echo "::set-output name=sdk-version::$v" - - - name: Generate Release Notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cat > release-notes.txt << EOF - This release targets the OpenTelemetry SDK ${{ steps.set-sdk-version.outputs.sdk-version }}. - - EOF - - sed -n '/^## Version ${{ github.event.inputs.version }}/,/^## Version /p' CHANGELOG.md \ - | tail -n +2 \ - | head -n -1 \ - | perl -0pe 's/^\n+//g' \ - | perl -0pe 's/\n+$/\n/g' \ - | sed -r 's,\[#([0-9]+)]\(https://github.com/open-telemetry/opentelemetry-java-contrib/pull/[0-9]+\),#\1,' \ - | perl -0pe 's/\n +/ /g' \ - >> release-notes.txt - - cat >> release-notes.txt << EOF - - EOF - - - name: Create GitHub release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-${{ github.event.inputs.version }}.jar opentelemetry-jmx-metrics.jar - gh release create --target ${{ github.ref_name }} \ - --title "Version ${{ github.event.inputs.version }}" \ - --notes-file release-notes.txt \ - --discussion-category announcements \ - v${{ github.event.inputs.version }} \ - opentelemetry-javaagent.jar - - # proactively create release branch so that contributors can suggest patches more easily - - name: Create release branch - run: | - branch_name=$(echo ${{ github.event.inputs.version }} | sed -E 's/([0-9]+)\.([0-9]+)\.0/v\1.\2.x/') - git checkout -b $branch_name - git push origin $branch_name diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9350e7eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,182 @@ +name: Release +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - uses: gradle/gradle-build-action@v2 + name: Build + with: + arguments: --stacktrace build + + - uses: actions/upload-artifact@v2 + name: Save unit test results + if: always() + with: + name: test-results + path: jmx-metrics/build/reports/tests/test + + integration-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK for running Gradle + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - uses: gradle/gradle-build-action@v2 + name: Integration test + with: + arguments: --stacktrace integrationTest + + - uses: actions/upload-artifact@v2 + name: Save integration test results + if: always() + with: + name: integration-test-results + path: jmx-metrics/build/reports/tests/integrationTest + + release: + runs-on: ubuntu-latest + needs: + - build + - integration-test + steps: + - uses: actions/checkout@v3 + 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@v3 + with: + distribution: temurin + java-version: 17 + + - name: Build and publish artifacts + uses: gradle/gradle-build-action@v2 + with: + arguments: 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: Set versions + id: set-versions + run: | + version=$(grep -Eo "[0-9]+.[0-9]+.[0-9]+" version.gradle.kts | head -1) + 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 "::set-output name=release-version::$version" + echo "::set-output name=prior-release-version::$prior_version" + + - name: Generate release notes + env: + VERSION: ${{ steps.set-versions.outputs.release-version }} + PRIOR_VERSION: ${{ steps.set-versions.outputs.prior-release-version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [[ $version == *.0 ]]; then + cat > release-notes.txt << EOF + This release targets the OpenTelemetry SDK $VERSION. + + EOF + else + cat > release-notes.txt << EOF + This is a patch release on the previous $PRIOR_VERSION release, fixing the issue(s) below. + + EOF + fi + + sed -n '/^## Version $VERSION/,/^## Version /p' CHANGELOG.md \ + | tail -n +2 \ + | head -n -1 \ + | perl -0pe 's/^\n+//g' \ + | perl -0pe 's/\n+$/\n/g' \ + | sed -r 's,\[#([0-9]+)]\(https://github.com/$GITHUB_REPOSITORY/(pull|issues)/[0-9]+\),#\1,' \ + | perl -0pe 's/\n +/ /g' \ + >> release-notes.txt + + if [[ $version == *.0 ]]; then + cat >> 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 v$VERSION >> release-notes.txt + fi + + - name: Create GitHub release + env: + VERSION: ${{ steps.set-versions.outputs.release-version }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cp jmx-metrics/build/libs/opentelemetry-jmx-metrics-$VERSION.jar opentelemetry-jmx-metrics.jar + gh release create --target $GITHUB_REF_NAME \ + --title "Version $VERSION" \ + --notes-file release-notes.txt \ + --discussion-category announcements \ + v$VERSION \ + opentelemetry-jmx-metrics.jar + + - uses: actions/checkout@v3 + with: + ref: main + # history is needed in order to generate the patch + fetch-depth: 0 + + - name: Set up git name + run: | + git config user.name opentelemetry-java-bot + git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com + + # this step should be last since it will fail if conflicting change log updates on main + - name: Create pull request to merge any change log updates to main + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git format-patch --stdout main..$GITHUB_REF_NAME CHANGELOG.md > patch + if [ -s patch ]; then + git apply patch + msg="Merge change log updates from $GITHUB_REF_NAME to main" + git commit -a -m "$msg" + git push origin HEAD:opentelemetry-java-bot/merge-change-log-updates + gh pr create --title "$msg" \ + --body "$msg" \ + --head opentelemetry-java-bot/merge-change-log-updates \ + --base main + fi diff --git a/.github/workflows/reusable-create-issue-for-failure.yml b/.github/workflows/reusable-create-issue-for-failure.yml new file mode 100644 index 00000000..78a5ee9b --- /dev/null +++ b/.github/workflows/reusable-create-issue-for-failure.yml @@ -0,0 +1,26 @@ +name: Reusable - Create issue for failure + +on: + workflow_call: + +jobs: + create-issue: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Create issue + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cat > body.txt << EOF + [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) failed. + + Please take a look and fix it ASAP. + EOF + + gh issue create --title "$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER failed" \ + --label bug \ + --label area:build \ + --label priority:p1 \ + --body-file body.txt diff --git a/.github/workflows/reusable-markdown-link-check.yml b/.github/workflows/reusable-markdown-link-check.yml new file mode 100644 index 00000000..f5152e65 --- /dev/null +++ b/.github/workflows/reusable-markdown-link-check.yml @@ -0,0 +1,21 @@ +name: Reusable - Markdown link check + +on: + workflow_call: + +jobs: + markdown-link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install markdown-link-check + run: npm install -g markdown-link-check + + - name: Run markdown-link-check + run: | + # --quiet displays errors only, making them easier to find in the log + find . -type f \ + -name '*.md' \ + -not -path './CHANGELOG.md' \ + | xargs markdown-link-check --quiet --config .github/scripts/markdown-link-check-config.json diff --git a/.github/workflows/reusable-misspell-check.yml b/.github/workflows/reusable-misspell-check.yml new file mode 100644 index 00000000..24f3a2c7 --- /dev/null +++ b/.github/workflows/reusable-misspell-check.yml @@ -0,0 +1,18 @@ +name: Reusable - Misspell check + +on: + workflow_call: + +jobs: + misspell-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install misspell + run: | + curl -L -o ./install-misspell.sh https://git.io/misspell + sh ./install-misspell.sh + + - name: Run misspell + run: bin/misspell -error . diff --git a/RELEASING.md b/RELEASING.md index 0bdb92b8..d62f25c7 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -2,55 +2,48 @@ OpenTelemetry Java Contrib uses [SemVer standard](https://semver.org) for versioning of its artifacts. -Instead of manually specifying project version (and by extension the version of built artifacts) -in gradle build scripts, we use [nebula-release-plugin](https://github.com/nebula-plugins/nebula-release-plugin) -to calculate the current version based on git tags. This plugin looks for the latest tag of the form -`vX.Y.Z` on the current branch and calculates the current project version as `vX.Y.(Z+1)-SNAPSHOT`. +The version is specified in [version.gradle.kts](version.gradle.kts). ## Snapshot builds -Every successful CI build of the master branch automatically executes `./gradlew snapshot` as the last task. -This signals Nebula plugin to build and publish to -[Sonatype OSS snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/) -next _minor_ release version. This means version `vX.(Y+1).0-SNAPSHOT`. -## Starting the Release +Every successful CI build of the main branch automatically executes `./gradlew publishToSonatype` +as the last step, which publishes a snapshot build to +[Sonatype OSS snapshots repository](https://oss.sonatype.org/content/repositories/snapshots/io/opentelemetry/contrib/). -Before making the release, merge a PR to `main` updating the `CHANGELOG.md`. -You can use the script at `buildscripts/draft-change-log-entries.sh` to help create an initial draft. -Typically only end-user facing changes are included in the change log. +## Preparing a new major or minor release -Open the [Release workflow](https://github.com/open-telemetry/opentelemetry-java-contrib/actions/workflows/release-build.yml). +* Close the release milestone if there is one. +* Merge a pull request to `main` updating the `CHANGELOG.md`. +* Run the [Prepare release branch workflow](.github/workflows/prepare-release-branch.yml). +* Review and merge the two pull requests that it creates + (one is targeted to the release branch and one is targeted to the `main` branch). -Press the "Run workflow" button, then select the release branch from the dropdown list, -e.g. `v1.9.x`, and click the "Run workflow" button below that. - -This workflow will publish the artifacts to maven central and will publish a github release with the -javaagent jar attached and release notes based on the change log. - -### Notifying other OpenTelemetry projects - -When cutting a new release, the relevant integration tests for components in other opentelemetry projects need to be updated. - -- OpenTelemetry Collector contrib JMX receiver - [Downloads latest version here](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/jmxreceiver/integration_test.go) - -## Patch Release +## Preparing a new patch release All patch releases should include only bug-fixes, and must avoid adding/modifying the public APIs. -In general, patch releases are only made for bug-fixes for the following types of issues: -* Regressions -* Memory leaks -* Deadlocks +In general, patch releases are only made for regressions, memory leaks and deadlocks. -Before making the release: +* Backport pull request(s) to the release branch + * Run the [Backport pull request workflow](.github/workflows/backport-pull-request.yml). + * Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `v1.9.x`, then enter the pull request number that you want to backport, + then click the "Run workflow" button below that. + * Review and merge the backport pull request that it generates +* Merge a pull request to the release branch updating the `CHANGELOG.md` +* Run the [Prepare patch release workflow](.github/workflows/prepare-patch-release.yml). + * Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `v1.9.x`, and click the "Run workflow" button below that. +* Review and merge the pull request that it creates -* Merge PR(s) containing the desired patches to the release branch -* Merge a PR to the release branch updating the `CHANGELOG.md` +## Making the release -Open the [Patch release workflow](https://github.com/open-telemetry/opentelemetry-java-contrib/actions/workflows/patch-release-build.yml). +Run the [Release workflow](.github/workflows/release.yml). -Press the "Run workflow" button, then select the release branch from the dropdown list, -e.g. `v1.9.x`, and click the "Run workflow" button below that. - -This workflow will publish the artifacts to maven central and will publish a github release with -release notes based on the change log. +* Press the "Run workflow" button, then select the release branch from the dropdown list, + e.g. `v1.9.x`, and click the "Run workflow" button below that. +* This workflow will publish the artifacts to maven central and will publish a GitHub release with + release notes based on the change log and with the javaagent jar attached. +* Lastly, if there were any change log updates in the release branch that need to be merged back to + the main branch, the workflow will create a pull request if the updates can be cleanly applied, + or it will fail this last step if the updates cannot be cleanly applied. diff --git a/aws-xray/README.md b/aws-xray/README.md index 37d650f7..44a7e0b1 100644 --- a/aws-xray/README.md +++ b/aws-xray/README.md @@ -7,4 +7,4 @@ This module contains a custom `IdGenerator` and `Sampler` for use with AWS X-Ray - [Anuraag Agrawal](https://github.com/anuraaga), AWS - [William Armiros](https://github.com/willarmiros), AWS -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/build.gradle.kts b/build.gradle.kts index 5c9ae8dc..2e02ae40 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,3 @@ -import nebula.plugin.release.git.opinion.Strategies import java.time.Duration plugins { @@ -8,16 +7,9 @@ plugins { id("com.github.ben-manes.versions") id("io.github.gradle-nexus.publish-plugin") - id("nebula.release") } -release { - defaultVersionStrategy = Strategies.getSNAPSHOT() -} - -nebulaRelease { - addReleaseBranchPattern("""v\d+\.\d+\.x""") -} +apply(from = "version.gradle.kts") nexusPublishing { packageGroup.set("io.opentelemetry") diff --git a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts index 9b41b862..7b922edc 100644 --- a/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/otel.publish-conventions.gradle.kts @@ -19,12 +19,6 @@ publishing { } } - if (findProperty("otel.stable") != "true") { - val versionParts = version.split('-').toMutableList() - versionParts[0] += "-alpha" - version = versionParts.joinToString("-") - } - afterEvaluate { val mavenGroupId: String? by project if (mavenGroupId != null) { @@ -68,10 +62,6 @@ publishing { } } -rootProject.tasks.named("release").configure { - finalizedBy(tasks["publishToSonatype"]) -} - // Sign only if we have a key to do so val signingKey: String? = System.getenv("GPG_PRIVATE_KEY") // Stub out entire signing block off of CI since Gradle provides no way of lazy configuration of diff --git a/jfr-streaming/README.md b/jfr-streaming/README.md index 80dd9845..e1584894 100644 --- a/jfr-streaming/README.md +++ b/jfr-streaming/README.md @@ -12,4 +12,4 @@ The main entry point is the `JfrMetrics` class in the package `io.opentelemetry. - [Jack Berg](https://github.com/jack-berg), New Relic - [Jason Plumb](https://github.com/breedx-splk), Splunk -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/jmx-metrics/README.md b/jmx-metrics/README.md index ff8fe19e..bbb37cf2 100644 --- a/jmx-metrics/README.md +++ b/jmx-metrics/README.md @@ -248,4 +248,4 @@ file contents can also be provided via stdin on startup when using `-config -` a - [Ryan Fitzpatrick](https://github.com/rmfitzpatrick), Splunk - [Sam DeHaan](https://github.com/dehaansa), ObservIQ -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/maven-extension/README.md b/maven-extension/README.md index c1f150d7..da9346da 100644 --- a/maven-extension/README.md +++ b/maven-extension/README.md @@ -186,4 +186,4 @@ The [`otel-cli`](https://github.com/equinix-labs/otel-cli) is a command line wra - [Cyrille Le Clerc](https://github.com/cyrille-leclerc), Elastic - [Ken Finnigan](https://github.com/kenfinnigan), Workday -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/runtime-attach/README.md b/runtime-attach/README.md index b83208e6..323521b1 100644 --- a/runtime-attach/README.md +++ b/runtime-attach/README.md @@ -3,4 +3,4 @@ - [Nikita Salnikov-Tarnovski](https://github.com/iNikem), Splunk - [Trask Stalnaker](https://github.com/trask), Microsoft -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/samplers/README.md b/samplers/README.md index f0bef99e..0e1721a9 100644 --- a/samplers/README.md +++ b/samplers/README.md @@ -3,4 +3,4 @@ - [Anuraag Agrawal](https://github.com/anuraaga), AWS - [Nikita Salnikov-Tarnovski](https://github.com/iNikem), Splunk -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/settings.gradle.kts b/settings.gradle.kts index 644fa097..7ab708e0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,7 +4,6 @@ pluginManagement { id("com.github.johnrengelman.shadow") version "7.1.2" id("com.gradle.enterprise") version "3.8.1" id("io.github.gradle-nexus.publish-plugin") version "1.1.0" - id("nebula.release") version "16.0.0" } } diff --git a/static-instrumenter/README.md b/static-instrumenter/README.md index b4c3b04c..af8e67c1 100644 --- a/static-instrumenter/README.md +++ b/static-instrumenter/README.md @@ -21,4 +21,4 @@ Maven3 plugin running the static instrumentation agent during the `package` phas - [Jakub Wach](https://github.com/kubawach), Splunk - [Anna Nosek](https://github.com/Enkelian), Splunk -Learn more about component owners in [component-owners.yml](../.github/workflows/component-owners.yml). +Learn more about component owners in [component_owners.yml](../.github/component_owners.yml). diff --git a/version.gradle.kts b/version.gradle.kts new file mode 100644 index 00000000..a9e23e7e --- /dev/null +++ b/version.gradle.kts @@ -0,0 +1,7 @@ +allprojects { + if (findProperty("otel.stable") != "true") { + version = "1.13.0-alpha-SNAPSHOT" + } else { + version = "1.13.0-SNAPSHOT" + } +}