Loading .gitlab-ci.yml +21 −187 Original line number Diff line number Diff line stages: - build - release - publish - deploy - update .is_release_stable: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "false" .is_release_preview: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_PREVIEW_PATTERN_RULE && $CI_CONTAINER_UPDATE == "false" .is_container_update_old: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "true" && $CI_CONTAINER_LATEST == "false" .is_container_update_latest: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "true" && $CI_CONTAINER_LATEST == "true" include: - project: "abfelbaum/ci" file: - "dotnet/standard.yml" - "dotnet/nuget.yml" dotnet:build:tmp: variables: RELEASE_STABLE_PATTERN: '^([01-9]\d*)\.([0-9]\d*)\.([0-9]\d*)$' RELEASE_STABLE_PATTERN_RULE: '/^([01-9]\d*)\.([0-9]\d*)\.([0-9]\d*)$/' RELEASE_PREVIEW_PATTERN: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$' RELEASE_PREVIEW_PATTERN_RULE: '/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/' CI_CONTAINER_UPDATE: 'false' CI_CONTAINER_UPDATE_LATEST: 'false' image: registry.git.abfelbaum.dev/abfelbaum/images/dotnet/sdk:6.0 build: stage: build except: - tags - schedules script: - dotnet build -c Release build-server: stage: build only: - tags script: - dotnet build -c Release -o build Server/AbfiBin.Server.csproj - dotnet publish -c Release -o publish Server/AbfiBin.Server.csproj artifacts: paths: - publish/ build-cli: stage: build only: - tags except: - pipelines script: - dotnet build -c Release -o build CommandLine/AbfiBin.CommandLine.csproj - dotnet publish -c Release -o publish CommandLine/AbfiBin.CommandLine.csproj - dotnet pack -c Release -o pack CommandLine/AbfiBin.CommandLine.csproj artifacts: paths: - pack/ DOTNET_PROJECT_PATH: "Server/AbfiBin.Server.csproj" release-semantic-release: stage: release image: registry.git.abfelbaum.dev/abfelbaum/images/semantic-release:latest when: manual except: - tags - pipelines - schedules before_script: - openssl aes-256-cbc -K $OPENSSL_KEY -iv $OPENSSL_IV -base64 -in $OPENSSL_FILE -out /tmp/git_gpg_keys.asc -d - chmod 600 /tmp/git_gpg_keys.asc - gpg --batch --yes --import /tmp/git_gpg_keys.asc - git config commit.gpgsign true - git config --global user.signingkey ${GPG_KEY_ID} script: - semantic-release release-gitlab-release: stage: release image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest only: - tags except: - pipelines script: - echo "Create release for $CI_COMMIT_TAG" release: name: $CI_COMMIT_TAG description: $CI_COMMIT_MESSAGE tag_name: $CI_COMMIT_TAG publish-cli-gitlab: stage: publish only: - tags except: - pipelines dependencies: - build-cli before_script: - dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text script: - dotnet nuget push "pack/*.nupkg" --source gitlab publish-cli-nuget: stage: publish only: - tags except: - pipelines dependencies: - build-cli script: - dotnet nuget push "pack/*.nupkg" --api-key $NUGET_TOKEN --source "https://api.nuget.org/v3/index.json" publish-server: stage: publish only: - tags dependencies: - build-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint init - waypoint build artifacts: public: false paths: - data.db publish-server-latest: stage: publish rules: - !reference [.is_release_stable, rules] - !reference [.is_container_update_latest, rules] dependencies: - publish-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - docker image tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE:latest" - docker push "$CI_REGISTRY_IMAGE:latest" deploy-server-testing: stage: deploy rules: - !reference [.is_release_preview, rules] - !reference [.is_container_update_latest, rules] dependencies: - publish-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint deploy environment: name: AbfiBin Testing deployment_tier: testing url: https://testing.bin.abfelbaum.dev dotnet:build:release: variables: DOTNET_PROJECT_PATH: "Server/AbfiBin.Server.csproj" deploy-server-production: stage: deploy dependencies: - publish-server rules: - !reference [.is_release_stable, rules] - !reference [.is_container_update_latest, rules] image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint deploy environment: name: AbfiBin deployment_tier: production url: https://bin.abfelbaum.dev dotnet:pack:tmp: variables: DOTNET_PROJECT_PATH: "CommandLine/AbfiBin.CommandLine.csproj" update: stage: update only: - schedules script: - git tag --list --sort=version:refname | grep -E $RELEASE_STABLE_PATTERN | head -n -1 | tail -n +6 | xargs -I % curl --request POST --form "variables[CI_CONTAINER_UPDATE]=true" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline?token=$CI_JOB_TOKEN&ref=%" - git tag --list --sort=version:refname | grep -E $RELEASE_STABLE_PATTERN | tail -n 1 | xargs -I % curl --request POST --form "variables[CI_CONTAINER_LATEST]=true" --form "variables[CI_CONTAINER_UPDATE]=true" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline?token=$CI_JOB_TOKEN&ref=%" No newline at end of file dotnet:pack:release: variables: DOTNET_PROJECT_PATH: "CommandLine/AbfiBin.CommandLine.csproj" No newline at end of file Loading
.gitlab-ci.yml +21 −187 Original line number Diff line number Diff line stages: - build - release - publish - deploy - update .is_release_stable: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "false" .is_release_preview: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_PREVIEW_PATTERN_RULE && $CI_CONTAINER_UPDATE == "false" .is_container_update_old: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "true" && $CI_CONTAINER_LATEST == "false" .is_container_update_latest: rules: - if: $CI_COMMIT_TAG =~ $RELEASE_STABLE_PATTERN_RULE && $CI_CONTAINER_UPDATE == "true" && $CI_CONTAINER_LATEST == "true" include: - project: "abfelbaum/ci" file: - "dotnet/standard.yml" - "dotnet/nuget.yml" dotnet:build:tmp: variables: RELEASE_STABLE_PATTERN: '^([01-9]\d*)\.([0-9]\d*)\.([0-9]\d*)$' RELEASE_STABLE_PATTERN_RULE: '/^([01-9]\d*)\.([0-9]\d*)\.([0-9]\d*)$/' RELEASE_PREVIEW_PATTERN: '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$' RELEASE_PREVIEW_PATTERN_RULE: '/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?$/' CI_CONTAINER_UPDATE: 'false' CI_CONTAINER_UPDATE_LATEST: 'false' image: registry.git.abfelbaum.dev/abfelbaum/images/dotnet/sdk:6.0 build: stage: build except: - tags - schedules script: - dotnet build -c Release build-server: stage: build only: - tags script: - dotnet build -c Release -o build Server/AbfiBin.Server.csproj - dotnet publish -c Release -o publish Server/AbfiBin.Server.csproj artifacts: paths: - publish/ build-cli: stage: build only: - tags except: - pipelines script: - dotnet build -c Release -o build CommandLine/AbfiBin.CommandLine.csproj - dotnet publish -c Release -o publish CommandLine/AbfiBin.CommandLine.csproj - dotnet pack -c Release -o pack CommandLine/AbfiBin.CommandLine.csproj artifacts: paths: - pack/ DOTNET_PROJECT_PATH: "Server/AbfiBin.Server.csproj" release-semantic-release: stage: release image: registry.git.abfelbaum.dev/abfelbaum/images/semantic-release:latest when: manual except: - tags - pipelines - schedules before_script: - openssl aes-256-cbc -K $OPENSSL_KEY -iv $OPENSSL_IV -base64 -in $OPENSSL_FILE -out /tmp/git_gpg_keys.asc -d - chmod 600 /tmp/git_gpg_keys.asc - gpg --batch --yes --import /tmp/git_gpg_keys.asc - git config commit.gpgsign true - git config --global user.signingkey ${GPG_KEY_ID} script: - semantic-release release-gitlab-release: stage: release image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest only: - tags except: - pipelines script: - echo "Create release for $CI_COMMIT_TAG" release: name: $CI_COMMIT_TAG description: $CI_COMMIT_MESSAGE tag_name: $CI_COMMIT_TAG publish-cli-gitlab: stage: publish only: - tags except: - pipelines dependencies: - build-cli before_script: - dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text script: - dotnet nuget push "pack/*.nupkg" --source gitlab publish-cli-nuget: stage: publish only: - tags except: - pipelines dependencies: - build-cli script: - dotnet nuget push "pack/*.nupkg" --api-key $NUGET_TOKEN --source "https://api.nuget.org/v3/index.json" publish-server: stage: publish only: - tags dependencies: - build-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint init - waypoint build artifacts: public: false paths: - data.db publish-server-latest: stage: publish rules: - !reference [.is_release_stable, rules] - !reference [.is_container_update_latest, rules] dependencies: - publish-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" - docker image tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" "$CI_REGISTRY_IMAGE:latest" - docker push "$CI_REGISTRY_IMAGE:latest" deploy-server-testing: stage: deploy rules: - !reference [.is_release_preview, rules] - !reference [.is_container_update_latest, rules] dependencies: - publish-server image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint deploy environment: name: AbfiBin Testing deployment_tier: testing url: https://testing.bin.abfelbaum.dev dotnet:build:release: variables: DOTNET_PROJECT_PATH: "Server/AbfiBin.Server.csproj" deploy-server-production: stage: deploy dependencies: - publish-server rules: - !reference [.is_release_stable, rules] - !reference [.is_container_update_latest, rules] image: registry.git.abfelbaum.dev/abfelbaum/images/builder:latest script: - waypoint deploy environment: name: AbfiBin deployment_tier: production url: https://bin.abfelbaum.dev dotnet:pack:tmp: variables: DOTNET_PROJECT_PATH: "CommandLine/AbfiBin.CommandLine.csproj" update: stage: update only: - schedules script: - git tag --list --sort=version:refname | grep -E $RELEASE_STABLE_PATTERN | head -n -1 | tail -n +6 | xargs -I % curl --request POST --form "variables[CI_CONTAINER_UPDATE]=true" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline?token=$CI_JOB_TOKEN&ref=%" - git tag --list --sort=version:refname | grep -E $RELEASE_STABLE_PATTERN | tail -n 1 | xargs -I % curl --request POST --form "variables[CI_CONTAINER_LATEST]=true" --form "variables[CI_CONTAINER_UPDATE]=true" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/trigger/pipeline?token=$CI_JOB_TOKEN&ref=%" No newline at end of file dotnet:pack:release: variables: DOTNET_PROJECT_PATH: "CommandLine/AbfiBin.CommandLine.csproj" No newline at end of file