From 5e86fc37246e370e3ed472ac6916c7992a9d6ca6 Mon Sep 17 00:00:00 2001 From: Marty Tippin <120425148+tippmar-nr@users.noreply.github.com> Date: Wed, 5 Jun 2024 13:59:05 -0500 Subject: [PATCH] ci: .NET workflow tweaks --- .github/workflows/dotnet.yml | 59 ++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index ffa4ec0..81110c0 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,22 +1,33 @@ -# Copyright 2010 New Relic, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# Copyright New Relic, Inc. +# SPDX-License-Identifier: Apache-2.0 --- name: .NET Agent CI on: - workflow_dispatch: # run test job only + workflow_dispatch: # run test job always, optionally publish a specific version + inputs: + publish_agent: + description: Publish the agent? + type: boolean + required: true + default: false + agent_version: + description: The agent version to publish (in SemVer format xx.xx.xx) + type: string + required: true pull_request: # run check modified files / test jobs + paths: + - 'src/dotnet/**' + - '.github/workflows/dotnet.yml' + push: # run check modified files / test jobs + branches: + - main + paths: + - 'dotnet/**' + - '.github/workflows/dotnet.yml' + # Do not run when a tag is created. + tags-ignore: + - "**" release: # run check modified files / test / publish jobs types: - published @@ -35,7 +46,7 @@ permissions: jobs: check-modified-files: - name: Check whether any Dotnet-related files were modified, skip the test job if not + name: Check whether any Dotnet-related files were modified uses: ./.github/workflows/check-modified-files.yml secrets: inherit permissions: @@ -113,8 +124,8 @@ jobs: publish: runs-on: ubuntu-latest - # only publish on a dotnet release - if: github.event_name == 'release' && endsWith(github.ref_name, '_dotnet') + # publish on a dotnet release or when selected on a manual invocation + if: (github.event_name == 'release' && endsWith(github.ref_name, '_dotnet')) || (github.event_name == 'workflow_dispatch' && inputs.publish_agent) needs: - test @@ -125,13 +136,17 @@ jobs: disable-sudo: true egress-policy: audit - - name: Extract Agent Version from release tag + - name: Extract Agent Version from release tag or workflow input id: version run: | - agent_version=${{ github.ref_name }} # Use tag name - agent_version=${agent_version##v} # Remove v prefix - agent_version=${agent_version%%_dotnet} # Remove language suffix - echo "agent_version=${agent_version}" | tee -a "$GITHUB_OUTPUT" + if (${{ github.event_name == 'workflow_dispatch'}}) then + echo "agent_version=${{ inputs.agent_version }}" | tee -a "$GITHUB_OUTPUT" + else + agent_version=${{ github.ref_name }} # Use tag name + agent_version=${agent_version##v} # Remove v prefix + agent_version=${agent_version%%_dotnet} # Remove language suffix + echo "agent_version=${agent_version}" | tee -a "$GITHUB_OUTPUT" + fi - name: Checkout code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1