fix: proper restore and disable auto-push in CI
- Add restore step before build - Add CI=true env to disable PushToFoursatNuget target - Add --allow-insecure-connections to csproj push command - Add Condition to skip push target in CI
This commit is contained in:
@@ -26,6 +26,8 @@ jobs:
|
|||||||
git log -1 --format="%H %s"
|
git log -1 --format="%H %s"
|
||||||
|
|
||||||
- name: Pack and Push Protobuf packages
|
- name: Pack and Push Protobuf packages
|
||||||
|
env:
|
||||||
|
CI: "true"
|
||||||
run: |
|
run: |
|
||||||
echo "📦 Looking for Protobuf projects..."
|
echo "📦 Looking for Protobuf projects..."
|
||||||
|
|
||||||
@@ -49,14 +51,19 @@ jobs:
|
|||||||
# Get project directory
|
# Get project directory
|
||||||
proj_dir=$(dirname "$proj")
|
proj_dir=$(dirname "$proj")
|
||||||
|
|
||||||
# Build and pack
|
# Restore first
|
||||||
|
echo " → Restoring..."
|
||||||
|
dotnet restore "$proj"
|
||||||
|
|
||||||
|
# Build
|
||||||
echo " → Building..."
|
echo " → Building..."
|
||||||
dotnet build "$proj" -c Release --no-restore 2>/dev/null || dotnet restore "$proj" && dotnet build "$proj" -c Release
|
dotnet build "$proj" -c Release --no-restore
|
||||||
|
|
||||||
|
# Pack without running PushToFoursatNuget target
|
||||||
echo " → Packing..."
|
echo " → Packing..."
|
||||||
dotnet pack "$proj" -c Release --no-build -o "$proj_dir/nupkg"
|
dotnet pack "$proj" -c Release --no-build -o "$proj_dir/nupkg" -p:RunPushTarget=false
|
||||||
|
|
||||||
# Push to Nexus (skip-duplicate will ignore if already exists)
|
# Push to Nexus manually (skip-duplicate will ignore if already exists)
|
||||||
echo " → Pushing to Nexus..."
|
echo " → Pushing to Nexus..."
|
||||||
for nupkg in $proj_dir/nupkg/*.nupkg; do
|
for nupkg in $proj_dir/nupkg/*.nupkg; do
|
||||||
if [ -f "$nupkg" ]; then
|
if [ -f "$nupkg" ]; then
|
||||||
@@ -64,8 +71,7 @@ jobs:
|
|||||||
--source "${{ env.NEXUS_URL }}" \
|
--source "${{ env.NEXUS_URL }}" \
|
||||||
--api-key "${{ env.NEXUS_USER }}:${{ env.NEXUS_PASS }}" \
|
--api-key "${{ env.NEXUS_USER }}:${{ env.NEXUS_PASS }}" \
|
||||||
--skip-duplicate \
|
--skip-duplicate \
|
||||||
--allow-insecure-connections || echo " ⚠️ Package may already exist"
|
--allow-insecure-connections && echo " ✅ Pushed: $(basename $nupkg)" || echo " ⏭️ Skipped (exists)"
|
||||||
echo " ✅ Done: $(basename $nupkg)"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -63,10 +63,10 @@
|
|||||||
<Protobuf Include="Protos\inventory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
<Protobuf Include="Protos\inventory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PushToFoursatNuget" AfterTargets="Pack">
|
<Target Name="PushToFoursatNuget" AfterTargets="Pack" Condition="'$(RunPushTarget)' != 'false' AND '$(CI)' != 'true'">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
|
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
|
||||||
<PushCommand>dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate </PushCommand>
|
<PushCommand>dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate --allow-insecure-connections</PushCommand>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Exec Command="$(PushCommand)" />
|
<Exec Command="$(PushCommand)" />
|
||||||
|
|||||||
Reference in New Issue
Block a user