Skip to content

CI integration: allow adding [skip ci] to semantic-release commit #153

Closed

Description

@Sieboldianus

We've successfully implemented semantic-release in our Gitlab CI workflow on the master-release branch, passing GL_TOKEN through as a protected variable.

There's a minor inconvenience, when semantic-release pushes the new version to the branch within the CI job, it'll trigger the pipeline again (resulting in one needless CI run).

As far as I know, semantic-release allows making use of the [skip ci] flag in semantic-release commit. I wonder if this is the only solution - then maybe it would make sense allowing to set a flag --skip-ci to python-semantic-release which would add [skip ci] to the version commit (or, even better, using ci.skip flag in the git push, not messing up commit messages). Maybe it would even make sense passing this flag by default, since the version-commit will likely have no new code.

Here's our gitlab-ci.yml, for completeness:

build:
  image: python:alpine
  stage: build
  variables:
    GITLAB_CI : "true"
  script:
    - apk update && apk add git
    # checkout to release branch
    - git checkout -B "$CI_BUILD_REF_NAME" "$CI_BUILD_REF"
    - git config --global user.name "semantic-release (via GitlabCI)"
    - git config --global user.email "semantic-release@gitlab"
    # install python-semantic-release
    - pip install python-semantic-release
    # publish release
    - semantic-release publish
  only:
  - master-release

Activity

  1. Sieboldianus commented on Oct 24, 2019

    @Sieboldianus
    ContributorAuthor

    Well, that was fast: there's a gitlab feature only:changes/except:changes (considered alpha) that allows skipping pipelines for certain files in gitlab-ci.yml, e.g. if semantic-release version variable is set to .version:__version__ then the following gitlab-ci entry will skip the pipeline for changes to this file:

      except:
        changes:
          - .version

    Yay!

    I'll leave this open for any comments, please feel free to close it as solved!

  2. relekang commented on Oct 24, 2019

    @relekang
    Member

    It'll trigger the pipeline again (resulting in one needless CI run).

    Considering this needless is kind of subjective I think. Running the CI job is required to get the a green build for the tag for some combinations of CI and VCS hosting.

    I am open to have an option that adds [skip ci] to the commit message, but it needs to be optional and of by default.

  3. Sieboldianus commented on Oct 24, 2019

    @Sieboldianus
    ContributorAuthor

    Yes, I agree - there may be applications that I am not aware of that need CI every time, even if just on a version upgrade. Also, with the except-changes we have a solution that works for us. Many thanks for the explanation! So, I'll close this - anyone interested may still continue adding comments..

  4. gabrielSoudry commented on Feb 7, 2022

    @gabrielSoudry

    For those who would be interested (I had trouble finding this information) in gitlab you could use this to skip the CI :

    [semantic_release]
    commit_subject = chore(release): Release v{version} [skip ci]
    
    

    [Skip Ci] Skip CI on commit release

  5. louison commented on Jan 20, 2023

    @louison

    For those who would be interested (I had trouble finding this information) in gitlab you could use this to skip the CI :

    [semantic_release]
    commit_subject = chore(release): Release v{version} [skip ci]
    

    [Skip Ci] Skip CI on commit release

    Works also like a charm on Google Cloud Build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions