Enhance NuGet configuration by adding auditSources section and updating release workflow to improve package versioning and restore processes. Adjust parallelism for package pushing and refine build commands for better efficiency.

This commit is contained in:
2026-05-30 16:27:16 +03:30
parent 6a0e724eb0
commit cf13f4faae
2 changed files with 37 additions and 37 deletions
+34 -37
View File
@@ -8,14 +8,12 @@ on:
env: env:
DOTNET_NOLOGO: true DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NUGET_SOURCE_URL: https://nuget.sabp.ir/v3/index.json NUGET_SOURCE_URL: https://nuget.sabp.ir/v3/index.json
NUGET_PUSH_PARALLELISM: 4
PACKAGE_OUTPUT: ./artifacts/nuget PACKAGE_OUTPUT: ./artifacts/nuget
PACKAGE_PROJECTS: src/SufiChain.SufiBlazor/SufiChain.SufiBlazor.csproj PACKAGE_PROJECTS: src/SufiChain.SufiBlazor/SufiChain.SufiBlazor.csproj
# TODO: Uncomment these when demo packages are ready to build and release. # TODO: Add demo packages here when they are ready for release.
# PACKAGE_PROJECTS: >-
# src/SufiChain.SufiBlazor/SufiChain.SufiBlazor.csproj
# src/SufiChain.SufiBlazor.Demo.Localization/SufiChain.SufiBlazor.Demo.Localization.csproj
# src/SufiChain.SufiBlazor.Demo/SufiChain.SufiBlazor.Demo.csproj
RELEASE_TAG: ${{ gitea.event.release.tag_name }} RELEASE_TAG: ${{ gitea.event.release.tag_name }}
REF_NAME: ${{ gitea.ref_name }} REF_NAME: ${{ gitea.ref_name }}
REPOSITORY: ${{ gitea.repository }} REPOSITORY: ${{ gitea.repository }}
@@ -32,46 +30,46 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
git clone --depth 1 https://git.sabp.ir/sufi-chain/sufi-blazor.git . git clone --depth 1 https://git.sabp.ir/sufi-chain/sufi-blazor.git .
echo "=== Workspace contents ==="
ls -la
- name: Restore selected projects - name: Set package version
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
for project in $PACKAGE_PROJECTS; do
dotnet restore "$project"
done
- name: Build selected projects
shell: bash
run: |
set -euo pipefail
for project in $PACKAGE_PROJECTS; do
dotnet build "$project" --configuration Release --no-restore
done
- name: Pack selected projects
shell: bash
run: |
set -euo pipefail
mkdir -p "$PACKAGE_OUTPUT"
if [ -n "${RELEASE_TAG:-}" ]; then if [ -n "${RELEASE_TAG:-}" ]; then
version="$RELEASE_TAG" version="$RELEASE_TAG"
else else
version="0.0.0-dev.$(date +%Y%m%d%H%M%S)" version="0.0.0-dev.$(date +%Y%m%d%H%M%S)"
fi fi
version="${version#v}" version="${version#v}"
echo "=== Packing version: $version ===" echo "VERSION=$version" >> "$GITHUB_ENV"
echo "Package version: $version"
- name: Restore selected projects
shell: bash
run: |
set -euo pipefail
for project in $PACKAGE_PROJECTS; do for project in $PACKAGE_PROJECTS; do
dotnet pack "$project" \ dotnet restore "$project" \
--verbosity minimal \
-p:NuGetAudit=false
done
- name: Build and pack selected projects
shell: bash
run: |
set -euo pipefail
mkdir -p "$PACKAGE_OUTPUT"
for project in $PACKAGE_PROJECTS; do
dotnet build "$project" \
--configuration Release \ --configuration Release \
--no-build \ --no-restore \
--output "$PACKAGE_OUTPUT" \ --verbosity minimal \
-p:PackageVersion="$version" \ -m \
-p:ContinuousIntegrationBuild=true -p:PackageVersion="$VERSION" \
-p:ContinuousIntegrationBuild=true \
-p:BuildInParallel=true \
-p:PackageOutputPath="$PWD/$PACKAGE_OUTPUT" \
-p:GeneratePackageOnBuild=true
done done
- name: Push packages to BaGet - name: Push packages to BaGet
@@ -85,16 +83,15 @@ jobs:
exit 1 exit 1
fi fi
shopt -s nullglob mapfile -t packages < <(find "$PACKAGE_OUTPUT" -type f -name '*.nupkg' ! -name '*.symbols.nupkg' | sort)
packages=("$PACKAGE_OUTPUT"/*.nupkg)
if [ ${#packages[@]} -eq 0 ]; then if [ ${#packages[@]} -eq 0 ]; then
echo "No NuGet packages were produced." echo "No NuGet packages were produced."
exit 1 exit 1
fi fi
for package in "${packages[@]}"; do printf '%s\0' "${packages[@]}" | xargs -0 -n 1 -P "$NUGET_PUSH_PARALLELISM" sh -c '
dotnet nuget push "$package" \ dotnet nuget push "$1" \
--source "$NUGET_SOURCE_URL" \ --source "$NUGET_SOURCE_URL" \
--api-key "$NUGET_API_KEY" \ --api-key "$NUGET_API_KEY" \
--skip-duplicate --skip-duplicate
done ' sh
+3
View File
@@ -5,4 +5,7 @@
<add key="liara-mirror" value="https://package-mirror.liara.ir/repository/nuget/index.json" /> <add key="liara-mirror" value="https://package-mirror.liara.ir/repository/nuget/index.json" />
<add key="sufi-nuget" value="https://nuget.sabp.ir/v3/index.json" /> <add key="sufi-nuget" value="https://nuget.sabp.ir/v3/index.json" />
</packageSources> </packageSources>
<auditSources>
<clear />
</auditSources>
</configuration> </configuration>