Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dhilpipre authored Nov 9, 2023
0 parents commit f79a0ec
Show file tree
Hide file tree
Showing 20 changed files with 1,212 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Describe a scenario in which this project behaves unexpectedly
title: ''
labels: bug, needs-triage
assignees: ''

---

[NOTE]: # ( ^^ Provide a general summary of the issue in the title above. ^^ )

## Description

[NOTE]: # ( Describe the problem you're encountering. )
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )

## Steps to Reproduce

[NOTE]: # ( Please be as specific as possible. )

## Expected Behavior

[NOTE]: # ( Tell us what you expected to happen. )

## Relevant Logs / Console output

[NOTE]: # ( Please provide specifics of the local error logs, Browser Dev Tools console, etc. if appropriate and possible. )

## Your Environment

[TIP]: # ( Include as many relevant details about your environment as possible. )

* ex: Browser name and version:
* ex: Operating System and version:

## Additional context

[TIP]: # ( Add any other context about the problem here. )
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Enhancement request
about: Suggest an idea for a future version of this project
title: ''
labels: enhancement, needs-triage
assignees: ''

---

[NOTE]: # ( ^^ Provide a general summary of the request in the title above. ^^ )

## Summary

[NOTE]: # ( Provide a brief overview of what the new feature is all about. )

## Desired Behavior

[NOTE]: # ( Tell us how the new feature should work. Be specific. )
[TIP]: # ( Do NOT give us access or passwords to your New Relic account or API keys! )

## Possible Solution

[NOTE]: # ( Not required. Suggest how to implement the addition or change. )

## Additional context

[TIP]: # ( Why does this feature matter to you? What unique circumstances do you have? )
3 changes: 3 additions & 0 deletions .github/workflows/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

{{.SECTION}}### $title{{.SECTION}}
{{.COMMITS}}- $commit{{.COMMITS}}
216 changes: 216 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Build and Release (Manual Run) v1.3

on:
workflow_dispatch: # This event allows manual triggering

jobs:
build-and-release:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0


- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'temurin'


- name: Set Extensions Dir
id: set_ext_dir
run: |
echo "Setting Extensions Dir..."
mkdir ${HOME}/release
mkdir /tmp/to
echo "NEW_RELIC_EXTENSIONS_DIR=${HOME}/release" >> $GITHUB_ENV
- name: Build with Gradle and verifyInstrumentation
run: |
. ./newrelic-dependencies.sh
./gradlew clean build install verifyInstrumentation
- name: Identify Release Type
id: define_release_type
run: |
echo "Generating changelog to check type of release..."
old_tag=$(git describe --abbrev=0 --tags 2>/dev/null) || true
if [[ -n "$old_tag" ]]; then
changelog=$(git log --pretty=format:"- %s (%h)" $old_tag..HEAD)
fi
if echo "$changelog" | grep -iqE '\bBREAKING CHANGE\b'; then
echo "RELEASE_TYPE=major" >> $GITHUB_ENV
elif echo "$changelog" | grep -iqE '\bfeat\b'; then
echo "RELEASE_TYPE=minor" >> $GITHUB_ENV
else
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV
fi
- name: Set release version
id: set_release_version
run: |
major_version=1
minor_version=0
patch_revision=0
# Retrieve the latest release tag
latest_tag=$(git describe --abbrev=0 --tags 2>/dev/null) || true
echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV
if [[ -n "$latest_tag" && $latest_tag == v* ]]; then
# Extract the major and minor versions from the latest tag
current_major_version=$(echo $latest_tag | cut -d'.' -f1 | sed 's/v//')
current_minor_version=$(echo $latest_tag | cut -d'.' -f2)
current_patch_revision=$(echo $latest_tag | cut -d'.' -f3)
if [ "${{ env.RELEASE_TYPE }}" = "major" ]; then
major_version=$((current_major_version +1 ))
elif [ "${{ env.RELEASE_TYPE }}" = "minor" ]; then
minor_version=$((current_minor_version + 1))
major_version=$((current_major_version))
else
patch_revision=$((current_patch_revision + 1))
minor_version=$((current_minor_version))
major_version=$((current_major_version))
fi

fi

# Set the release version environment variable
release_version="v${major_version}.${minor_version}.${patch_revision}"
echo "RELEASE_VERSION=${release_version}" >> $GITHUB_ENV

- name: Set Tag
id: set_tag
run: echo "::set-output name=tag::${{ env.RELEASE_VERSION }}"

- name: Set release name
id: set_release_name
run: |
repo_name="${{ github.repository }}"
sanitized_repo_name=$(echo "$repo_name" | awk -F 'newrelic-java-' '{print $2}')
echo "RELEASE_NAME=${sanitized_repo_name}-instrumentation-" >> $GITHUB_ENV
previous_tag=$(git describe --abbrev=0 --tags HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)
- name: Create Archive
run: |
echo "CURRENT=${PWD}" >> $GITHUB_ENV
cd ${HOME}/release
zip -r /tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip *.jar
cd ${{env.CURRENT}}

