Commit cfcacc77 authored by shRabbit's avatar shRabbit
Browse files

Publish pipeline: only create release on tag to enter CI/CD Catalog

The component project has no real solution to build. A tag pipeline previously ran
the dotnet restore/build/test/publish jobs, all failed (no .sln), skipping
create-release. Now the pipeline only publishes the tagged version to the Catalog.
parent 02b0967d
Loading
Loading
Loading
Loading
Loading
+6 −38
Original line number Diff line number Diff line
# This pipeline builds the component repository itself and keeps the
# `dotnet-build` component published at the referencing commit/tag.

workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - when: always
# This pipeline publishes the `dotnet-build` component to the CI/CD Catalog.
#
# The component project is only a template repository (no real solution to build),
# so this pipeline does NOT build anything itself. When a tag is pushed, it runs
# the create-release job which publishes the tagged component version into the
# CI/CD Catalog. See https://docs.gitlab.com/ee/ci/components/#publish-a-new-release

stages:
  - build
  - test
  - release

include:
  # Include the dotnet-build component located in this repository at the
  # current SHA so the component is validated on every push.
  - component: $CI_SERVER_FQDN/$CI_PROJECT_PATH/dotnet-build@$CI_COMMIT_SHA
    inputs:
      # The repository is just a component skeleton, so there is no real
      # solution to build. Override these when consuming the component.
      solution_path: "**/*.sln"
      tests_enabled: true
      publish_enabled: true

# Validate that the `dotnet-build` job was injected by the component.
ensure-component-added:
  stage: test
  image: badouralix/curl-jq
  rules:
    - if: $CI_PROJECT_VISIBILITY != "public"
      when: never
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - when: always
  script: |
    url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs"
    curl --fail --show-error --silent "$url" |
    jq --exit-status 'map(select(.name | contains("dotnet-build"))) | length >= 1'

create-release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest