Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
soenneker committed Oct 22, 2024
1 parent 6a91cd3 commit dd2a5b9
Show file tree
Hide file tree
Showing 18 changed files with 1,094 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"automerge": true,
"prHourlyLimit": 0,
"autoApprove": true
}
51 changes: 51 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build-and-test
on:
# Testing - run for any PRs.
pull_request:
branches:
- main

env:
"PipelineEnvironment": true

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- 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

- name: Test
run: dotnet test test/Soenneker.Utils.RateLimiting.Executor.Tests/Soenneker.Utils.RateLimiting.Executor.Tests.csproj --no-restore --verbosity normal

- name: Pack
run: dotnet pack --no-build --configuration Release --output .
80 changes: 80 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: publish-package
on:
push:
branches:
- main

tags:
- v*

env:
"PipelineEnvironment": true

jobs:
publish-package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setting up build version
run: |
version=$(($GITHUB_RUN_NUMBER))
echo "BUILD_VERSION=2.1.$version" >> ${GITHUB_ENV}
- name: Setup .NET Core 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- 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

- name: Test
run: dotnet test test/Soenneker.Utils.RateLimiting.Executor.Tests/Soenneker.Utils.RateLimiting.Executor.Tests.csproj --no-restore --verbosity normal

- name: Pack
run: dotnet pack --no-build --configuration Release --output .

- 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
Loading

0 comments on commit dd2a5b9

Please sign in to comment.