rjw-sexperience-ideology/.gitlab-ci.yml

78 lines
2.9 KiB
YAML

# ### Specify the Docker image
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
# ### Define variables
variables:
# 1) Name of directory where restore and build objects are stored.
OBJECTS_DIRECTORY: 'IdeologyAddon/obj'
# 2) Name of directory used for keeping restored dependencies.
NUGET_PACKAGES_DIRECTORY: '.nuget'
# 3) A relative path to the source code from project repository root.
SOURCE_CODE_PATH: 'Source/'
# ### Define global cache rule
cache:
# Per-stage and per-branch caching.
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
paths:
# 1) Main JSON file holding information about package dependency tree, packages versions,
# frameworks etc. It also holds information where to the dependencies were restored.
- '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/project.assets.json'
# 2) Other NuGet and MSBuild related files. Also needed.
- '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/*.csproj.nuget.*'
# 3) Path to the directory where restored dependencies are kept.
- '$NUGET_PACKAGES_DIRECTORY'
policy: pull-push
# ### Restore project dependencies
#
# NuGet packages by default are restored to '.nuget/packages' directory
# in the user's home directory. That directory is out of scope of GitLab caching.
#
# To get around this, a custom path can be specified using the '--packages <PATH>' option
# for 'dotnet restore' command. In this example, a temporary directory is created
# in the root of project repository, so its content can be cached.
#
# Learn more about GitLab cache: https://docs.gitlab.com/ee/ci/caching/index.html
#before_script:
# - 'cd $SOURCE_CODE_PATH'
# - 'dotnet restore --packages ../$NUGET_PACKAGES_DIRECTORY'
build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH != "master"
# ### Build all projects discovered from solution file.
script:
- 'cd $SOURCE_CODE_PATH'
- 'dotnet restore --packages ../$NUGET_PACKAGES_DIRECTORY'
- 'dotnet build -c Release --no-restore'
- 'cd $CI_PROJECT_DIR/About'
- 'mv -f RealAbout.xml About.xml'
artifacts:
untracked: false
when: on_success
expire_in: 1 day
paths:
- "*" # Incluse everything
exclude:
- ".*" # Exclude dot files
- ".*/**/*" # Exclude everything in the dot folders
- "Source/**/*" # Exclude everything in the Source folder
release_dev:
stage: deploy
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == "dev" # Run this job when commits are pushed or merged to the dev branch
variables:
GIT_STRATEGY: none # Do not clone repo and skip 'before_script'
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/rsi/test"
script:
- apk add zip
- zip -rq mod.zip ./
- echo "${PACKAGE_REGISTRY_URL}"
- 'curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file mod.zip "${PACKAGE_REGISTRY_URL}/rjw_sexperience_ideology.zip"'