AIFotoOnlus/.gitlab-ci.yml

49 lines
1.8 KiB
YAML

stages:
- build
- publish
variables:
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
DOTNET_NOLOGO: "true"
GIT_DEPTH: "0"
image: mcr.microsoft.com/dotnet/sdk:10.0
before_script:
- dotnet --info
build:
stage: build
script:
- dotnet restore src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj
- dotnet build src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj --configuration Release --no-restore
artifacts:
paths:
- src/AIFotoONLUS.Core/bin/**
expire_in: 1 hour
publish_nuget:
stage: publish
image: mcr.microsoft.com/dotnet/sdk:10.0
variables:
NUGET_SOURCE: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/nuget/index.json"
script: |
dotnet restore
git fetch --prune --unshallow || true
git fetch origin +refs/heads/*:refs/remotes/origin/* || true
git branch --show-current || true
- dotnet tool install --global GitVersion.Tool --version 6.5.1 || true
export PATH="$PATH:~/.dotnet/tools"
# Build a NuGet-safe version: MajorMinorPatch-EscapedBranchName.PreReleaseNumber
MM=$(dotnet-gitversion /showvariable MajorMinorPatch 2>/dev/null || gitversion /showvariable MajorMinorPatch 2>/dev/null || echo "0.1.0")
BR=$(dotnet-gitversion /showvariable EscapedBranchName 2>/dev/null || gitversion /showvariable EscapedBranchName 2>/dev/null || echo "master")
PR=$(dotnet-gitversion /showvariable PreReleaseNumber 2>/dev/null || gitversion /showvariable PreReleaseNumber 2>/dev/null || echo "0")
PACKAGE_VERSION="${MM}-${BR}.${PR}"
PACKAGE_VERSION=$(echo "$PACKAGE_VERSION" | sed 's/[^0-9A-Za-z.-]//g')
echo "Package version: $PACKAGE_VERSION"
dotnet pack src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj -c Release -o nuget /p:PackageVersion="$PACKAGE_VERSION"
dotnet nuget push "nuget/*.nupkg" --source "$NUGET_SOURCE" --api-key "$CI_JOB_TOKEN" --skip-duplicate
only:
- main
- master
- tags