Skip to content

Commit e57ad92

Browse files
author
Your GitHub Username
committed
build: updated vendor title
build: added release workflow
1 parent 316f980 commit e57ad92

File tree

6 files changed

+244
-14
lines changed

6 files changed

+244
-14
lines changed

.github/workflows/CHANGELOG.tpl.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
{{.SECTION}}### $title{{.SECTION}}
3+
{{.COMMITS}}- $commit{{.COMMITS}}
4+

.github/workflows/release.yml

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
name: Build and Release (Manual Run) v1.3
2+
3+
on:
4+
workflow_dispatch: # This event allows manual triggering
5+
6+
jobs:
7+
build-and-release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
17+
- name: Set up JDK 8
18+
uses: actions/setup-java@v3
19+
with:
20+
java-version: 8
21+
distribution: 'temurin'
22+
23+
24+
- name: Set Extensions Dir
25+
id: set_ext_dir
26+
run: |
27+
echo "Setting Extensions Dir..."
28+
mkdir ${HOME}/release
29+
mkdir /tmp/to
30+
echo "NEW_RELIC_EXTENSIONS_DIR=${HOME}/release" >> $GITHUB_ENV
31+
32+
- name: Build with Gradle and verifyInstrumentation
33+
run: |
34+
. ./newrelic-dependencies.sh
35+
./gradlew clean build install verifyInstrumentation
36+
37+
- name: Identify Release Type
38+
id: define_release_type
39+
run: |
40+
echo "Generating changelog to check type of release..."
41+
old_tag=$(git describe --abbrev=0 --tags 2>/dev/null) || true
42+
if [[ -n "$old_tag" ]]; then
43+
changelog=$(git log --pretty=format:"- %s (%h)" $old_tag..HEAD)
44+
fi
45+
if echo "$changelog" | grep -iqE '\bBREAKING CHANGE\b'; then
46+
echo "RELEASE_TYPE=major" >> $GITHUB_ENV
47+
elif echo "$changelog" | grep -iqE '\bfeat\b'; then
48+
echo "RELEASE_TYPE=minor" >> $GITHUB_ENV
49+
else
50+
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV
51+
fi
52+
53+
- name: Set release version
54+
id: set_release_version
55+
run: |
56+
major_version=1
57+
minor_version=0
58+
patch_revision=1
59+
60+
# Retrieve the latest release tag
61+
latest_tag=$(git describe --abbrev=0 --tags 2>/dev/null) || true
62+
echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV
63+
64+
if [[ -n "$latest_tag" && $latest_tag == v* ]]; then
65+
# Extract the major and minor versions from the latest tag
66+
current_major_version=$(echo $latest_tag | cut -d'.' -f1 | sed 's/v//')
67+
current_minor_version=$(echo $latest_tag | cut -d'.' -f2)
68+
current_patch_revision=$(echo $latest_tag | cut -d'.' -f3)
69+
70+
if [ "${{ env.RELEASE_TYPE }}" = "major" ]; then
71+
major_version=$((current_major_version +1 ))
72+
elif [ "${{ env.RELEASE_TYPE }}" = "minor" ]; then
73+
minor_version=$((current_minor_version + 1))
74+
major_version=$((current_major_version))
75+
else
76+
patch_revision=$((current_patch_revision + 1))
77+
minor_version=$((current_minor_version))
78+
major_version=$((current_major_version))
79+
fi
80+
81+
fi
82+
83+
# Set the release version environment variable
84+
release_version="v${major_version}.${minor_version}.${patch_revision}"
85+
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV
86+
87+
- name: Set Tag
88+
id: set_tag
89+
run: echo "::set-output name=tag::${{ env.RELEASE_VERSION }}"
90+
91+
- name: Set release name
92+
id: set_release_name
93+
run: |
94+
repo_name="${{ github.repository }}"
95+
sanitized_repo_name=$(echo "$repo_name" | awk -F 'newrelic-java-' '{print $2}')
96+
echo "RELEASE_NAME=${sanitized_repo_name}-instrumentation-" >> $GITHUB_ENV
97+
previous_tag=$(git describe --abbrev=0 --tags HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)
98+
99+
- name: Create Archive
100+
run: |
101+
echo "CURRENT=${PWD}" >> $GITHUB_ENV
102+
cd ${HOME}/release
103+
zip -r /tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip *.jar
104+
cd ${{env.CURRENT}}
105+
106+
107+
108+
- name: Create Release
109+
id: create_release
110+
uses: actions/github-script@v6
111+
with:
112+
github-token: ${{ secrets.GITHUB_TOKEN }}
113+
script: |
114+
try {
115+
var changelog = ``;
116+
var tag = '' + `${{ steps.set_tag.outputs.tag }}`;
117+
const archivePath = '/tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip';
118+
var response = await github.rest.repos.createRelease({
119+
draft:false,
120+
generate_release_notes:true,
121+
name:tag,
122+
owner:context.repo.owner,
123+
prerelease:false,
124+
repo:context.repo.repo,
125+
tag_name:tag,
126+
body:changelog
127+
});
128+
129+
core.exportVariable('RELEASE_ID', response.data.id);
130+
core.exportVariable('RELEASE_URL', response.data.html_url);
131+
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
132+
} catch (error) {
133+
core.setFailed(error.message);
134+
}
135+
- name: Upload Release Artifacts
136+
uses: actions/upload-release-asset@v1
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
with:
140+
asset_path: /tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip
141+
asset_name: ${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip
142+
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
143+
asset_content_type: application/zip
144+
145+
- name: "Generate release changelog"
146+
id: github_changelog
147+
uses: Helmisek/conventional-changelog-generator@v1.0.6-release
148+
with:
149+
repo-token: ${{ secrets.GITHUB_TOKEN }}
150+
commit-types: "fix:Bug Fixes,feat:Features,doc:Documentation,build:Build Upgrades,BREAKING CHANGE:Enhancements"
151+
template-path: ".github/workflows/CHANGELOG.tpl.md"
152+
153+
154+
- name: update CHANGELOG.md
155+
run: |
156+
# Content to add at the top
157+
# Get the current date in YYYY-MM-DD format
158+
release_date=$(date +"%Y-%m-%d")
159+
version="## Version: [${{env.RELEASE_VERSION}}](${{ env.RELEASE_URL }}) | Created: $release_date"
160+
content="$version${{steps.github_changelog.outputs.changelog}}"
161+
162+
# Existing file
163+
file="CHANGELOG.md"
164+
165+
# Create a temporary file with the content at the top and existing content below
166+
167+
echo "$content" > temp_file.txt
168+
cat "$file" >> temp_file.txt
169+
170+
# Overwrite the original file with the updated content
171+
mv temp_file.txt "$file"
172+
173+
# Commit the updated CHANGELOG.md file
174+
git add CHANGELOG.md
175+
git config --local user.email "action@github.com"
176+
git config --local user.name "GitHub Action"
177+
git commit -m "Update Changelog for Release [skip ci]"
178+
179+
# Push the changes to the remote repository
180+
git push --quiet --set-upstream origin HEAD
181+
182+
- name: Get Compare URL
183+
run: |
184+
compare=$(echo ${{ env.RELEASE_URL }} | sed 's/releases\/tag.*/compare/')
185+
compareurl=$(echo "\nFull Changelog: ($compare/${{ env.LATEST_TAG }}...${{ steps.set_tag.outputs.tag }})")
186+
echo "COMPAREURL=${compareurl}" >> $GITHUB_ENV
187+
188+
- name: Update Release
189+
id: update_release
190+
uses: actions/github-script@v6
191+
with:
192+
github-token: ${{ secrets.GITHUB_TOKEN }}
193+
script: |
194+
try {
195+
196+
197+
var changelog = `${{steps.github_changelog.outputs.changelog}}` + `${{env.COMPAREURL}}` ;
198+
var release_id = `${{env.RELEASE_ID}}`;
199+
var tag = '' + `${{ steps.set_tag.outputs.tag }}`;
200+
const archivePath = '/tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip';
201+
var _response = await github.rest.repos.updateRelease({
202+
draft:false,
203+
generate_release_notes:true,
204+
owner:context.repo.owner,
205+
repo: context.repo.repo,
206+
prerelease:false,
207+
release_id:release_id,
208+
body:changelog
209+
});
210+
211+
core.exportVariable('RELEASE_ID', _response.data.id);
212+
core.exportVariable('RELEASE_URL', _response.data.html_url);
213+
core.exportVariable('RELEASE_UPLOAD_URL', _response.data.upload_url);
214+
} catch (error) {
215+
core.setFailed(error.message);
216+
}
217+

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## Installation
2+
3+
To install:
4+
5+
1. Download the latest release jar files.
6+
2. In the New Relic Java directory (the one containing newrelic.jar), create a directory named extensions if it does not already exist.
7+
3. Copy the downloaded jars into the extensions directory.
8+
4. Restart the application.
9+

build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121
}
2222

