-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (113 loc) · 4.43 KB
/
dotnet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Restore, build and publish .NET Core application.
name: ♻ dotnet
on:
workflow_call:
inputs:
runs_on:
description: The label of the runner (GitHub- or self-hosted) to run this workflow on. Defaults to `ubuntu-24.04`.
type: string
required: false
default: ubuntu-24.04
dotnet_version:
description: The version of .NET to install.
type: string
required: true
node_version:
description: A specific version of Node.js to install. Use to override pre-installed version on GitHub-hosted runners.
type: string
required: false
npm_version:
description: A specific version of npm to install. Use to override pre-installed version on GitHub-hosted runners.
type: string
required: false
project:
description: Specify the path of the project or solution file, or the path of the directory containing the project or solution file.
type: string
required: false
default: "."
runtime:
description: Which runtime to publish the application for.
type: string
required: false
self_contained:
description: Publish the .NET runtime with your application so the runtime doesn't need to be installed on the target machine?
type: boolean
required: false
default: false
test_project:
description: Specify the path of a test project or solution file, or the path of a directory containing a test project or solution file.
type: string
required: false
test_collect:
description: The name of a data collector to enable for the test run, for example `Code Coverage`.
type: string
required: false
artifact_name:
description: The name of the build artifact to upload.
type: string
required: false
default: dotnet-app
outputs:
artifact_name:
description: The name of the uploaded artifact containing the application.
value: ${{ inputs.artifact_name }}
permissions: {}
jobs:
dotnet:
name: .NET
runs-on: ${{ inputs.runs_on }}
permissions:
contents: read # Required to checkout the repository
env:
PROJECT: ${{ inputs.project }}
CONFIGURATION: Release
RUNTIME: ${{ inputs.runtime }}
SELF_CONTAINED: ${{ inputs.self_contained }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Setup .NET
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9
with:
dotnet-version: ${{ inputs.dotnet_version }}
- name: Setup Node.js
if: inputs.node_version != ''
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e
with:
node-version: ${{ inputs.node_version }}
- name: Update npm
if: inputs.npm_version != ''
env:
NPM_VERSION: ${{ inputs.npm_version }}
run: npm install -g "npm@$NPM_VERSION"
- name: .NET Restore
run: dotnet restore "$PROJECT" --runtime "$RUNTIME"
- name: .NET Build
run: dotnet build "$PROJECT" --configuration "$CONFIGURATION" --runtime "$RUNTIME" --self-contained "$SELF_CONTAINED" --no-restore
- name: .NET Test
if: inputs.test_project != ''
env:
TEST_PROJECT: ${{ inputs.test_project }}
TEST_COLLECT: ${{ inputs.test_collect }}
run: dotnet test "$TEST_PROJECT" --configuration "$CONFIGURATION" --collect "$TEST_COLLECT"
- name: .NET Publish
id: publish
env:
OUTPUT_PATH: ${{ runner.temp }}/${{ inputs.artifact_name }}
run: |
dotnet publish "$PROJECT" --configuration "$CONFIGURATION" --runtime "$RUNTIME" --self-contained "$SELF_CONTAINED" --output "$OUTPUT_PATH" --no-build
echo "publish_path=$OUTPUT_PATH" >> "$GITHUB_OUTPUT"
- name: Create tarball
id: tar
working-directory: ${{ steps.publish.outputs.publish_path }}
env:
ARTIFACT_NAME: ${{ inputs.artifact_name }}
run: |
tarball="$RUNNER_TEMP/$ARTIFACT_NAME.tar"
tar --create --file "$tarball" .
echo "tarball=$tarball" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: ${{ inputs.artifact_name }}
path: ${{ steps.tar.outputs.tarball }}