From 146103c3d4379f3a14afae3a49ea5b7bb8c33841 Mon Sep 17 00:00:00 2001 From: hramadan Date: Fri, 17 Mar 2023 16:07:24 -0700 Subject: [PATCH 01/23] WIP: initial script yeehaw --- .github/workflows/scripts/parse_changelog.rb | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/scripts/parse_changelog.rb diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb new file mode 100644 index 0000000000..f932166227 --- /dev/null +++ b/.github/workflows/scripts/parse_changelog.rb @@ -0,0 +1,49 @@ +#!/usr/bin/ruby +# This file is distributed under New Relic's license terms. +# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. +# frozen_string_literal: true + +require 'date' +require_relative '../../../lib/new_relic/version' + +DIVIDER = '---' +SUPPRORT_STATEMENT = " +We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version at most 90 days old. Read more about [keeping agent up to date](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/). + +See the New Relic Ruby agent [EOL policy](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-eol-policy/) for information about agent releases and support dates. +" + +changelog = File.read('CHANGELOG.md') +latest_entry = changelog.split('##')[1].prepend('##') +titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten + +metadata = Hash.new { |h, k| h[k] = [] } +titles.each do |t| + category = t.split(':').first + case category + when 'Feature' + metadata[:feature] << t.delete_prefix('Feature: ') + when 'Bugfix' + metadata[:bugs] << t.delete_prefix('Bugfix: ') + when 'Security' + metadata[:securtiy] << t.delete_prefix('Security: ') + end +end + +frontmatter = [ + DIVIDER, + 'subject: Ruby agent', + "date: #{Date.today}", + "version: #{NewRelic::VERSION::STRING}", + "downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem", + "features: #{metadata[:feature]}", + "bugs: #{metadata[:bugs]}", + "security: #{metadata[:securtiy]}", + DIVIDER, + '', + SUPPRORT_STATEMENT, + '', + latest_entry +] + +File.write("ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From df0025ff75e77ecef51e60b4b93e70526325209a Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 13:58:01 -0700 Subject: [PATCH 02/23] Test: GHA release note run --- .github/workflows/generate_release_notes.yml | 34 ++++++++++++++++++++ .github/workflows/scripts/parse_changelog.rb | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/generate_release_notes.yml diff --git a/.github/workflows/generate_release_notes.yml b/.github/workflows/generate_release_notes.yml new file mode 100644 index 0000000000..23bae983bc --- /dev/null +++ b/.github/workflows/generate_release_notes.yml @@ -0,0 +1,34 @@ +name: Generate Release Notes +on: + workflow_dispatch: + +jobs: + createPullRequest: + runs-on: ubuntu-latest + steps: + - uses: ruby/setup-ruby@v1.90.0 + with: + ruby-version: 3.1 + - uses: actions/checkout + # - uses: actions/checkout@v3 + - name: Make changes to pull request + run: ruby .github/workflows/scripts/parse_changelog.rb + + - name: Create Pull Request + id: cpr + # uses: peter-evans/create-pull-request@v4 + uses: peter-evans/create-pull-request + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: https://github.com/hannahramadan/docs-website + add-paths: /src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ + commit-message: "chore(ruby agent): Ruby release notes" + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + signoff: false + branch: ruby-release-notes + delete-branch: true + title: 'Ruby Release Notes' + body: | + Ruby release notes. This is an automated PR. + draft: true diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index f932166227..0c0a8668ef 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -46,4 +46,4 @@ latest_entry ] -File.write("ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) +File.write("/src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From 6f2c5aabc0e56bf326db050e53a7aa64c97c619f Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:00:10 -0700 Subject: [PATCH 03/23] Udpate workflow path --- .github/workflows/generate_release_notes.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/generate_release_notes.yml b/.github/workflows/generate_release_notes.yml index 23bae983bc..72553fb762 100644 --- a/.github/workflows/generate_release_notes.yml +++ b/.github/workflows/generate_release_notes.yml @@ -9,15 +9,13 @@ jobs: - uses: ruby/setup-ruby@v1.90.0 with: ruby-version: 3.1 - - uses: actions/checkout - # - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - name: Make changes to pull request run: ruby .github/workflows/scripts/parse_changelog.rb - name: Create Pull Request id: cpr - # uses: peter-evans/create-pull-request@v4 - uses: peter-evans/create-pull-request + uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} path: https://github.com/hannahramadan/docs-website From c20cc2847bec86bc0454ad26b1460ad63e974c50 Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:03:34 -0700 Subject: [PATCH 04/23] Run on PR --- .github/workflows/generate_release_notes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate_release_notes.yml b/.github/workflows/generate_release_notes.yml index 72553fb762..d1ee4aa134 100644 --- a/.github/workflows/generate_release_notes.yml +++ b/.github/workflows/generate_release_notes.yml @@ -1,6 +1,6 @@ name: Generate Release Notes on: - workflow_dispatch: + pull_request: jobs: createPullRequest: From 1c5c5c5e786052dae19d8e578bea3c431e36525f Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:08:11 -0700 Subject: [PATCH 05/23] Change path: Ruby agent --- .github/workflows/generate_release_notes.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate_release_notes.yml b/.github/workflows/generate_release_notes.yml index d1ee4aa134..3a8104f8ac 100644 --- a/.github/workflows/generate_release_notes.yml +++ b/.github/workflows/generate_release_notes.yml @@ -18,8 +18,8 @@ jobs: uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - path: https://github.com/hannahramadan/docs-website - add-paths: /src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ + # path: https://github.com/hannahramadan/docs-website + # add-paths: /src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ commit-message: "chore(ruby agent): Ruby release notes" committer: GitHub author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> From c3f3e91415ae61ee0cb84d4c0573e6acac01cb04 Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:14:59 -0700 Subject: [PATCH 06/23] Create new destination path --- .github/workflows/scripts/parse_changelog.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index 0c0a8668ef..0a0ecbcbe4 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -4,6 +4,7 @@ # frozen_string_literal: true require 'date' +require 'fileutils' require_relative '../../../lib/new_relic/version' DIVIDER = '---' @@ -46,4 +47,5 @@ latest_entry ] -File.write("/src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) +FileUtils.mkdir_p('src/content/docs/release-notes/agent-release-notes/ruby-release-notes') +File.write("src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From 5871b97bc10f40994d1e5ba123b255917089e422 Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:16:54 -0700 Subject: [PATCH 07/23] Change action name --- .../{generate_release_notes.yml => release_notes_pr.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{generate_release_notes.yml => release_notes_pr.yml} (100%) diff --git a/.github/workflows/generate_release_notes.yml b/.github/workflows/release_notes_pr.yml similarity index 100% rename from .github/workflows/generate_release_notes.yml rename to .github/workflows/release_notes_pr.yml From 066597e638bc364e6b8d251c5cfacdcae13beff5 Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:38:31 -0700 Subject: [PATCH 08/23] new action! --- .github/workflows/make_release_notes.yml | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/make_release_notes.yml diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml new file mode 100644 index 0000000000..0169b786a7 --- /dev/null +++ b/.github/workflows/make_release_notes.yml @@ -0,0 +1,63 @@ +name: make release notes +on: + pull_request: + +jobs: + send-pull-requests: + runs-on: ubuntu-latest + steps: + - uses: ruby/setup-ruby@v1.90.0 + with: + ruby-version: 3.1 + - name: Checkout code + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + fetch-depth: 0 # Checkout everything to get access to the tags + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Send pull-request + run: | + LATEST_TAG=$(git describe --tags --always --abbrev=0) + REPOSITORY="hannahramadan/docs-website" + FOLDER="bin/$REPOSITORY" + BRANCH_NAME="chore-update-scripts-to-$LATEST_TAG" + + # Clone the remote repository and change working directory to the + # folder it was cloned to. + git clone \ + --depth=1 \ + --branch=main \ + https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ + $FOLDER + + cd $FOLDER + + # Setup the committers identity. + git config user.email "hramadan@newrelic.com" + git config user.name "hramadan" + + # Create a new feature branch for the changes. + git checkout -b $BRANCH_NAME + + # Update the script files to the latest version. + ruby .github/workflows/scripts/parse_changelog.rb + + # Commit the changes and push the feature branch to origin + git add . + git commit -m "chore: update scripts to $LATEST_TAG" + git push origin $BRANCH_NAME + + # Store the PAT in a file that can be accessed by the + # GitHub CLI. + echo "${{ secrets.RELEASE_NOTES }}" > token.txt + + # Authorize GitHub CLI for the current repository and + # create a pull-requests containing the updates. + gh auth login --with-token < token.txt + gh pr create \ + --body "" \ + --title "chore: update scripts to $LATEST_TAG" \ + --head "$BRANCH_NAME" \ + --base "develop" From 4ed1e94b42f156d958c9b3eaabc960c04affe90c Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 14:43:25 -0700 Subject: [PATCH 09/23] Update branch name -> develop --- .github/workflows/make_release_notes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index 0169b786a7..1defcabd67 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -28,7 +28,7 @@ jobs: # folder it was cloned to. git clone \ --depth=1 \ - --branch=main \ + --branch=develop \ https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ $FOLDER From edad4ed93b584afdefb9550209ed70e954ec971e Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 20 Mar 2023 15:48:35 -0700 Subject: [PATCH 10/23] try to get file uploaded --- .github/workflows/make_release_notes.yml | 5 ++++- .github/workflows/scripts/parse_changelog.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index 1defcabd67..71ff1255b6 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -24,6 +24,9 @@ jobs: FOLDER="bin/$REPOSITORY" BRANCH_NAME="chore-update-scripts-to-$LATEST_TAG" + # Update the script files to the latest version. + ruby .github/workflows/scripts/parse_changelog.rb + # Clone the remote repository and change working directory to the # folder it was cloned to. git clone \ @@ -42,7 +45,7 @@ jobs: git checkout -b $BRANCH_NAME # Update the script files to the latest version. - ruby .github/workflows/scripts/parse_changelog.rb + # cp -R /Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ # Commit the changes and push the feature branch to origin git add . diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index 0a0ecbcbe4..632f518309 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -47,5 +47,5 @@ latest_entry ] -FileUtils.mkdir_p('src/content/docs/release-notes/agent-release-notes/ruby-release-notes') +FileUtils.mkdir_p('/Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes') File.write("src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From ecffd80bb58ae8f2ddcf677b5a07b2b9d169af2c Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 09:30:09 -0700 Subject: [PATCH 11/23] test: echo statments --- .github/workflows/make_release_notes.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index 71ff1255b6..c99c212c88 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -34,7 +34,12 @@ jobs: --branch=develop \ https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ $FOLDER - + + echo ********************* + echo $FOLDER + echo pwd + echo ls -la + cd $FOLDER # Setup the committers identity. From ebe2385864cf128aae0da93b608834f121625d1b Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 09:33:59 -0700 Subject: [PATCH 12/23] remove path --- .github/workflows/scripts/parse_changelog.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index 632f518309..97856ac78d 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -47,5 +47,6 @@ latest_entry ] -FileUtils.mkdir_p('/Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes') -File.write("src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) +# FileUtils.mkdir_p('/Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes') +# File.write("src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) +File.write("ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From 93dd352262c4432d1d3f088baddcc1916e7b6c33 Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 09:42:18 -0700 Subject: [PATCH 13/23] command redo --- .github/workflows/make_release_notes.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index c99c212c88..cab600f586 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -35,10 +35,10 @@ jobs: https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ $FOLDER - echo ********************* - echo $FOLDER - echo pwd - echo ls -la + ********************* + $FOLDER + pwd + ls -la cd $FOLDER From d1e85c57cfdc69bce7cc449d9900dda71e0651a9 Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 09:50:48 -0700 Subject: [PATCH 14/23] $ --- .github/workflows/make_release_notes.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index cab600f586..90589eef21 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -34,11 +34,11 @@ jobs: --branch=develop \ https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ $FOLDER - - ********************* - $FOLDER - pwd - ls -la + + echo *********"" + echo $FOLDER + echo $pwd + echo $ls -la cd $FOLDER From fbe26bb258de6c4c2d6475c06a35181dbec2e585 Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 09:53:50 -0700 Subject: [PATCH 15/23] remove echo --- .github/workflows/make_release_notes.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml index 90589eef21..99c8005f86 100644 --- a/.github/workflows/make_release_notes.yml +++ b/.github/workflows/make_release_notes.yml @@ -35,10 +35,10 @@ jobs: https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ $FOLDER - echo *********"" + echo "*********" echo $FOLDER - echo $pwd - echo $ls -la + pwd + ls -la cd $FOLDER From 7969776cf330df8fcb7f7c38d9ccd35de865adf5 Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 15:34:01 -0700 Subject: [PATCH 16/23] Final commit! --- .github/workflows/scripts/parse_changelog.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index 97856ac78d..f932166227 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -4,7 +4,6 @@ # frozen_string_literal: true require 'date' -require 'fileutils' require_relative '../../../lib/new_relic/version' DIVIDER = '---' @@ -47,6 +46,4 @@ latest_entry ] -# FileUtils.mkdir_p('/Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes') -# File.write("src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) File.write("ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) From 316bcdc8776cd805495c92a36c7c693acc5fbe47 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:35:43 -0700 Subject: [PATCH 17/23] Delete make_release_notes.yml --- .github/workflows/make_release_notes.yml | 71 ------------------------ 1 file changed, 71 deletions(-) delete mode 100644 .github/workflows/make_release_notes.yml diff --git a/.github/workflows/make_release_notes.yml b/.github/workflows/make_release_notes.yml deleted file mode 100644 index 99c8005f86..0000000000 --- a/.github/workflows/make_release_notes.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: make release notes -on: - pull_request: - -jobs: - send-pull-requests: - runs-on: ubuntu-latest - steps: - - uses: ruby/setup-ruby@v1.90.0 - with: - ruby-version: 3.1 - - name: Checkout code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - with: - fetch-depth: 0 # Checkout everything to get access to the tags - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Send pull-request - run: | - LATEST_TAG=$(git describe --tags --always --abbrev=0) - REPOSITORY="hannahramadan/docs-website" - FOLDER="bin/$REPOSITORY" - BRANCH_NAME="chore-update-scripts-to-$LATEST_TAG" - - # Update the script files to the latest version. - ruby .github/workflows/scripts/parse_changelog.rb - - # Clone the remote repository and change working directory to the - # folder it was cloned to. - git clone \ - --depth=1 \ - --branch=develop \ - https://hannahramadan:${{ secrets.RELEASE_NOTES }}@github.com/$REPOSITORY \ - $FOLDER - - echo "*********" - echo $FOLDER - pwd - ls -la - - cd $FOLDER - - # Setup the committers identity. - git config user.email "hramadan@newrelic.com" - git config user.name "hramadan" - - # Create a new feature branch for the changes. - git checkout -b $BRANCH_NAME - - # Update the script files to the latest version. - # cp -R /Users/hramadan/src/content/docs/release-notes/agent-release-notes/ruby-release-notes src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ - - # Commit the changes and push the feature branch to origin - git add . - git commit -m "chore: update scripts to $LATEST_TAG" - git push origin $BRANCH_NAME - - # Store the PAT in a file that can be accessed by the - # GitHub CLI. - echo "${{ secrets.RELEASE_NOTES }}" > token.txt - - # Authorize GitHub CLI for the current repository and - # create a pull-requests containing the updates. - gh auth login --with-token < token.txt - gh pr create \ - --body "" \ - --title "chore: update scripts to $LATEST_TAG" \ - --head "$BRANCH_NAME" \ - --base "develop" From 89985983fa7b0d6392d1d95f5576ff36d40c1620 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Thu, 23 Mar 2023 15:35:51 -0700 Subject: [PATCH 18/23] Delete release_notes_pr.yml --- .github/workflows/release_notes_pr.yml | 32 -------------------------- 1 file changed, 32 deletions(-) delete mode 100644 .github/workflows/release_notes_pr.yml diff --git a/.github/workflows/release_notes_pr.yml b/.github/workflows/release_notes_pr.yml deleted file mode 100644 index 3a8104f8ac..0000000000 --- a/.github/workflows/release_notes_pr.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Generate Release Notes -on: - pull_request: - -jobs: - createPullRequest: - runs-on: ubuntu-latest - steps: - - uses: ruby/setup-ruby@v1.90.0 - with: - ruby-version: 3.1 - - uses: actions/checkout@v3 - - name: Make changes to pull request - run: ruby .github/workflows/scripts/parse_changelog.rb - - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - # path: https://github.com/hannahramadan/docs-website - # add-paths: /src/content/docs/release-notes/agent-release-notes/ruby-release-notes/ - commit-message: "chore(ruby agent): Ruby release notes" - committer: GitHub - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false - branch: ruby-release-notes - delete-branch: true - title: 'Ruby Release Notes' - body: | - Ruby release notes. This is an automated PR. - draft: true From 941f3f28f9200971143fdbcee16ddd31aecc7c05 Mon Sep 17 00:00:00 2001 From: hramadan Date: Thu, 23 Mar 2023 15:43:55 -0700 Subject: [PATCH 19/23] Update filename --- .../scripts/{parse_changelog.rb => generate_release_notes.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/scripts/{parse_changelog.rb => generate_release_notes.rb} (100%) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/generate_release_notes.rb similarity index 100% rename from .github/workflows/scripts/parse_changelog.rb rename to .github/workflows/scripts/generate_release_notes.rb From 002c7f8ee0be6a6997bf09e25914e7a867a57b3a Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:30:15 -0700 Subject: [PATCH 20/23] Update parse_changelog.rb --- .github/workflows/scripts/parse_changelog.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index f932166227..c88291c0f8 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -15,18 +15,18 @@ changelog = File.read('CHANGELOG.md') latest_entry = changelog.split('##')[1].prepend('##') -titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten - +titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten # Match strings between sets of '**' metadata = Hash.new { |h, k| h[k] = [] } + titles.each do |t| category = t.split(':').first case category when 'Feature' - metadata[:feature] << t.delete_prefix('Feature: ') + metadata[:features] << t.delete_prefix('Feature: ') when 'Bugfix' metadata[:bugs] << t.delete_prefix('Bugfix: ') when 'Security' - metadata[:securtiy] << t.delete_prefix('Security: ') + metadata[:security] << t.delete_prefix('Security: ') end end @@ -38,7 +38,7 @@ "downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem", "features: #{metadata[:feature]}", "bugs: #{metadata[:bugs]}", - "security: #{metadata[:securtiy]}", + "security: #{metadata[:security]}", DIVIDER, '', SUPPRORT_STATEMENT, From 2d074f0bf5c9a8e7363af05960fe5d7fceb0e8b9 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Fri, 24 Mar 2023 09:35:05 -0700 Subject: [PATCH 21/23] Update .github/workflows/scripts/parse_changelog.rb Co-authored-by: Kayla Reopelle (she/her) <87386821+kaylareopelle@users.noreply.github.com> --- .github/workflows/scripts/parse_changelog.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/parse_changelog.rb b/.github/workflows/scripts/parse_changelog.rb index c88291c0f8..53d381cf68 100644 --- a/.github/workflows/scripts/parse_changelog.rb +++ b/.github/workflows/scripts/parse_changelog.rb @@ -36,7 +36,7 @@ "date: #{Date.today}", "version: #{NewRelic::VERSION::STRING}", "downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem", - "features: #{metadata[:feature]}", + "features: #{metadata[:features]}", "bugs: #{metadata[:bugs]}", "security: #{metadata[:security]}", DIVIDER, From 7bc24cab4c3846e65e89b842d2f9d2195e0c3629 Mon Sep 17 00:00:00 2001 From: hramadan Date: Mon, 27 Mar 2023 13:28:34 -0700 Subject: [PATCH 22/23] Make script classy --- .../scripts/generate_release_notes.rb | 94 +++++++++++-------- 1 file changed, 56 insertions(+), 38 deletions(-) diff --git a/.github/workflows/scripts/generate_release_notes.rb b/.github/workflows/scripts/generate_release_notes.rb index 53d381cf68..ef06fd2d1d 100644 --- a/.github/workflows/scripts/generate_release_notes.rb +++ b/.github/workflows/scripts/generate_release_notes.rb @@ -6,44 +6,62 @@ require 'date' require_relative '../../../lib/new_relic/version' -DIVIDER = '---' -SUPPRORT_STATEMENT = " -We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version at most 90 days old. Read more about [keeping agent up to date](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/). - -See the New Relic Ruby agent [EOL policy](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-eol-policy/) for information about agent releases and support dates. -" - -changelog = File.read('CHANGELOG.md') -latest_entry = changelog.split('##')[1].prepend('##') -titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten # Match strings between sets of '**' -metadata = Hash.new { |h, k| h[k] = [] } - -titles.each do |t| - category = t.split(':').first - case category - when 'Feature' - metadata[:features] << t.delete_prefix('Feature: ') - when 'Bugfix' - metadata[:bugs] << t.delete_prefix('Bugfix: ') - when 'Security' - metadata[:security] << t.delete_prefix('Security: ') +class GenerateReleaseNotes + DIVIDER = '---' + SUPPORT_STATEMENT = <<~SUPPORT_STATEMENT + + We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version at most 90 days old. Read more about [keeping agents up to date](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/). + + See the New Relic Ruby agent [EOL policy](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-eol-policy/) for information about agent releases and support dates. + + SUPPORT_STATEMENT + + def build_metadata + changelog = File.read('CHANGELOG.md') + latest_entry = changelog.split('##')[1].prepend('##') + titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten # Match strings between sets of '**' + metadata = Hash.new { |h, k| h[k] = [] } + + titles.each do |t| + category = t.split(':').first + case category + when 'Feature' + metadata[:features] << t.delete_prefix('Feature: ') + when 'Bugfix' + metadata[:bugs] << t.delete_prefix('Bugfix: ') + when 'Security' + metadata[:security] << t.delete_prefix('Security: ') + end + end + + return metadata, latest_entry + end + + def build_release_content + metadata, latest_entry = build_metadata + frontmatter = <<~FRONTMATTER + #{DIVIDER} + subject: Ruby agent + date: #{Date.today} + version: #{NewRelic::VERSION::STRING} + downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem + features: #{metadata[:features]} + bugs: #{metadata[:bugs]} + security: #{metadata[:security]} + #{DIVIDER} + + #{SUPPORT_STATEMENT} + #{latest_entry} + FRONTMATTER + end + + def write_filename + "ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx" + end + + def write_output_file + File.write(write_filename, build_release_content) end end -frontmatter = [ - DIVIDER, - 'subject: Ruby agent', - "date: #{Date.today}", - "version: #{NewRelic::VERSION::STRING}", - "downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem", - "features: #{metadata[:features]}", - "bugs: #{metadata[:bugs]}", - "security: #{metadata[:security]}", - DIVIDER, - '', - SUPPRORT_STATEMENT, - '', - latest_entry -] - -File.write("ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx", frontmatter.join("\n")) +GenerateReleaseNotes.new.write_output_file From 71ad8ad052b2c10f226eff59df4ad4de6c699e49 Mon Sep 17 00:00:00 2001 From: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com> Date: Mon, 27 Mar 2023 14:16:55 -0700 Subject: [PATCH 23/23] Update .github/workflows/scripts/generate_release_notes.rb Co-authored-by: James Bunch --- .github/workflows/scripts/generate_release_notes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scripts/generate_release_notes.rb b/.github/workflows/scripts/generate_release_notes.rb index ef06fd2d1d..777fc421ab 100644 --- a/.github/workflows/scripts/generate_release_notes.rb +++ b/.github/workflows/scripts/generate_release_notes.rb @@ -39,7 +39,7 @@ def build_metadata def build_release_content metadata, latest_entry = build_metadata - frontmatter = <<~FRONTMATTER + <<~FRONTMATTER #{DIVIDER} subject: Ruby agent date: #{Date.today}