Skip to content

Commit a03f182

Browse files
committed
Initial commit: BeyondNetCode.Shell.Bootstrapper library
Extracted from beyondnetcode/ums - Namespace renamed: Ums.Shell.Bootstrapper -> BeyondNetCode.Shell.Bootstrapper - Package IDs updated for NuGet: BeyondNetCode.* - GitFlow workflow, CONTRIBUTING.md, VERSIONING.md added - AutoMapper API fix for v12 compatibility - All tests passing (5 tests) Original code authorship: raulnq (https://github.com/raulnq)
0 parents  commit a03f182

28 files changed

Lines changed: 2335 additions & 0 deletions

.editorconfig

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.{cs,csx}]
11+
indent_size = 4
12+
tab_width = 4
13+
14+
dotnet_sort_system_directives_first = true
15+
dotnet_separate_import_directive_groups = false
16+
17+
csharp_style_var_for_built_in_types = true:suggestion
18+
csharp_style_var_when_type_is_apparent = true:suggestion
19+
csharp_style_var_elsewhere = true:suggestion
20+
21+
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
22+
csharp_style_expression_bodied_properties = when_on_single_line:suggestion
23+
csharp_style_expression_bodied_constructors = false:suggestion
24+
25+
csharp_style_throw_expression = true:suggestion
26+
csharp_style_conditional_delegate_call = true:suggestion
27+
dotnet_style_null_propagation = true:suggestion
28+
dotnet_style_coalesce_expression = true:suggestion
29+
30+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
31+
32+
csharp_prefer_braces = when_multiline:suggestion
33+
34+
csharp_new_line_before_open_brace = all
35+
csharp_new_line_before_else = true
36+
csharp_new_line_before_catch = true
37+
csharp_new_line_before_finally = true
38+
39+
csharp_space_after_cast = false
40+
csharp_space_before_colon_in_inheritance_clause = true
41+
csharp_space_after_colon_in_inheritance_clause = true
42+
csharp_space_around_binary_operators = before_and_after
43+
44+
dotnet_naming_rule.private_fields_underscore.severity = suggestion
45+
dotnet_naming_rule.private_fields_underscore.symbols = private_fields
46+
dotnet_naming_rule.private_fields_underscore.style = camel_case_underscore_style
47+
48+
dotnet_naming_symbols.private_fields.applicable_kinds = field
49+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
50+
51+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
52+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
53+
54+
dotnet_naming_rule.constants_pascal_case.severity = suggestion
55+
dotnet_naming_rule.constants_pascal_case.symbols = constants
56+
dotnet_naming_rule.constants_pascal_case.style = pascal_case_style
57+
58+
dotnet_naming_symbols.constants.applicable_kinds = field
59+
dotnet_naming_symbols.constants.required_modifiers = const
60+
61+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
62+
63+
[*.{json,yml,yaml}]
64+
indent_size = 2
65+
66+
[*.{xml,csproj,props,targets}]
67+
indent_size = 2
68+
69+
[*.md]
70+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto
5+
6+
###############################################################################
7+
# Set default behavior for command prompt diff.
8+
#
9+
# This is need for earlier builds of msysgit that does not have it on by
10+
# default for csharp files.
11+
# Note: This is only used by command line
12+
###############################################################################
13+
#*.cs diff=csharp
14+
15+
###############################################################################
16+
# Set the merge driver for project and solution files
17+
#
18+
# Merging from the command prompt will add diff markers to the files if there
19+
# are conflicts (Merging from VS is not affected by the settings below, in VS
20+
# the diff markers are never inserted). Diff markers may cause the following
21+
# file extensions to fail to load in VS. An alternative would be to treat
22+
# these files as binary and thus will always conflict and require user
23+
# intervention with every merge. To do so, just uncomment the entries below
24+
###############################################################################
25+
#*.sln merge=binary
26+
#*.csproj merge=binary
27+
#*.vbproj merge=binary
28+
#*.vcxproj merge=binary
29+
#*.vcproj merge=binary
30+
#*.dbproj merge=binary
31+
#*.fsproj merge=binary
32+
#*.lsproj merge=binary
33+
#*.wixproj merge=binary
34+
#*.modelproj merge=binary
35+
#*.sqlproj merge=binary
36+
#*.wwaproj merge=binary
37+
38+
###############################################################################
39+
# behavior for image files
40+
#
41+
# image files are treated as binary by default.
42+
###############################################################################
43+
#*.jpg binary
44+
#*.png binary
45+
#*.gif binary
46+
47+
###############################################################################
48+
# diff behavior for common document formats
49+
#
50+
# Convert binary document formats to text before diffing them. This feature
51+
# is only available from the command line. Turn it on by uncommenting the
52+
# entries below.
53+
###############################################################################
54+
#*.doc diff=astextplain
55+
#*.DOC diff=astextplain
56+
#*.docx diff=astextplain
57+
#*.DOCX diff=astextplain
58+
#*.dot diff=astextplain
59+
#*.DOT diff=astextplain
60+
#*.pdf diff=astextplain
61+
#*.PDF diff=astextplain
62+
#*.rtf diff=astextplain
63+
#*.RTF diff=astextplain

