Skip to content

Update dependency Soenneker.Utils.Runtime to 4.0.993 (#2139) #1922

Update dependency Soenneker.Utils.Runtime to 4.0.993 (#2139)

Update dependency Soenneker.Utils.Runtime to 4.0.993 (#2139) #1922

name: publish-package
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
paths-ignore:
- 'test/**'
workflow_dispatch:
permissions:
contents: write
packages: write
env:
PipelineEnvironment: true
NUGET_XMLDOC_MODE: skip
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Setting up build version
shell: bash
run: |
echo "BUILD_VERSION=4.0.${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV"
- name: Get release notes from latest commit
shell: bash
run: |
notes="$(git log -1 --pretty=%B | sed '/^Co-authored-by:/d')"
{
echo "PACKAGE_RELEASE_NOTES<<EOF"
printf '%s\n' "$notes"
echo "EOF"
} >> "$GITHUB_ENV"
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Restore tests
run: dotnet restore test/Soenneker.Utils.HttpClientCache.Tests/Soenneker.Utils.HttpClientCache.Tests.csproj --verbosity minimal
- name: Build tests
run: dotnet build test/Soenneker.Utils.HttpClientCache.Tests/Soenneker.Utils.HttpClientCache.Tests.csproj --configuration Release --no-restore --verbosity minimal
- name: Test
run: dotnet test test/Soenneker.Utils.HttpClientCache.Tests/Soenneker.Utils.HttpClientCache.Tests.csproj --configuration Release --no-build --no-restore --verbosity normal
- name: Restore library
run: dotnet restore src/Soenneker.Utils.HttpClientCache/Soenneker.Utils.HttpClientCache.csproj --verbosity minimal
- name: Build library
run: dotnet build src/Soenneker.Utils.HttpClientCache/Soenneker.Utils.HttpClientCache.csproj --configuration Release --no-restore --verbosity minimal
- name: Pack
shell: bash
run: |
mkdir -p artifacts
dotnet pack src/Soenneker.Utils.HttpClientCache/Soenneker.Utils.HttpClientCache.csproj \
--configuration Release \
--no-build \
--no-restore \
--output ./artifacts
- name: Publish to NuGet
shell: bash
run: |
set -euo pipefail
for i in 1 2; do
output_file="$(mktemp)"
set +e
dotnet nuget push ./artifacts/*.nupkg \
--source "https://api.nuget.org/v3/index.json" \
--api-key "${{ secrets.NUGET__TOKEN }}" \
--skip-duplicate 2>&1 | tee "$output_file"
exit_code=${PIPESTATUS[0]}
set -e
if [ $exit_code -eq 0 ]; then
exit 0
fi
if grep -qiE 'Quota Exceeded|retry after:' "$output_file"; then
echo "NuGet throttled this publish. Not retrying inside the same job."
exit 1
fi
if [ "$i" -lt 2 ]; then
echo "Transient failure, retrying once in 15 seconds..."
sleep 15
else
exit $exit_code
fi
done
- name: Publish to GitHub Packages
shell: bash
run: |
dotnet nuget push ./artifacts/*.nupkg \
--source "https://nuget.pkg.github.com/soenneker/index.json" \
--api-key "${{ secrets.GH__TOKEN }}" \
--skip-duplicate
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GH__TOKEN }}
shell: bash
run: |
gh release create "v$BUILD_VERSION" \
--title "v$BUILD_VERSION" \
--notes "${{ env.PACKAGE_RELEASE_NOTES }}"