diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d9392ff6..77058028 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -22,9 +22,16 @@ env: SWO_EMAIL: ${{ secrets.SWO_EMAIL }} SWO_PWORD: ${{ secrets.SWO_PWORD }} STAGE_BUCKET: ${{ secrets.STAGE_BUCKET }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_TOKEN: ${{ secrets.SONATYPE_TOKEN }} + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }} jobs: s3-stage-upload: # this job uploads the jar to stage s3 + needs: + - maven_snapshot_release runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -309,6 +316,12 @@ jobs: java-version: '17' distribution: 'temurin' + - name: Set agent version env + run: | + ./gradlew build -x test + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + echo "AGENT_VERSION=$(cd agent/build/libs && unzip -p solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }' | sed 's/[^a-z0-9.-]//g').$GIT_HASH" >> $GITHUB_ENV + - name: Run application working-directory: smoke-tests run: | @@ -420,3 +433,28 @@ jobs: - name: Docker logout if: always() run: docker logout + + maven_snapshot_release: + runs-on: ubuntu-latest + env: + SNAPSHOT_BUILD: true + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Set agent version env + run: | + ./gradlew build -x test + GIT_HASH=$(git rev-parse --short "$GITHUB_SHA") + echo "AGENT_VERSION=$(cd agent/build/libs && unzip -p solarwinds-apm-agent.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }' | sed 's/[^a-z0-9.-]//g').$GIT_HASH" >> $GITHUB_ENV + + - name: Publish + run: ./gradlew publish \ No newline at end of file diff --git a/smoke-tests/netty-test/build.gradle.kts b/smoke-tests/netty-test/build.gradle.kts index 73924ce2..1aa49269 100644 --- a/smoke-tests/netty-test/build.gradle.kts +++ b/smoke-tests/netty-test/build.gradle.kts @@ -1,3 +1,5 @@ +import java.net.URI + /* * © SolarWinds Worldwide, LLC. All rights reserved. * @@ -25,10 +27,19 @@ version = "unspecified" repositories { mavenCentral() + maven { + url = URI.create("https://s01.oss.sonatype.org/content/repositories/snapshots/") + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_TOKEN") + } + } } +val sdkVersion = System.getenv("AGENT_VERSION") ?: "2.6.0" dependencies { implementation("io.netty:netty-common:4.1.94.Final") + implementation("io.github.appoptics:solarwinds-otel-sdk:$sdkVersion-SNAPSHOT") testImplementation(platform("org.junit:junit-bom:5.9.1")) testImplementation("org.junit.jupiter:junit-jupiter") } @@ -38,7 +49,6 @@ tasks.test { } val swoAgentPath = project.buildDir.toString() + "/swo/solarwinds-apm-agent.jar" - fun getAgentPath(downloadPath: String) = if (System.getenv("AGENT_PATH") == null) downloadPath else System.getenv("AGENT_PATH") diff --git a/smoke-tests/netty-test/src/main/java/com/solarwinds/netty/NettyApp.java b/smoke-tests/netty-test/src/main/java/com/solarwinds/netty/NettyApp.java index cde783c6..4086bbe7 100644 --- a/smoke-tests/netty-test/src/main/java/com/solarwinds/netty/NettyApp.java +++ b/smoke-tests/netty-test/src/main/java/com/solarwinds/netty/NettyApp.java @@ -17,11 +17,13 @@ package com.solarwinds.netty; import io.netty.util.NetUtil; +import com.solarwinds.api.ext.SolarwindsAgent; import java.util.concurrent.TimeUnit; public class NettyApp { public static void main(String[] args){ + SolarwindsAgent.setTransactionName("hello world!"); System.out.printf("Number of interfaces: %d%n",NetUtil.NETWORK_INTERFACES.size()); try { TimeUnit.MINUTES.sleep(1); diff --git a/solarwinds-otel-sdk/build.gradle b/solarwinds-otel-sdk/build.gradle index 793010b4..0211530a 100644 --- a/solarwinds-otel-sdk/build.gradle +++ b/solarwinds-otel-sdk/build.gradle @@ -83,9 +83,12 @@ publishing { name = 'Apache License, Version 2.0' } } + groupId = 'io.github.appoptics' artifactId = "${archivesBaseName}" - version = "${versions.agent}" + def sdkVersion = System.getenv("AGENT_VERSION") ?: "2.6.0" + version = Boolean.parseBoolean(System.getenv("SNAPSHOT_BUILD")) ? "$sdkVersion-SNAPSHOT" : "${versions.agent}" + from components.java artifact sourcesJar artifact javadocJar @@ -93,10 +96,14 @@ publishing { } publishToMavenLocal } + repositories { maven { name = "OSSRH" - url = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/" + + url = Boolean.parseBoolean(System.getenv("SNAPSHOT_BUILD")) ? snapshotsRepoUrl : releasesRepoUrl credentials { username = System.getenv("SONATYPE_USERNAME") password = System.getenv("SONATYPE_TOKEN") @@ -115,7 +122,6 @@ signing { sign publishing.publications.mavenJava } - test { useJUnitPlatform() testLogging {