.github/workflows/build.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: CI / CD
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
tags:
9+
- 'v*'
10+
11+
env:
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13+
DOTNET_NOLOGO: true
14+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
15+
16+
jobs:
17+
build-and-test:
18+
name: Build & Test (${{ matrix.os }})
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest]
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup .NET
31+
uses: actions/setup-dotnet@v5
32+
with:
33+
dotnet-version: 10.0.x
34+
35+
- name: Cache NuGet packages
36+
uses: actions/cache@v4
37+
with:
38+
path: ${{ env.NUGET_PACKAGES }}
39+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
40+
restore-keys: ${{ runner.os }}-nuget-
41+
42+
- name: Restore
43+
run: dotnet restore BeyondNet.Bootstrapper.sln
44+
45+
- name: Build
46+
run: dotnet build BeyondNet.Bootstrapper.sln --configuration Release --no-restore
47+
48+
- name: Test
49+
run: dotnet test BeyondNet.Bootstrapper.sln --configuration Release --no-build --logger "trx;LogFileName=results.trx"
50+
51+
- name: Upload test results
52+
uses: actions/upload-artifact@v4
53+
if: always()
54+
with:
55+
name: test-results-${{ matrix.os }}
56+
path: "**/*.trx"
57+
58+
version:
59+
name: Determine Version
60+
runs-on: ubuntu-latest
61+
needs: build-and-test
62+
if: github.event_name == 'push' || github.event_name == 'tag'
63+
outputs:
64+
version: ${{ steps.version.outputs.version }}
65+
is_release: ${{ steps.version.outputs.is_release }}
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
70+
- name: Get version from tag
71+
id: version
72+
run: |
73+
TAG="${GITHUB_REF#refs/tags/}"
74+
if [[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
75+
VERSION="${TAG#v}"
76+
echo "version=$VERSION" >> $GITHUB_OUTPUT
77+
echo "is_release=true" >> $GITHUB_OUTPUT
78+
else
79+
HASH="${GITHUB_SHA:0:7}"
80+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
81+
echo "version=0.0.0-$BRANCH_NAME+$HASH" >> $GITHUB_OUTPUT
82+
echo "is_release=false" >> $GITHUB_OUTPUT
83+
fi
84+
85+
pack:
86+
name: Pack NuGet Packages
87+
runs-on: ubuntu-latest
88+
needs: [build-and-test, version]
89+
if: needs.version.outputs.is_release == 'true'
90+
strategy:
91+
matrix:
92+
project:
93+
- src/BeyondNetCode.Shell.Bootstrapper/BeyondNetCode.Shell.Bootstrapper.csproj
94+
- src/BeyondNetCode.Shell.Bootstrapper.DependencyInjection/BeyondNetCode.Shell.Bootstrapper.DependencyInjection.csproj
95+
- src/BeyondNetCode.Shell.Bootstrapper.AutoMapper/BeyondNetCode.Shell.Bootstrapper.AutoMapper.csproj
96+
- src/BeyondNetCode.Shell.Bootstrapper.Observability/BeyondNetCode.Shell.Bootstrapper.Observability.csproj
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- name: Setup .NET
101+
uses: actions/setup-dotnet@v5
102+
with:
103+
dotnet-version: 10.0.x
104+
105+
- name: Pack
106+
run: |
107+
dotnet pack "${{ matrix.project }}" \
108+
-c Release \
109+
--version:${{ needs.version.outputs.version }} \
110+
--no-build \
111+
-p:PackageOutputPath=${{ github.workspace }}/nupkgs
112+
113+
- name: Upload artifacts
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: packages-${{ matrix.project }}
117+
path: nupkgs/*.nupkg
118+
119+
publish:
120+
name: Publish to NuGet
121+
runs-on: ubuntu-latest
122+
needs: pack
123+
if: needs.pack.result == 'success' && needs.version.outputs.is_release == 'true'
124+
environment: nuget-release
125+
126+
steps:
127+
- name: Download packages
128+
uses: actions/download-artifact@v4
129+
with:
130+
pattern: packages-*
131+
path: ./nupkgs
132+
merge-multiple: true
133+
134+
- name: Setup .NET
135+
uses: actions/setup-dotnet@v5
136+
with:
137+
dotnet-version: 10.0.x
138+
139+
- name: Push to NuGet.org
140+
run: |
141+
for nupkg in $(find ./nupkgs -name '*.nupkg'); do
142+
dotnet nuget push "$nupkg" \
143+
--api-key ${{ secrets.NUGET_API_KEY }} \
144+
--source https://api.nuget.org/v3/index.json \
145+
--skip-duplicate
146+
done
147+
env:
148+
DOTNET_CLI_TELEMETRY_OPTOUT: '1'
149+
150+
release:
151+
name: Create GitHub Release
152+
runs-on: ubuntu-latest
153+
needs: [version]
154+
if: needs.version.outputs.is_release == 'true'
155+
steps:
156+
- uses: actions/checkout@v4
157+
158+
- name: Generate Release Notes
159+
id: release-notes
160+
uses: actions/github-script@v7
161+
with:
162+
script: |
163+
const { data: commits } = await github.rest.repos.listCommits({
164+
owner: context.repo.owner,
165+
repo: context.repo.repo,
166+
per_page: 100,
167+
since: '2024-01-01'
168+
});
169+
let body = '## What\'s New\n\n';
170+
body += `**Version:** ${context.payload.ref.replace('refs/tags/', '')}\n\n`;
171+
body += '### Commits\n';
172+
commits.slice(0, 20).forEach(c => {
173+
body += `- ${c.commit.message.split('\n')[0]} (${c.sha.slice(0, 7)})\n`;
174+
});
175+
return body;
176+
177+
- name: Create Release
178+
uses: softprops/action-gh-release@v2
179+
with:
180+
tag_name: ${{ github.ref_name }}
181+
name: Release ${{ github.ref_name }}
182+
body: ${{ steps.release-notes.outputs.result }}
183+
draft: false
184+
prerelease: ${{ contains(needs.version.outputs.version, 'beta') || contains(needs.version.outputs.version, 'alpha') }}
185+
env:
186+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)