Sha256: de459099b8bce24c46760a0757e94d780f09828b71458441f285cf351bc5827a

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

stages:
  - version
  - deploy
  - release

workflow:
  rules:
    # For merge requests, create a pipeline.
    - if: '$CI_MERGE_REQUEST_IID'
    # For default branch, create a pipeline.
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
    # For tags, never create pipeline.
    - if: '$CI_COMMIT_TAG'
      when: never

Update version:
  stage: version
  image: ruby:2.7.5
  before_script:
    - gem install gfsm
  script:
    - gfsm version bump --force > .version
    - gfsm changelog --force --output-file CHANGELOG.md
    - echo "RELEASE_VERSION=$(<.version)" >> variables.env
  artifacts:
    reports:
      dotenv: variables.env
    paths:
      - .version
      - CHANGELOG.md
    
# Publish gem:
# - GEM_HOST_API_KEY: A valid RubyGems API key.
Publish gem:
  stage: deploy
  image: ruby:2.7.5
  variables:
    GEMSPEC_FILE: "gfsm.gemspec"
    GEM_FILE: "gfsm-${RELEASE_VERSION}.gem"
  before_script:
    - |
      rm -f ./*.gem
      [ -f "${GEMSPEC_FILE}" ] || (echo "No ${GEMSPEC_FILE} file found!" && exit 1)
  script:
    - |
      gem build "${GEMSPEC_FILE}"
      [ -f "${GEM_FILE}" ] || (echo "No ${GEM_FILE} file found!" && exit 1)
      gem push "${GEM_FILE}"
  artifacts:
    paths:
      - "*.gem"
  rules:
    - if: '$GEM_HOST_API_KEY == null'
      when: never
    - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

Create release:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  script:
    - |
      release-cli create --name "Release v$RELEASE_VERSION" --description CHANGELOG.md --tag-name "v$RELEASE_VERSION"
  needs:
    - job: "Update version"
      artifacts: true
    - job: "Publish gem"
      artifacts: false
  rules:
    - if: '$GEM_HOST_API_KEY == null'
      when: never
    - if: '$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH'
      when: never
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gfsm-0.2.0 .gitlab-ci.yml
gfsm-0.1.4 .gitlab-ci.yml