- name: Create Release
id: create_release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
var changelog = ``;
var tag = '' + `${{ steps.set_tag.outputs.tag }}`;
const archivePath = '/tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip';
var response = await github.rest.repos.createRelease({
draft:false,
generate_release_notes:true,
name:tag,
owner:context.repo.owner,
prerelease:false,
repo:context.repo.repo,
tag_name:tag,
body:changelog
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_URL', response.data.html_url);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
- name: Upload Release Artifacts
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: /tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip
asset_name: ${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_content_type: application/zip

- name: "Generate release changelog"
id: github_changelog
uses: Helmisek/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
commit-types: "fix:Bug Fixes,feat:Features,doc:Documentation,build:Build Upgrades,BREAKING CHANGE:Enhancements"
template-path: ".github/workflows/CHANGELOG.tpl.md"


- name: update CHANGELOG.md
run: |
# Content to add at the top
# Get the current date in YYYY-MM-DD format
release_date=$(date +"%Y-%m-%d")
version="## Version: [${{env.RELEASE_VERSION}}](${{ env.RELEASE_URL }}) | Created: $release_date"
content="$version${{steps.github_changelog.outputs.changelog}}"
# Existing file
file="CHANGELOG.md"
# Create a temporary file with the content at the top and existing content below
echo "$content" > temp_file.txt
cat "$file" >> temp_file.txt
# Overwrite the original file with the updated content
mv temp_file.txt "$file"
# Commit the updated CHANGELOG.md file
git add CHANGELOG.md
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update Changelog for Release [skip ci]"
# Push the changes to the remote repository
git push --quiet --set-upstream origin HEAD
- name: Get Compare URL
run: |
compare=$(echo ${{ env.RELEASE_URL }} | sed 's/releases\/tag.*/compare/')
compareurl=$(echo "\nFull Changelog: ($compare/${{ env.LATEST_TAG }}...${{ steps.set_tag.outputs.tag }})")
echo "COMPAREURL=${compareurl}" >> $GITHUB_ENV
- name: Update Release
id: update_release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
var changelog = `${{steps.github_changelog.outputs.changelog}}` + `${{env.COMPAREURL}}` ;
var release_id = `${{env.RELEASE_ID}}`;
var tag = '' + `${{ steps.set_tag.outputs.tag }}`;
const archivePath = '/tmp/to/${{ env.RELEASE_NAME}}${{ steps.set_tag.outputs.tag }}.zip';
var _response = await github.rest.repos.updateRelease({
draft:false,
generate_release_notes:true,
owner:context.repo.owner,
repo: context.repo.repo,
prerelease:false,
release_id:release_id,
body:changelog
});
core.exportVariable('RELEASE_ID', _response.data.id);
core.exportVariable('RELEASE_URL', _response.data.html_url);
core.exportVariable('RELEASE_UPLOAD_URL', _response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
31 changes: 31 additions & 0 deletions .github/workflows/repolinter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# NOTE: This file should always be named `repolinter.yml` to allow
# workflow_dispatch to work properly
name: Repolinter Action

# NOTE: This workflow will ONLY check the default branch!
# Currently there is no elegant way to specify the default
# branch in the event filtering, so branches are instead
# filtered in the "Test Default Branch" step.
on: [push, workflow_dispatch]

jobs:
repolint:
name: Run Repolinter
runs-on: ubuntu-latest
steps:
- name: Test Default Branch
id: default-branch
uses: actions/github-script@v2
with:
script: |
const data = await github.repos.get(context.repo)
return data.data && data.data.default_branch === context.ref.split('/').slice(-1)[0]
- name: Checkout Self
if: ${{ steps.default-branch.outputs.result == 'true' }}
uses: actions/checkout@v2
- name: Run Repolinter
if: ${{ steps.default-branch.outputs.result == 'true' }}
uses: newrelic/repolinter-action@v1
with:
config_url: https://raw.githubusercontent.com/newrelic/.github/main/repolinter-rulesets/new-relic-experimental.yml
output_type: issue
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.java-version
.git
.github
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Installation

To install:

1. Download the latest release jar files.
2. In the New Relic Java directory (the one containing newrelic.jar), create a directory named extensions if it does not already exist.
3. Copy the downloaded jars into the extensions directory.
4. Restart the application.
30 changes: 30 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Contributing

Contributions are always welcome. Before contributing please read the
[code of conduct](./CODE_OF_CONDUCT.md) and [search the issue tracker](issues); your issue may have already been discussed or fixed in `main`. To contribute,
[fork](https://help.github.com/articles/fork-a-repo/) this repository, commit your changes, and [send a Pull Request](https://help.github.com/articles/using-pull-requests/).

Note that our [code of conduct](./CODE_OF_CONDUCT.md) applies to all platforms and venues related to this project; please follow it in all your interactions with the project and its participants.

## Feature Requests

Feature requests should be submitted in the [Issue tracker](../../issues), with a description of the expected behavior & use case, where they’ll remain closed until sufficient interest, [e.g. :+1: reactions](https://help.github.com/articles/about-discussions-in-issues-and-pull-requests/), has been [shown by the community](../../issues?q=label%3A%22votes+needed%22+sort%3Areactions-%2B1-desc).
Before submitting an Issue, please search for similar ones in the
[closed issues](../../issues?q=is%3Aissue+is%3Aclosed+label%3Aenhancement).

## Pull Requests

1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
2. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
3. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.

## Contributor License Agreement

Keep in mind that when you submit your Pull Request, you'll need to sign the CLA via the click-through using CLA-Assistant. If you'd like to execute our corporate CLA, or if you have any questions, please drop us an email at [email protected].

For more information about CLAs, please check out Alex Russell’s excellent post,
[“Why Do I Need to Sign This?”](https://infrequently.org/2008/06/why-do-i-need-to-sign-this/).

## Slack

We host a public Slack with a dedicated channel for contributors and maintainers of open source projects hosted by New Relic. If you are contributing to this project, you're welcome to request access to the #oss-contributors channel in the newrelicusers.slack.com workspace. To request access, see https://newrelicusers-signup.herokuapp.com/.
Loading

0 comments on commit f79a0ec

Please sign in to comment.