Skip to content

Commit e6a3cde

Browse files
authored
Merge pull request #1 from darkpatternsdigital/add-ci
Add GitHub build actions
2 parents 404383d + b044aba commit e6a3cde

3 files changed

Lines changed: 105 additions & 5 deletions

File tree

.github/workflows/dotnet-build.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: All packages build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches:
8+
- '**/*'
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
permissions:
15+
packages: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ./.github/workflows/parts/cache/
20+
21+
- name: Decode the Signing Key
22+
# Generated via powershell: `[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes('.\Refactoring.snk')) | Set-Clipboard` and saved to GitHub Secrets SIGNING_KEY
23+
run: |
24+
if [ -n "${{ secrets.SIGNING_KEY }}" ]; then
25+
echo "${{ secrets.SIGNING_KEY }}" | base64 --decode > ./Refactoring.snk
26+
fi
27+
28+
###########
29+
# BUILD
30+
- name: Restore dependencies
31+
run: dotnet restore
32+
- name: Build
33+
run: |
34+
if [[ $VERSION_SUFFIX ]]; then
35+
VERSION_SUFFIX_PARAM="--version-suffix sha.$VERSION_SUFFIX"
36+
else
37+
VERSION_SUFFIX_PARAM=''
38+
fi
39+
dotnet build --no-restore --configuration Release ${VERSION_SUFFIX_PARAM}
40+
env:
41+
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }}
42+
43+
###########
44+
# TEST
45+
- name: Test
46+
run: |
47+
if [[ $VERSION_SUFFIX ]]; then
48+
VERSION_SUFFIX_PARAM="-p:VersionSuffix=sha.$VERSION_SUFFIX"
49+
else
50+
VERSION_SUFFIX_PARAM=''
51+
fi
52+
dotnet test --verbosity normal ${VERSION_SUFFIX_PARAM} --configuration Release --collect:"XPlat Code Coverage"
53+
env:
54+
VERSION_SUFFIX: ${{ github.ref != 'refs/heads/main' && github.sha || '' }}
55+
- name: 'Upload Code Coverage'
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: code-coverage
59+
path: ./lib/*/TestResults/*/coverage.cobertura.xml
60+
retention-days: 7
61+
# - name: Record code coverage
62+
# uses: 5monkeys/cobertura-action@master
63+
# with:
64+
# path: ./lib/*/TestResults/*/coverage.cobertura.xml
65+
# repo_token: ${{ secrets.GITHUB_TOKEN }}
66+
# minimum_coverage: 90
67+
# fail_below_threshold: false
68+
69+
###########
70+
# PUBLISH
71+
- name: Publish NuGet packages to GitHub registry if new version number
72+
if: ${{ github.ref != 'refs/heads/main' }}
73+
run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${GITHUB_TOKEN} -s https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json --skip-duplicate --no-symbols
74+
continue-on-error: true # Dependabot and other outside contributors can't push to our GitHub packages
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
- name: Publish NuGet packages to NuGet registry if new version number
78+
if: ${{ github.ref == 'refs/heads/main' }}
79+
run: dotnet nuget push ./artifacts/package/release/*.nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate --no-symbols
80+
env:
81+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 'Package Cache'
2+
description: 'Caches packages for this repository'
3+
inputs: {}
4+
outputs: {}
5+
runs:
6+
using: 'composite'
7+
steps:
8+
# .NET install and cache
9+
- uses: actions/setup-dotnet@v3
10+
with:
11+
# The main version this project uses
12+
dotnet-version: '10.0.x'
13+
14+
- uses: actions/cache@v3
15+
with:
16+
path: ~/.nuget/packages
17+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
18+
restore-keys: |
19+
${{ runner.os }}-nuget-
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
1818

1919
<SignAssembly>True</SignAssembly>
20-
<AssemblyOriginatorKeyFile Condition="exists('$(SolutionRoot)OpenApiCodegen.snk')">$(SolutionRoot)OpenApiCodegen.snk</AssemblyOriginatorKeyFile>
20+
<AssemblyOriginatorKeyFile Condition="exists('$(SolutionRoot)Refactoring.snk')">$(SolutionRoot)Refactoring.snk</AssemblyOriginatorKeyFile>
2121
<NoWarn Condition="$(MSBuildProjectName.Contains('Test'))">$(NoWarn);CS8002;CA1054</NoWarn>
2222
</PropertyGroup>
2323

@@ -33,14 +33,14 @@
3333
<Import Project="Directory.Build.local.props" Condition="exists('$(MSBuildThisFileDirectory)Directory.Build.local.props')" />
3434

3535
<PropertyGroup>
36-
<Authors>Dark Patterns Digital, Principle Studios, Matt DeKrey, Tony Mishler, Chris Lees</Authors>
37-
<PackageProjectUrl>https://github.com/darkpatternsdigital/openapi-generators</PackageProjectUrl>
38-
<RepositoryUrl>https://github.com/darkpatternsdigital/openapi-generators.git</RepositoryUrl>
36+
<Authors>Dark Patterns Digital, Matt DeKrey</Authors>
37+
<PackageProjectUrl>https://github.com/darkpatternsdigital/DarkPatterns.Refactoring</PackageProjectUrl>
38+
<RepositoryUrl>https://github.com/darkpatternsdigital/DarkPatterns.Refactoring.git</RepositoryUrl>
3939
<RepositoryType>git</RepositoryType>
4040
<RepositoryBranch>main</RepositoryBranch>
4141
<PublishRepositoryUrl>true</PublishRepositoryUrl>
4242
<PackageIcon>dpd-logo.png</PackageIcon>
43-
<Copyright>2026 Matt DeKrey; Dark Patterns Digital, LCA; &amp; Principle Studios</Copyright>
43+
<Copyright>2026 Matt DeKrey; Dark Patterns Digital, LCA</Copyright>
4444
<PackageLicenseExpression>BSD-2-Clause</PackageLicenseExpression>
4545
<PackageReadmeFile>README.md</PackageReadmeFile>
4646
</PropertyGroup>

0 commit comments

Comments
 (0)