Skip to content

Commit

Permalink
Merge pull request #30 from appoptics/NH-3952-gh-actions
Browse files Browse the repository at this point in the history
NH-3952: Github Actions
  • Loading branch information
jiwen624 authored Feb 23, 2022
2 parents 889095f + 5636d5b commit 36bde56
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 39 deletions.
46 changes: 27 additions & 19 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

# This workflow builds the NightHawk agent, run the tests, then publish a new release.
# You'll need to bump the version by modifying `ext.versions.agent` property in the build.gradle file
# then manually run this workflow to cut off a new release. The release name will be in the form of
# "v+versionNumber". For example, if `ext.versions.agent` = 0.5.1, the release name will be "v0.5.1".
name: Java CI with Gradle

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
checkout-ref:
description: branch, tag or SHA to checkout. defaults to ref or SHA of triggering event.

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref_name }}
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle
uses: gradle/gradle-build-action@bc3340afc5e3cc44f2321809ac090d731c13c514
- name: Build with Gradle and Publish
uses: gradle/gradle-build-action@v2
with:
arguments: build
arguments: publish
env:
# These two secrets `secrets.GP_USERNAME` and `secrets.GP_TOKEN` are Github's PAT (Personal Access Token),
# which are used to download private packages from Github Packages (in our case, the Joboe core libs from https://github.com/librato/joboe)
# Gradle fetches the dependencies from Github Packages with this user/token pair, see build.gradle for the repositories config.
#
# Currently the PAT is set up under the trace-build service account and just requires read:packages access to the Librato org.
# (Check out this document about how to create a PAT: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
GP_USERNAME: ${{ secrets.GP_USERNAME }}
GP_TOKEN: ${{ secrets.GP_TOKEN }}
# GITHUB_TOKEN is used to publish the build artifacts (the NightHawk agent) to Github Packages.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set agent version env
run: |
echo "AGENT_VERSION=v$(cd agent/build/libs && unzip -p solarwinds-apm-agent-all.jar META-INF/MANIFEST.MF | grep Implementation-Version | awk '{ print $2 }')" >> $GITHUB_ENV
- name: Release and upload artifacts
run: gh release create ${{ env.AGENT_VERSION }} --title "${{ env.AGENT_VERSION }}" --target ${{ github.ref_name }} --draft agent/build/libs/*.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This workflow is triggered either by a push or by manually clicking `Run Workflow` in the Actions page.
# The purpose of the workflow is to build the agent and run the tests.

name: Push

on:
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref_name }}
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
- name: Build with Gradle and Test
uses: gradle/gradle-build-action@v2
with:
arguments: test
env:
GP_USERNAME: ${{ secrets.GP_USERNAME }}
GP_TOKEN: ${{ secrets.GP_TOKEN }}
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
# explicitly list all the build directories instead of an asterisk (**/build/) to avoid possible unwanted match
/instrumentation/build/
/agent/build/
/appoptics-opentelemetry-sdk-shaded/build/
/appoptics-opentelemetry-sdk/build/
/buildSrc/build/
/core-bootstrap/build/
/custom/build/
/instrumentation/appoptics-annotation/build/
/instrumentation/jdbc/build/
/instrumentation/spring/build/
/instrumentation/spring/spring-webmvc-3.1/build/
/sdk-extensions-bootstrap/build/
/sdk-extensions/build/
**/build/
**/*.log
.gradle/
.DS_Store
22 changes: 22 additions & 0 deletions agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id("com.github.johnrengelman.shadow") version "6.0.0"
id 'maven-publish'
}

apply from: "$rootDir/gradle/shadow.gradle"
Expand Down Expand Up @@ -62,3 +63,24 @@ tasks {
dependsOn(shadowJar)
}
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'com.solarwinds.agent'
artifactId = "${archivesBaseName}"
version = "${versions.agent}"
from components.java
}
}
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/appoptics/opentelemetry-java-instrumentation-custom-distro"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
17 changes: 11 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
group = "com.solarwinds"
group = "com.solarwinds.agent"

subprojects {
version = rootProject.version

apply plugin: "java"
apply plugin: "muzzle"
apply plugin: "checkstyle"
Expand All @@ -13,9 +11,9 @@ subprojects {
opentelemetryJavaagent: "1.7.2",
bytebuddy : "1.10.18",
guava : "30.1-jre",
appopticsCore : "7.0.3",
appopticsMetrics : "7.0.0",
agent : "0.5.0" // the custom distro agent version
appopticsCore : "7.0.4",
appopticsMetrics : "7.0.4",
agent : "0.5.1" // the custom distro agent version
]
versions.opentelemetryAlpha = "${versions.opentelemetry}-alpha"
versions.opentelemetryJavaagentAlpha = "${versions.opentelemetryJavaagent}-alpha"
Expand All @@ -36,6 +34,13 @@ subprojects {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven {
url = uri("https://maven.pkg.github.com/librato/joboe")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GP_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GP_TOKEN")
}
}
mavenLocal()
mavenCentral()
}
Expand Down

0 comments on commit 36bde56

Please sign in to comment.