Skip to content

Commit

Permalink
ci: Release Automation (#1821)
Browse files Browse the repository at this point in the history
Co-authored-by: @jaffinito
  • Loading branch information
tippmar-nr authored Aug 8, 2023
1 parent 8cedbb6 commit 583b338
Show file tree
Hide file tree
Showing 39 changed files with 1,716 additions and 3 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/deploy_agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ on:
description: 'If "true", will run the index-download-site job. If "false", will not.'
required: true
default: 'true'
update-apm-version:
description: 'If "true", will run the update-apm job. If "false", will not.'
required: true
default: 'true'

permissions:
contents: read
Expand Down Expand Up @@ -334,3 +338,56 @@ jobs:
run: |
curl -i -X POST -H 'Fastly-Key:${{ secrets.FASTLY_TOKEN }}' ${{ secrets.FASTLY_URL }}
shell: bash

update-apm:
name: Update System Configuration Page
runs-on: ubuntu-latest
if: ${{ github.event.inputs.update-apm-version == true }}
steps:
- name: Update system configuration page
run: |
PAYLOAD="{
\"system_configuration\": {
\"key\": \"dotnet_agent_version\",
\"value\": \"${{ github.event.inputs.agent_version }}\"
}
}"
CONTENT_TYPE='Content-Type: application/json'
# STAGING
curl -X POST 'https://staging-api.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:${{ secrets.NEW_RELIC_API_KEY_STAGING }}" -i \
-H "$CONTENT_TYPE" \
-d "$PAYLOAD"
# PRODUCTION
curl -X POST 'https://api.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:${{ secrets.NEW_RELIC_API_KEY_PRODUCTION }}" -i \
-H "$CONTENT_TYPE" \
-d "$PAYLOAD"
# EU PRODUCTION
curl -X POST 'https://api.eu.newrelic.com/v2/system_configuration.json' \
-H "X-Api-Key:${{ secrets.NEW_RELIC_API_KEY_PRODUCTION }}" -i \
-H "$CONTENT_TYPE" \
-d "$PAYLOAD"
publish-release-notes:
needs: [deploy-linux, index-download-site]
if: ${{ github.event.inputs.deploy == 'true' && github.event.inputs.downloadsite == 'true' && github.event.inputs.nuget == 'true' && github.event.inputs.linux == 'true' && github.event.inputs.linux-deploy-to-production == 'true' }}
name: Create and Publish Release Notes
uses: newrelic/newrelic-dotnet-agent/.github/workflows/publish_release_notes.yml@main
with:
agent_version: ${{ github.event.inputs.agent_version }}
run_id: ${{ github.event.inputs.run_id }}
secrets: inherit

post-deploy:
needs: [deploy-linux, index-download-site]
if: ${{ github.event.inputs.deploy == 'true' && github.event.inputs.downloadsite == 'true' && github.event.inputs.nuget == 'true' && github.event.inputs.linux == 'true' && github.event.inputs.linux-deploy-to-production == 'true' }}
name: Run Post Deploy Workflow
uses: newrelic/newrelic-dotnet-agent/.github/workflows/post_deploy_agent.yml@main
with:
agent_version: ${{ github.event.inputs.agent_version }}
secrets: inherit

136 changes: 134 additions & 2 deletions .github/workflows/post_deploy_agent.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: Post Deploy for the .NET Agent


on:
workflow_dispatch:
inputs:
Expand All @@ -24,8 +25,36 @@ env:

jobs:

placeholder:
name: Placeholder
validate-apt-repo:
name: Validate APT-based repo
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: false
egress-policy: audit

- name: Validate
run: |
echo 'deb https://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install newrelic-dotnet-agent
installed_version=$(dpkg -s newrelic-dotnet-agent | grep -i version)
if [ "$AGENT_VERSION" = "$installed_version" ]; then
echo "Versions match."
exit 0
else
echo "ERROR: Version mismatch: Expected $AGENT_VERSION was $installed_version"
exit 1
fi
shell: bash
env:
AGENT_VERSION: "Version: ${{ github.event.inputs.agent_version }}"

validate-yum-repo:
name: Validate YUM-based repo
runs-on: ubuntu-latest
steps:
- name: Harden Runner
Expand All @@ -34,3 +63,106 @@ jobs:
disable-sudo: true
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Validate
run: |
cd deploy/validation/validate-yum
# This will setup the New Relic yum repo and install the agent.
docker build -t localtesting/validateyum:latest .
docker run --name validateyum localtesting/validateyum:latest
installed_version=$(docker logs --tail 1 validateyum)
if [ "$AGENT_VERSION" = "$installed_version" ]; then
echo "Versions match."
exit 0
else
echo "ERROR: Version mismatch: Expected $AGENT_VERSION was $installed_version"
exit 1
fi
shell: bash
env:
AGENT_VERSION: "newrelic-dotnet-agent-${{ github.event.inputs.agent_version }}-1.x86_64"

