Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

cenk1cenk2/old-drone-semantic-release

 
 

Repository files navigation

drone-semantic-release

Build Status Docker Pulls Docker Image Size (latest by date) Docker Image Version (latest by date) GitHub last commit

Drone plugin for making semantic releases based on https://github.com/semantic-release/semantic-release. With some added twists ofc.

Usage

See commit message format to use it.

Add the following to the drone configuration

kind: pipeline
name: default

steps:
  - name: semantic-release
    image: cenk1cenk2/drone-semantic-release
    settings:
      # arguments: -- # semantic release
      semantic_release: true # enable or disable semantic release
      arguments: # if you want to add arguments to semantic release
      override: # if you want to change the command compeletely
      add_apk: # install apk packages for exec step of semantic release
      add_modules: # install node packages if desired
      mode: release # "release" means the actual release and "predict" means to generate the version in dry run to use it e.g. before build
      git_method: gh # set for git authentication with gh (Github), gl (GitLab), bb (BitBucket), cr (Credentials)
      use_local_rc: false # use defaults or a custom rc file true | false
      # arguments: -- # arguments for passing to the semantic-release
      git_user_name: bot # semantic release committer name (git config user.name), defaults to semantic-release
      git_user_email: [email protected] # semantic release committer email (git config user.email)
      github_token: # semantic release token (for authentication)
        from_secret: github_token
      npm_token: # semantic release token (for authentication)
        from_secret: npm_token
      # If you are not using this token you can use the general password login
      npm_username:
        from_secret: npm_username
      npm_password:
        from_secret: npm_password
      npm_email:
        from_secret: npm_email
      # arguments: -- # arguments for updating readme on dockerhub, readme_location is set from up
      update_readme_toc: true # update the readme utilizing https://www.npmjs.com/package/markdown-toc
      readme_location: "README.md $(find packages -maxdepth 2 -name README.md | paste -sd ' ')" # readme path
      # arguments: -- # arguments for updating readme on dockerhub, readme_location is set from up
      # if you want to push readme to docker hub in this step
      update_docker_readme: false
      docker_username:
        from_secret: docker_username
      docker_password:
        from_secret: docker_password
      docker_repo: cenk1cenk2/some-repository

or for BitBucket

bitbucket_token: # semantic release token (for authentication)
  from_secret: token

or for GitLab

gitlab_token: # semantic release token (for authentication)
  from_secret: token

or for any git server (including BitBucket cloud which does not support tokens):

git_login: bot
git_password:
  from_secret: password

Custom Release File

You can overwrite the default configuration defined in release.config.js by adding release.config.js or .releaserc to your repository. But this can be overwritten by setting use_local_rc variable to true.

What it does

Runs on master branch only. Skips any actions below while on other branches.

  • automatically creates a semantic version number
  • attaches the version number as repo's git tag
  • automatically creates, populates and pushes CHANGELOG.md to your master branch

Use this with Gitlab-CI with some trick

Just add the same variables with PLUGIN_ prefix. Since Gitlab tries to run it in another directory this can be overcome by copying all the files in /drone/src then copying it back. It is not the perfect solution but it kind of works.

publish:
  stage: publish
  image: cenk1cenk2/drone-semantic-release
  variables:
    PLUGIN_GIT_METHOD: gl
    PLUGIN_GIT_USER_EMAIL: $GIT_USER_EMAIL
    PLUGIN_GITLAB_TOKEN: $GITLAB_TOKEN
    PLUGIN_UPDATE_README_TOC: 'true'
    PLUGIN_README_LOCATION: "README.md $(find packages -maxdepth 2 -name README.md | paste -sd ' ')"
    PLUGIN_NPM_TOKEN: $NPM_TOKEN
    DRONE_REPO_BRANCH: $CI_COMMIT_REF_NAME
  before_script:
    - apk add --no-cache --no-progress rsync
    - rsync -a $CI_PROJECT_DIR/ /drone/src/
    - cd /drone/src
  script:
    - /semantic-release/release.sh
  after_script:
    - rsync -a /drone/src/ $CI_PROJECT_DIR/

About

Drone semantic release plugin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 79.6%
  • JavaScript 14.1%
  • Dockerfile 6.3%