Skip to content

Commit

Permalink
Move to new structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Soenneker committed Sep 17, 2024
1 parent 0af0748 commit 389d9e4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 14 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,26 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
- name: Install dependencies with retry
run: |
retries=5
base_wait_time=15
exponent=2
for i in $(seq 1 $retries); do
if dotnet restore; then
break
fi
if [ $i -lt $retries ]; then
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
echo "dotnet restore failed, retrying in $wait_time seconds..."
sleep $wait_time
else
echo "dotnet restore failed after $retries retries."
exit 1
fi
done
- name: Build
run: dotnet build --configuration Release --no-restore
Expand Down
47 changes: 41 additions & 6 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
branches:
- main

# Publish `v1.2.3` tags as releases.
tags:
- v*

Expand All @@ -15,7 +14,6 @@ jobs:
publish-package:
runs-on: ubuntu-latest

#{Services}
steps:
- uses: actions/checkout@v4

Expand All @@ -29,8 +27,26 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Install dependencies
run: dotnet restore
- name: Install dependencies with retry
run: |
retries=5
base_wait_time=15
exponent=2
for i in $(seq 1 $retries); do
if dotnet restore; then
break
fi
if [ $i -lt $retries ]; then
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
echo "dotnet restore failed, retrying in $wait_time seconds..."
sleep $wait_time
else
echo "dotnet restore failed after $retries retries."
exit 1
fi
done
- name: Build
run: dotnet build --configuration Release --no-restore
Expand All @@ -41,5 +57,24 @@ jobs:
- name: Pack
run: dotnet pack --no-build --configuration Release --output .

- name: Publish to nuGet
run: dotnet nuget push **\*.nupkg --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate
- name: Publish to NuGet with retry
run: |
nupkg_files=$(find . -name "*.nupkg")
retries=5
base_wait_time=20
exponent=3.5
for i in $(seq 1 $retries); do
if dotnet nuget push $nupkg_files --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate; then
break
fi
if [ $i -lt $retries ]; then
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
echo "NuGet publish failed, retrying in $wait_time seconds..."
sleep $wait_time
else
echo "NuGet publish failed after $retries retries."
exit 1
fi
done
16 changes: 11 additions & 5 deletions Soenneker.Utils.AutoBogus.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\publish-package.yml = .github\workflows\publish-package.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Soenneker.Utils.AutoBogus.Tests", "test\Soenneker.Utils.AutoBogus.Tests\Soenneker.Utils.AutoBogus.Tests.csproj", "{6456E465-9523-4612-9115-9D9B585B42E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E355F0FD-671D-4F99-A5C3-2F0442EFD8CD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{DD733813-BAA4-429B-90A7-8E7ADE196683}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Soenneker.Utils.AutoBogus.Tests.Console", "test\Soenneker.Utils.AutoBogus.Console\Soenneker.Utils.AutoBogus.Tests.Console.csproj", "{4BC4BD23-23A3-407D-8EA7-261FAD46E653}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Soenneker.Utils.AutoBogus.Tests", "test\Soenneker.Utils.AutoBogus.Tests\Soenneker.Utils.AutoBogus.Tests.csproj", "{6456E465-9523-4612-9115-9D9B585B42E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8D2D7C4E-6519-4211-B09C-1B0E55A0F684}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BA9DE495-DEC7-4A01-984B-8388B7ACD5A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -51,8 +53,12 @@ Global
{D786EC1A-4F59-412F-8624-83E6E3525B0C} = {4E42254D-039C-40ED-B3F4-8C1A94A366D1}
{6456E465-9523-4612-9115-9D9B585B42E8} = {E355F0FD-671D-4F99-A5C3-2F0442EFD8CD}
{4BC4BD23-23A3-407D-8EA7-261FAD46E653} = {E355F0FD-671D-4F99-A5C3-2F0442EFD8CD}
EndGlobalSection

{41850636-33B4-4228-AE59-A2113F66B9FA} = {8D2D7C4E-6519-4211-B09C-1B0E55A0F684}

{6456E465-9523-4612-9115-9D9B585B42E8} = {BA9DE495-DEC7-4A01-984B-8388B7ACD5A1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B849EC5C-B7B3-4C90-9B66-CBC15CCB776A}
EndGlobalSection
EndGlobal
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand Down

0 comments on commit 389d9e4

Please sign in to comment.