validate-download-site-s3:
name: Validate S3-hosted Download Site
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: true
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Build and Run S3Validator
run: |
dotnet build --configuration Release "$BUILD_PATH"
"$RUN_PATH/S3Validator" -v $AGENT_VERSION -c $CONFIG_PATH
shell: bash
env:
BUILD_PATH: ${{ github.workspace }}/build/S3Validator/S3Validator.csproj
RUN_PATH: ${{ github.workspace }}/build/S3Validator/bin/Release/net7.0/
CONFIG_PATH: ${{ github.workspace }}/build/S3Validator/bin/Release/net7.0/config.yml
AGENT_VERSION: ${{ github.event.inputs.agent_version }}

validate-nuget-packages:
name: Validate NuGet Package Deployment
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: true
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Build and Run NugetValidator
run: |
dotnet build --configuration Release "$BUILD_PATH"
"$RUN_PATH/NugetValidator" -v $AGENT_VERSION -c $CONFIG_PATH
shell: bash
env:
BUILD_PATH: ${{ github.workspace }}/build/NugetValidator/NugetValidator.csproj
RUN_PATH: ${{ github.workspace }}/build/NugetValidator/bin/Release/net7.0/
AGENT_VERSION: ${{ github.event.inputs.agent_version }}
CONFIG_PATH: ${{ github.workspace }}/build/NugetValidator/bin/Release/net7.0/config.yml

report-deprecated-nuget-packages:
name: Report Deprecated NuGet Packages
runs-on: ubuntu-latest
permissions:
issues: write

steps:
- name: Harden Runner
uses: step-security/harden-runner@cba0d00b1fc9a034e1e642ea0f1103c282990604 # v2.5.0
with:
disable-sudo: true
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Build and Run NugetDeprecator
run: |
dotnet build --configuration Release "$BUILD_PATH"
"$RUN_PATH/NugetVersionDeprecator" -c $CONFIG_PATH --github-token ${{ secrets.GITHUB_TOKEN }} --api-key ${{ secrets.NEW_RELIC_API_KEY_PRODUCTION }}
shell: bash
env:
BUILD_PATH: ${{ github.workspace }}/build/NugetVersionDeprecator/NugetVersionDeprecator.csproj
RUN_PATH: ${{ github.workspace }}/build/NugetVersionDeprecator/bin/Release/net7.0/
CONFIG_PATH: ${{ github.workspace }}/build/NugetVersionDeprecator/bin/Release/net7.0/config.yml
94 changes: 94 additions & 0 deletions .github/workflows/publish_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,97 @@ permissions:

env:
DOTNET_NOLOGO: true

jobs:

get-external-artifacts:
name: Get and Publish Deploy Artifacts Locally
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
with:
disable-sudo: true
egress-policy: audit

- name: Download Deploy Artifacts
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: all_solutions.yml
run_id: ${{ github.event.inputs.run_id }}
name: deploy-artifacts
path: ${{ github.workspace }}
repo: ${{ github.repository }}

- name: Upload Deploy Artifacts Locally
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: deploy-artifacts
path: ${{ github.workspace }}/build/BuildArtifacts
if-no-files-found: error

publish-release-notes:
needs: get-external-artifacts
name: Create and Publish Release Notes
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
fetch-depth: 0

- name: Download Deploy Artifacts
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: deploy-artifacts
path: ${{ github.workspace }}/artifacts

- name: Set Docs PR Branch Name
run: |
cleaned_branch=$(echo "10.13.0" | sed 's/\./-/g')
echo "branch_name=dotnet-release-$cleaned_branch"
echo "branch_name=dotnet-release-$cleaned_branch" >> $GITHUB_ENV
shell: bash

- name: Build Release Notes
run: |
dotnet build --configuration Release "$BUILD_PATH"
notes_file=$("$RUN_PATH/ReleaseNotesBuilder" -p "$RUN_PATH/data.yml" -c "$CHANGELOG" -x "$CHECKSUMS" -o "$OUTPUT_PATH")
echo "$notes_file"
echo "notes_file=$notes_file" >> $GITHUB_ENV
shell: bash
env:
BUILD_PATH: ${{ github.workspace }}/build/ReleaseNotesBuilder/ReleaseNotesBuilder.csproj
RUN_PATH: ${{ github.workspace }}/build/ReleaseNotesBuilder/bin/Release/net7.0/
CHANGELOG: ${{ github.workspace }}/src/Agent/CHANGELOG.md
CHECKSUMS: ${{ github.workspace }}/artifacts/DownloadSite/SHA256/checksums.md
OUTPUT_PATH: ${{ github.workspace }}

