From b43c5efe06c7f0bfc9e6b81559a4cea6cb55be6f Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Thu, 8 May 2025 14:44:59 -0700 Subject: [PATCH 1/9] Initial commit reconfiguring publishing steps per new migration --- .github/workflows/migrate_publish_release.yml | 54 +++++++++++++++++++ build.gradle | 2 +- .../com/nr/builder/publish/PublishConfig.java | 4 +- newrelic-java/build.gradle | 2 +- 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/migrate_publish_release.yml diff --git a/.github/workflows/migrate_publish_release.yml b/.github/workflows/migrate_publish_release.yml new file mode 100644 index 0000000000..af7bf6760c --- /dev/null +++ b/.github/workflows/migrate_publish_release.yml @@ -0,0 +1,54 @@ +name: Publish release version explicitly + +on: + workflow-dispatch: + inputs: + agent-ref: + description: "Specify agent branch/tag/sha (main is default)" + required: false + default: 'main' + +jobs: + publish_release: + runs-on: ubuntu-24.04 + steps: + - name: Checkout Agent + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # pin@v4 + with: + ref: ${{ inputs.agent-ref || 'main' }} + + - name: Setup environment + uses: ./.github/actions/setup-environment + + - name: Publish release + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS publish -x :newrelic-scala3-api:publish -x :newrelic-scala-api:publish -x :newrelic-scala-cats-api:publish -x :newrelic-cats-effect3-api:publish -x :newrelic-scala-zio-api:publish -x :newrelic-scala-zio2-api:publish -x :agent-bridge:publish -x :agent-bridge-datastore:publish -x :newrelic-weaver:publish -x :newrelic-weaver-api:publish -x :newrelic-weaver-scala:publish -x :newrelic-weaver-scala-api:publish -x :newrelic-opentelemetry-agent-extension:publish -Prelease=true + - name: Publish release scala apis + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :newrelic-scala3-api:publish :newrelic-scala-api:publish :newrelic-scala-cats-api:publish :newrelic-cats-effect3-api:publish :newrelic-scala-zio-api:publish :newrelic-scala-zio2-api:publish -Prelease=true + - name: Publish apis for Security agent + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :agent-bridge:publish :agent-bridge-datastore:publish :newrelic-weaver:publish :newrelic-weaver-api:publish :newrelic-weaver-scala:publish :newrelic-weaver-scala-api:publish -Prelease=true + - name: Publish New Relic OpenTelemetry API Extension + env: + SONATYPE_USERNAME: ${{ secrets.MIGRATION_TEST_SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.MIGRATION_TEST_SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew $GRADLE_OPTIONS :newrelic-opentelemetry-agent-extension:publish -Prelease=true diff --git a/build.gradle b/build.gradle index 38dbe795fb..3b19ddba33 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ allprojects { } } - group = 'com.newrelic.agent.java' + group = 'io.github.kanderson250.agent.java' version = agentVersion + (project.findProperty("release") == "true" ? "" : "-SNAPSHOT") version = version + (project.findProperty("release-suffix") != null ? project.findProperty("release-suffix") : "") diff --git a/buildSrc/src/main/java/com/nr/builder/publish/PublishConfig.java b/buildSrc/src/main/java/com/nr/builder/publish/PublishConfig.java index e07d4cad62..aa3a18249a 100644 --- a/buildSrc/src/main/java/com/nr/builder/publish/PublishConfig.java +++ b/buildSrc/src/main/java/com/nr/builder/publish/PublishConfig.java @@ -59,8 +59,8 @@ private static void configureSigning(Project project, MavenPublication publicati } private static void configureRepo(MavenArtifactRepository repo, String projectVersion) { - URI releasesRepoUri = URI.create("https://oss.sonatype.org/service/local/staging/deploy/maven2/"); - URI snapshotsRepoUrl = URI.create("https://oss.sonatype.org/content/repositories/snapshots/"); + URI releasesRepoUri = URI.create("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"); + URI snapshotsRepoUrl = URI.create("https://ossrh-staging-api.central.sonatype.com/content/repositories/snapshots/"); repo.setUrl( projectVersion.endsWith("SNAPSHOT") ? snapshotsRepoUrl diff --git a/newrelic-java/build.gradle b/newrelic-java/build.gradle index 1bb3a17d1e..254b4491ee 100644 --- a/newrelic-java/build.gradle +++ b/newrelic-java/build.gradle @@ -8,7 +8,7 @@ plugins { evaluationDependsOn(":newrelic-agent") -group = "com.newrelic.agent.java" +group = "io.github.kanderson250.agent.java" task dist(type: Zip, dependsOn: [ project(":newrelic-agent").newrelicVersionedAgentJar, From 7b48b39fe960e6543c63eeabcd4d84d8558adc02 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Thu, 8 May 2025 14:53:36 -0700 Subject: [PATCH 2/9] Update migration workflow typos --- .github/workflows/migrate_publish_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/migrate_publish_release.yml b/.github/workflows/migrate_publish_release.yml index af7bf6760c..ff75cde44b 100644 --- a/.github/workflows/migrate_publish_release.yml +++ b/.github/workflows/migrate_publish_release.yml @@ -1,7 +1,7 @@ -name: Publish release version explicitly +name: Test migration workflow on: - workflow-dispatch: + workflow_dispatch: inputs: agent-ref: description: "Specify agent branch/tag/sha (main is default)" From c34dd19fa46b316fd87a14d63587f52e73dbf1f8 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 17:25:02 -0700 Subject: [PATCH 3/9] Add build file checks and corresponding action --- .github/workflows/Check-Build-Files.yml | 17 ++++++++++ .../check-implementation-title.sh | 18 +++++++++++ automation/pull-request/check-verify.sh | 21 +++++++++++++ automation/pull-request/lint-build-files.sh | 31 +++++++++++++++++++ 4 files changed, 87 insertions(+) create mode 100644 .github/workflows/Check-Build-Files.yml create mode 100755 automation/pull-request/check-implementation-title.sh create mode 100755 automation/pull-request/check-verify.sh create mode 100755 automation/pull-request/lint-build-files.sh diff --git a/.github/workflows/Check-Build-Files.yml b/.github/workflows/Check-Build-Files.yml new file mode 100644 index 0000000000..17da4c53a1 --- /dev/null +++ b/.github/workflows/Check-Build-Files.yml @@ -0,0 +1,17 @@ +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + gather-changes: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b + with: + fetch-depth: 2 + + - name: Check changed files for build errors + run: | + CHANGED_FILES=$(git diff --name-only -r HEAD^1 HEAD | xargs) + ./automation/lint-build-files.sh $CHANGED_FILES \ No newline at end of file diff --git a/automation/pull-request/check-implementation-title.sh b/automation/pull-request/check-implementation-title.sh new file mode 100755 index 0000000000..c1ebb8c38c --- /dev/null +++ b/automation/pull-request/check-implementation-title.sh @@ -0,0 +1,18 @@ +#! /bin/bash + +FILE=$1 + +if [[ -z "$FILE" ]]; then + echo "Usage: $0 " + exit 1 +fi + +MODULE_NAME=$(basename "$(dirname "$FILE")") +EXPECTED_TITLE="com.newrelic.instrumentation.$MODULE_NAME" +TITLE_LINE=$(grep "'Implementation-Title':\s*'${EXPECTED_TITLE}'" "$FILE") + +#If the line is empty, fail +if ([[ -z "$TITLE_LINE" ]]); then + echo " Error: Expected $EXPECTED_TITLE in 'Implementation-Title' field but did not find it." + exit 1 +fi \ No newline at end of file diff --git a/automation/pull-request/check-verify.sh b/automation/pull-request/check-verify.sh new file mode 100755 index 0000000000..905630a822 --- /dev/null +++ b/automation/pull-request/check-verify.sh @@ -0,0 +1,21 @@ +#! /bin/bash + +FILE=$1 + +if [[ -z "$FILE" ]]; then + echo "Usage: $0 " + exit 1 +fi + +# Extract verifyInstrumentation block +block=$(awk '/verifyInstrumentation[[:space:]]*\{/,/\}/' "$FILE") + +if [[ -z "$block" ]]; then + echo " Error: verifyInstrumentation block not found." + exit 1 +fi + +if !(echo "$block" | grep -q 'passesOnly') ; then + echo " Error: passesOnly not found inside verifyInstrumentation block." + exit 1 +fi \ No newline at end of file diff --git a/automation/pull-request/lint-build-files.sh b/automation/pull-request/lint-build-files.sh new file mode 100755 index 0000000000..8944e15dcb --- /dev/null +++ b/automation/pull-request/lint-build-files.sh @@ -0,0 +1,31 @@ +#! /bin/bash + +CHANGED_FILES=$@ +MYPATH=$0 +INSTALL_DIR="`dirname ${MYPATH}`" +CHECK_TITLE="IMPLEMENTATION_TITLE_SHOULD_MATCH_MODULE_NAME" +CHECK_VERIFY_INSTRUMENTATION="VERIFY_INSTRUMENTATION_SHOULD_CONTAIN_PASSESONLY" + + +FAILURES="" +for file in $CHANGED_FILES; do + if [[ $file == *.gradle ]]; then + echo "Checking build file: $file" + /bin/sh "${INSTALL_DIR}/check-verify.sh" "$file" + if [ $? -ne 0 ]; then + FAILURES="${FAILURES} ${CHECK_VERIFY_INSTRUMENTATION}:${file} \n" + fi + /bin/sh "${INSTALL_DIR}/check-implementation-title.sh" "$file" + if [ $? -ne 0 ]; then + FAILURES="${FAILURES} ${CHECK_TITLE}:${file} \n" + fi + fi +done +echo "~~~~~~~~~~ RESULTS ~~~~~~~~~~" +if [[ -n "$FAILURES" ]]; then + echo "Build file checks failed at the following locations:" + echo -e "$FAILURES" + exit 1 +else + echo "All build files passed lint checks." +fi \ No newline at end of file From 98120a80c1a67551db6b1410ca1c7c1d12c165e3 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 17:33:04 -0700 Subject: [PATCH 4/9] Correct lint file name --- .github/workflows/Check-Build-Files.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Check-Build-Files.yml b/.github/workflows/Check-Build-Files.yml index 17da4c53a1..4a0f6bdd0e 100644 --- a/.github/workflows/Check-Build-Files.yml +++ b/.github/workflows/Check-Build-Files.yml @@ -14,4 +14,4 @@ jobs: - name: Check changed files for build errors run: | CHANGED_FILES=$(git diff --name-only -r HEAD^1 HEAD | xargs) - ./automation/lint-build-files.sh $CHANGED_FILES \ No newline at end of file + ./automation/pull-request/lint-build-files.sh $CHANGED_FILES \ No newline at end of file From 357f670e678635e40dbd01ca43ef8097d4af593e Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 17:44:20 -0700 Subject: [PATCH 5/9] Update bash script errors in build file linter --- automation/pull-request/check-implementation-title.sh | 4 ++-- automation/pull-request/check-verify.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/pull-request/check-implementation-title.sh b/automation/pull-request/check-implementation-title.sh index c1ebb8c38c..24359abd04 100755 --- a/automation/pull-request/check-implementation-title.sh +++ b/automation/pull-request/check-implementation-title.sh @@ -2,7 +2,7 @@ FILE=$1 -if [[ -z "$FILE" ]]; then +if [ -z "$FILE" ]; then echo "Usage: $0 " exit 1 fi @@ -12,7 +12,7 @@ EXPECTED_TITLE="com.newrelic.instrumentation.$MODULE_NAME" TITLE_LINE=$(grep "'Implementation-Title':\s*'${EXPECTED_TITLE}'" "$FILE") #If the line is empty, fail -if ([[ -z "$TITLE_LINE" ]]); then +if [ -z "$TITLE_LINE" ]; then echo " Error: Expected $EXPECTED_TITLE in 'Implementation-Title' field but did not find it." exit 1 fi \ No newline at end of file diff --git a/automation/pull-request/check-verify.sh b/automation/pull-request/check-verify.sh index 905630a822..b62d58b43f 100755 --- a/automation/pull-request/check-verify.sh +++ b/automation/pull-request/check-verify.sh @@ -2,7 +2,7 @@ FILE=$1 -if [[ -z "$FILE" ]]; then +if [ -z "$FILE" ]; then echo "Usage: $0 " exit 1 fi @@ -10,7 +10,7 @@ fi # Extract verifyInstrumentation block block=$(awk '/verifyInstrumentation[[:space:]]*\{/,/\}/' "$FILE") -if [[ -z "$block" ]]; then +if [ -z "$block" ]; then echo " Error: verifyInstrumentation block not found." exit 1 fi From e618f79ef3bd74df207c1ee7bdbbb4c2d9b5f3e7 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 17:49:49 -0700 Subject: [PATCH 6/9] Update script to only check instrumentation gradle files --- automation/pull-request/lint-build-files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/pull-request/lint-build-files.sh b/automation/pull-request/lint-build-files.sh index 8944e15dcb..3fe6d9bc4b 100755 --- a/automation/pull-request/lint-build-files.sh +++ b/automation/pull-request/lint-build-files.sh @@ -9,7 +9,7 @@ CHECK_VERIFY_INSTRUMENTATION="VERIFY_INSTRUMENTATION_SHOULD_CONTAIN_PASSESONLY" FAILURES="" for file in $CHANGED_FILES; do - if [[ $file == *.gradle ]]; then + if [[ $file == *instrumentation/*.gradle ]]; then echo "Checking build file: $file" /bin/sh "${INSTALL_DIR}/check-verify.sh" "$file" if [ $? -ne 0 ]; then From a0490db02f9134061081e6d527439ed53594a29d Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 17:58:10 -0700 Subject: [PATCH 7/9] Update Check-Build-Files action names --- .github/workflows/Check-Build-Files.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Check-Build-Files.yml b/.github/workflows/Check-Build-Files.yml index 4a0f6bdd0e..5b5794bae1 100644 --- a/.github/workflows/Check-Build-Files.yml +++ b/.github/workflows/Check-Build-Files.yml @@ -3,7 +3,7 @@ on: types: [opened, synchronize, reopened] jobs: - gather-changes: + check-build-files: runs-on: ubuntu-latest steps: - name: Check out the repository @@ -11,7 +11,7 @@ jobs: with: fetch-depth: 2 - - name: Check changed files for build errors + - name: Check changed files meet build linter requirements run: | CHANGED_FILES=$(git diff --name-only -r HEAD^1 HEAD | xargs) ./automation/pull-request/lint-build-files.sh $CHANGED_FILES \ No newline at end of file From 4b17e11f4c5e0639c8011372b6b76047ff5cb7c6 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 20:14:37 -0700 Subject: [PATCH 8/9] Update check build file action to use warning message --- .github/workflows/Check-Build-Files.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Check-Build-Files.yml b/.github/workflows/Check-Build-Files.yml index 5b5794bae1..8f8d649356 100644 --- a/.github/workflows/Check-Build-Files.yml +++ b/.github/workflows/Check-Build-Files.yml @@ -14,4 +14,8 @@ jobs: - name: Check changed files meet build linter requirements run: | CHANGED_FILES=$(git diff --name-only -r HEAD^1 HEAD | xargs) - ./automation/pull-request/lint-build-files.sh $CHANGED_FILES \ No newline at end of file + ./automation/pull-request/lint-build-files.sh $CHANGED_FILES + if [ $? -ne 0 ]; then + echo "::warning::Build files in this PR did not pass optional checks. Please review for accuracy! See check-build-files step for details." + fi + continue-on-error: true \ No newline at end of file From c95a5fa2fd201a11c191a241928b34c0621f9a69 Mon Sep 17 00:00:00 2001 From: Kate Anderson Date: Tue, 19 Aug 2025 20:21:25 -0700 Subject: [PATCH 9/9] Temporarily add test package --- instrumentation/my-test-package/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 instrumentation/my-test-package/build.gradle diff --git a/instrumentation/my-test-package/build.gradle b/instrumentation/my-test-package/build.gradle new file mode 100644 index 0000000000..d213a7b7e2 --- /dev/null +++ b/instrumentation/my-test-package/build.gradle @@ -0,0 +1,6 @@ + +'Implementation-Title': 'com.newrelic.instrumentation.my-bar-test-package' + +verifyInstrumentation { + passes "foo" +} \ No newline at end of file