AIFotoOnlus/.gitlab-ci.yml

58 lines
2.1 KiB
YAML

stages:
- build
- publish
# Only create pipelines automatically when a Git tag is pushed.
# Otherwise the pipeline must be started manually (pipeline "Run" / dispatch equivalent).
workflow:
rules:
- if: '$CI_COMMIT_TAG'
when: always
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 /p:GeneratePackageOnBuild=false
artifacts:
paths:
- src/AIFotoONLUS.Core/bin/**
expire_in: 1 hour
publish_nuget:
stage: publish
image: mcr.microsoft.com/dotnet/sdk:10.0
dependencies:
- build
variables:
NUGET_SOURCE: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/nuget/index.json"
script: |
dotnet restore src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj
git fetch --prune --unshallow || true
git fetch origin +refs/heads/*:refs/remotes/origin/* || true
git branch --show-current || true
# If build was triggered by a Git tag, use that tag as the package version (strip leading 'v').
# Otherwise rely on MinVer inside the project to infer a semantic version from git history.
if [ -n "$CI_COMMIT_TAG" ]; then
PACKAGE_VERSION="${CI_COMMIT_TAG#v}"
echo "Using tag version: $PACKAGE_VERSION"
dotnet pack src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj -c Release -o nuget --no-build /p:PackageVersion="$PACKAGE_VERSION" /p:EnableWindowsTargeting=true
else
echo "No tag detected; using MinVer to infer version at pack time"
dotnet pack src/AIFotoONLUS.Core/AIFotoONLUS.Core.csproj -c Release -o nuget --no-build /p:EnableWindowsTargeting=true
fi
dotnet nuget push "nuget/*.nupkg" --source "$NUGET_SOURCE" --api-key "$CI_JOB_TOKEN" --skip-duplicate
# Pipeline creation is controlled by the top-level `workflow` rules.
# This job will run when the pipeline is created for a tag or when manually started.