Files
FA_WEB/.woodpecker.yml
2026-01-02 21:13:19 +01:00

99 lines
3.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# .woodpecker.yml uniwersalny dla dowolnej wersji .NET (6.0+)
when:
event: [push, tag]
branch: [main]
steps:
restore:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- dotnet restore
volumes:
- nuget-cache:/root/.nuget/packages
test:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- dotnet test --no-restore --configuration Release --logger "trx" --results-directory /tmp/test-results
build:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- dotnet build --no-restore --configuration Release
deploy:
image: mcr.microsoft.com/dotnet/sdk:latest
secrets: [baget_api_key, baget_url]
volumes:
- /opt/deployment:/deploy-host
- nuget-cache:/root/.nuget/packages
commands:
- |
set -euo pipefail
echo "=== Informacje o projekcie ==="
echo "Repo: ${CI_REPO_NAME}"
echo "Commit: ${CI_COMMIT_SHA:0:8}"
echo "Branch/Tag: ${CI_COMMIT_REF}"
echo "SDK version: $(dotnet --version)"
# Odczytujemy tylko metadane typu projektu
PROJECT_TYPE=$(dotnet msbuild -getProperty:ProjectType -noLogo 2>/dev/null || echo "Unknown")
DEPLOY_TO_CENTRAL=$(dotnet msbuild -getProperty:DeployToCentral -noLogo 2>/dev/null || echo "false")
echo "ProjectType: $PROJECT_TYPE"
echo "DeployToCentral: $DEPLOY_TO_CENTRAL"
case "$PROJECT_TYPE" in
DataModel)
echo "→ Pakowanie i publikacja do BaGet"
dotnet pack --no-build --configuration Release -o /tmp/nupkg
for pkg in /tmp/nupkg/*.nupkg; do
dotnet nuget push "$pkg" \
--api-key "${BAGET_API_KEY}" \
--source "${BAGET_URL}" \
--skip-duplicate
done
echo "Publikacja NuGet zakończona."
;;
ConsoleApp|Api|Blazor)
if [[ "$DEPLOY_TO_CENTRAL" != "true" ]]; then
echo "DeployToCentral=false pomijam deploy."
exit 0
fi
echo "→ Publikacja $PROJECT_TYPE"
PUBLISH_ARGS="--no-build -c Release -o /tmp/publish"
if [[ "$PROJECT_TYPE" == "ConsoleApp" ]]; then
RID=$(dotnet msbuild -getProperty:RuntimeIdentifier -noLogo 2>/dev/null || echo "linux-x64")
SELF_CONTAINED=$(dotnet msbuild -getProperty:SelfContained -noLogo 2>/dev/null || echo "true")
SINGLE_FILE=$(dotnet msbuild -getProperty:PublishSingleFile -noLogo 2>/dev/null || echo "true")
PUBLISH_ARGS="$PUBLISH_ARGS --self-contained $SELF_CONTAINED -r $RID -p:PublishSingleFile=$SINGLE_FILE"
else
TRIMMED=$(dotnet msbuild -getProperty:PublishTrimmed -noLogo 2>/dev/null || echo "true")
PUBLISH_ARGS="$PUBLISH_ARGS -p:PublishTrimmed=$TRIMMED"
fi
dotnet publish $PUBLISH_ARGS
TARGET_DIR="/deploy-host/$PROJECT_TYPE/${CI_REPO_NAME}"
mkdir -p "$TARGET_DIR"
cp -r /tmp/publish/* "$TARGET_DIR/"
find "$TARGET_DIR" -type f \( -name "*.dll" -o -name "*.exe" -o -perm /111 \) -exec chmod +x {} \; 2>/dev/null || true
echo "Deploy zakończony → $TARGET_DIR"
;;
*)
echo "Nieznany ProjectType brak akcji."
;;
esac
volumes:
- name: nuget-cache
temp: {}