- name: Create branch
uses: dmnemec/copy_file_to_another_repo_action@c93037aa10fa8893de271f19978c980d0c1a9b37 # tag v1.1.1
env:
API_TOKEN_GITHUB: ${{ secrets.DOTNET_AGENT_GH_TOKEN }}
with:
source_file: "${{ env.notes_file }}"
destination_repo: 'newrelic/docs-website'
destination_folder: 'src/content/docs/release-notes/agent-release-notes/net-release-notes'
user_email: '${{ secrets.BOT_EMAIL }}'
user_name: 'dotnet-agent-team-bot'
destination_branch: 'develop'
destination_branch_create: ${{env.branch_name}}
commit_message: 'chore(.net agent): Add .NET Agent release notes for v${{ github.event.inputs.agent_version }}.'

- name: Create pull request
run: gh pr create --base "develop" --repo "$REPO" --head "$HEAD" --title "$TITLE" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.DOTNET_AGENT_GH_TOKEN }}
REPO: https://github.com/newrelic/docs-website/
HEAD: ${{env.branch_name}}
TITLE: ".NET Agent Release Notes for v${{ github.event.inputs.agent_version }}"
BODY: "This is an automated PR generated when the .NET agent is released. Please merge as soon as possible."
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
with:
release-type: go
changelog-path: src/Agent/CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.DOTNET_AGENT_GH_TOKEN }}
changelog-types: '[{"type":"notice","section":"Notice","hidden":false},{"type":"feat","section":"New Features","hidden":false},{"type":"fix","section":"Fixes","hidden":false},{"type":"security","section":"Security","hidden":false}]'
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ NDependOut/

test-results

#ignore launchSettings
launchSettings.json

# Ignore FullAgent build output
src/_build/
Agent/_build/
Expand Down Expand Up @@ -158,3 +161,4 @@ tests/TestResults/*
/src/Agent/_profilerBuild/x64-Release/NewRelic.Profiler.dll
/src/Agent/_profilerBuild/x86-Release/NewRelic.Profiler.dll
/tests/Agent/IntegrationTests/ContainerApplications/.env

24 changes: 24 additions & 0 deletions build/BuildTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArtifactBuilder", "Artifact
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewRelic.NuGetHelper", "NewRelic.NuGetHelper\NewRelic.NuGetHelper.csproj", "{94BF8D27-2122-4573-AA79-90B977B40EF3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NugetValidator", "NugetValidator\NugetValidator.csproj", "{C3F69996-5A5F-4836-A485-C270C318C6E9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S3Validator", "S3Validator\S3Validator.csproj", "{648D08B2-E677-4009-A593-D03E0579E859}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReleaseNotesBuilder", "ReleaseNotesBuilder\ReleaseNotesBuilder.csproj", "{0E9152F2-4CA9-4F24-AADF-9B15310C3DFA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NugetVersionDeprecator", "NugetVersionDeprecator\NugetVersionDeprecator.csproj", "{77685AF5-5FD7-483E-B589-BDE4E2F1769C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +29,22 @@ Global
{94BF8D27-2122-4573-AA79-90B977B40EF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94BF8D27-2122-4573-AA79-90B977B40EF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94BF8D27-2122-4573-AA79-90B977B40EF3}.Release|Any CPU.Build.0 = Release|Any CPU
{C3F69996-5A5F-4836-A485-C270C318C6E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3F69996-5A5F-4836-A485-C270C318C6E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3F69996-5A5F-4836-A485-C270C318C6E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3F69996-5A5F-4836-A485-C270C318C6E9}.Release|Any CPU.Build.0 = Release|Any CPU
{648D08B2-E677-4009-A593-D03E0579E859}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{648D08B2-E677-4009-A593-D03E0579E859}.Debug|Any CPU.Build.0 = Debug|Any CPU
{648D08B2-E677-4009-A593-D03E0579E859}.Release|Any CPU.ActiveCfg = Release|Any CPU
{648D08B2-E677-4009-A593-D03E0579E859}.Release|Any CPU.Build.0 = Release|Any CPU
{0E9152F2-4CA9-4F24-AADF-9B15310C3DFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E9152F2-4CA9-4F24-AADF-9B15310C3DFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E9152F2-4CA9-4F24-AADF-9B15310C3DFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E9152F2-4CA9-4F24-AADF-9B15310C3DFA}.Release|Any CPU.Build.0 = Release|Any CPU
{77685AF5-5FD7-483E-B589-BDE4E2F1769C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77685AF5-5FD7-483E-B589-BDE4E2F1769C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77685AF5-5FD7-483E-B589-BDE4E2F1769C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77685AF5-5FD7-483E-B589-BDE4E2F1769C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
11 changes: 11 additions & 0 deletions build/NugetValidator/Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2023 New Relic, Inc. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

namespace NugetValidator
{
public class Configuration
{
[YamlDotNet.Serialization.YamlMember(Alias = "nuget-packages")]
public List<string> Packages { get; set; }
}
}
Loading

0 comments on commit 583b338

Please sign in to comment.