2323
project.ext {
24-
group = 'com.newrelic.instrumentation'
24+
group = 'com.newrelic.instrumentation.labs'
2525
javaAgentVersion = '6.4.0'
2626

2727
// Aligned with minimum Java major version supported by latest Java Agent
@@ -76,7 +76,7 @@ task buildIfNeeded {
7676
task createModule {
7777
dependsOn checkForDependencies
7878
description = 'Generate project files for a new instrumentation module'
79-
group = 'New Relic'
79+
group = 'New Relic Labs'
8080
doLast {
8181

8282
def rootProject = projectDir.path
@@ -119,7 +119,7 @@ task createModule {
119119
// Example:
120120
// implementation 'javax.servlet:servlet-api:2.5'
121121
122-
// New Relic Java Agent dependencies
122+
// New Relic Labs Java Agent dependencies
123123
implementation 'com.newrelic.agent.java:newrelic-agent:JAVA_AGENT_VERSION'
124124
implementation 'com.newrelic.agent.java:newrelic-api:JAVA_AGENT_VERSION'
125125
implementation fileTree(include: ['*.jar'], dir: '../libs')
@@ -129,8 +129,8 @@ task createModule {
129129
jar {
130130
manifest {
131131
attributes 'Implementation-Title': 'PROJECT_GROUP.PROJECT_NAME'
132-
attributes 'Implementation-Vendor': 'New Relic'
133-
attributes 'Implementation-Vendor-Id': 'com.newrelic'
132+
attributes 'Implementation-Vendor': 'New Relic Labs'
133+
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
134134
attributes 'Implementation-Version': 1.0
135135
}
136136
}
@@ -175,7 +175,7 @@ subprojects {
175175

176176
task install(dependsOn: buildIfNeeded, type: Copy) {
177177
description = 'Copies compiled jar to the NEW_RELIC_EXTENSIONS_DIR.'
178-
group = 'New Relic'
178+
group = 'New Relic Labs'
179179

180180
def extDir = System.getenv("NEW_RELIC_EXTENSIONS_DIR") ?: " "
181181

ws-rs-errors-2.0/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'java'
66
dependencies {
77
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.5'
88

9-
// New Relic Java Agent dependencies
9+
// New Relic Labs Java Agent dependencies
1010
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0'
1111
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0'
1212
implementation fileTree(include: ['*.jar'], dir: '../libs')
@@ -15,9 +15,9 @@ dependencies {
1515

1616
jar {
1717
manifest {
18-
attributes 'Implementation-Title': 'com.newrelic.instrumentation.ws-rs-errors-2.0'
19-
attributes 'Implementation-Vendor': 'New Relic'
20-
attributes 'Implementation-Vendor-Id': 'com.newrelic'
18+
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.ws-rs-errors-2.0'
19+
attributes 'Implementation-Vendor': 'New Relic Labs'
20+
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
2121
attributes 'Implementation-Version': 1.0
2222
}
2323
}

ws-rs-errors-3.0/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ apply plugin: 'java'
66
dependencies {
77
implementation 'jakarta.ws.rs:jakarta.ws.rs-api:3.0.0'
88

9-
// New Relic Java Agent dependencies
9+
// New Relic Labs Java Agent dependencies
1010
implementation 'com.newrelic.agent.java:newrelic-agent:6.4.0'
1111
implementation 'com.newrelic.agent.java:newrelic-api:6.4.0'
1212
implementation fileTree(include: ['*.jar'], dir: '../libs')
@@ -15,9 +15,9 @@ dependencies {
1515

1616
jar {
1717
manifest {
18-
attributes 'Implementation-Title': 'com.newrelic.instrumentation.ws-rs-errors-3.0'
19-
attributes 'Implementation-Vendor': 'New Relic'
20-
attributes 'Implementation-Vendor-Id': 'com.newrelic'
18+
attributes 'Implementation-Title': 'com.newrelic.instrumentation.labs.ws-rs-errors-3.0'
19+
attributes 'Implementation-Vendor': 'New Relic Labs'
20+
attributes 'Implementation-Vendor-Id': 'com.newrelic.labs'
2121
attributes 'Implementation-Version': 1.0
2222
}
2323
}

0 commit comments

Comments
 (0)