Skip to content

Commit

Permalink
ci: .NET workflow tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Jun 5, 2024
1 parent 1b6f47d commit 5e86fc3
Showing 1 changed file with 37 additions and 22 deletions.
59 changes: 37 additions & 22 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 5e86fc3

Please sign in to comment.