-
Notifications
You must be signed in to change notification settings - Fork 63
137 lines (134 loc) · 5.33 KB
/
dotnetcore.yml
File metadata and controls
137 lines (134 loc) · 5.33 KB
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
136
137
permissions:
id-token: write
checks: write
contents: write
packages: write
name: DotNET Core Build
'on':
workflow_dispatch: {}
push: {}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Set up DotNET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |-
8.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.1.0
with:
versionSpec: '6.3.x'
- id: determine_version
name: Determine Version
uses: gittools/actions/gitversion/execute@v4.1.0
- name: Install Dependencies
run: dotnet restore
shell: bash
- name: List Dependencies
run: dotnet list package > dependencies.txt
shell: bash
- name: Collect Dependencies
uses: actions/upload-artifact@v4
with:
name: Dependencies
path: dependencies.txt
- name: List Dependency Updates
run: dotnet list package --outdated > dependencyUpdates.txt
shell: bash
- name: Collect Dependency Updates
uses: actions/upload-artifact@v4
with:
name: Dependencies Updates
path: dependencyUpdates.txt
- name: Test
run: dotnet test -l:trx
shell: bash
- if: always()
name: Report
uses: dorny/test-reporter@v1
with:
name: DotNET Tests
path: '**/*.trx'
reporter: dotnet-trx
fail-on-error: 'false'
- name: Publish
run: dotnet publish --configuration Release /p:AssemblyVersion=${{ steps.determine_version.outputs.assemblySemVer }}
- name: Install Octopus CLI 🐙
uses: OctopusDeploy/install-octopus-cli-action@v3
with:
version: 'latest'
- id: package
name: Package
run: |
# "dotnet publish" generates binary files in a specific directory called ./bin/<BUILD-CONFIGURATION>/<TFM>/publish/.
# See https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli for more details.
# We start by finding the publish directories, which we assume hold dll files.
shopt -s globstar
paths=()
for i in **/publish/*.dll; do
dir=${i%/*}
echo ${dir}
paths=(${paths[@]} ${dir})
done
# Find the unique set of directories holding the dll files.
eval uniquepaths=($(printf "%s\n" "${paths[@]}" | sort -u))
for i in "${uniquepaths[@]}"; do
echo $i
done
# For each publish dir, create a package.
packages=()
versions=()
for path in "${uniquepaths[@]}"; do
# Get the directory name four deep, which is typically the project folder.
# The directory name is used to name the package.
dir=${path}/../../../..
parentdir=$(builtin cd $dir; pwd)
projectname=${parentdir##*/}
# Package the published files.
octopus package zip create \
--base-path ${path} \
--id ${projectname} \
--version ${{ steps.determine_version.outputs.semVer }} \
--overwrite
packages=(${packages[@]} "${projectname}.${{ steps.determine_version.outputs.semVer }}.zip")
versions=(${versions[@]} "${projectname}:${{ steps.determine_version.outputs.semVer }}")
done
# We now need to output the list of generated packages so subsequent steps can access them.
# We create multiple output variables with line and comma separated vales to support the inputs of subsequent steps.
# Join the array with commas.
printf -v joined "%s," "${packages[@]}"
# Save the list of packages as an output variable
echo "::set-output name=artifacts::${joined%,}"
# Do the same again, but use new lines as the separator. These will be used when uploading packages to the GitHub release.
printf -v joinednewline "%s\n" "${packages[@]}"
# https://trstringer.com/github-actions-multiline-strings/
# Multiline strings require some care in a workflow.
joinednewline="${joinednewline//'%'/'%25'}"
joinednewline="${joinednewline//$'\n'/'%0A'}"
joinednewline="${joinednewline//$'\r'/'%0D'}"
# Now build a new line separated list of versions. These will be used when creating an Octopus release.
printf -v versionsjoinednewline "%s\n" "${versions[@]}"
versionsjoinednewline="${versionsjoinednewline//'%'/'%25'}"
versionsjoinednewline="${versionsjoinednewline//$'\n'/'%0A'}"
versionsjoinednewline="${versionsjoinednewline//$'\r'/'%0D'}"
# Save the list of packages newline separated as an output variable.
echo "::set-output name=artifacts_new_line::${joinednewline%\n}"
echo "::set-output name=versions_new_line::${versionsjoinednewline%\n}"
- name: Tag Release
uses: mathieudutour/github-tag-action@v6.0
with:
custom_tag: ${{ steps.determine_version.outputs.semVer }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: ${{ steps.package.outputs.artifacts_new_line }}
tag_name: ${{ steps.determine_version.outputs.semVer }}+run${{ github.run_number }}-attempt${{ github.run_attempt }}
draft: 'false'
prerelease: 'false'
target_commitish: ${{ github.sha }}