A Mind United

Development notes, docs, and scribbles.

Semantic Release

Automated Semantic Versioning.

Analyzes commits, and optionally:

Pre Installation

Before installing semantic release the project must

Pre-installed

Additional

Community Plugins

What we are setting up…

When there is a successful merge to the main branch, Semantic release will

While it does this, it can also:

Installation

Install all features covered here

npm install semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/release-notes-generator semantic-release-contributors @google/semantic-release-replace-plugin --save-dev

Install by Feature

Semantic Release

npm install semantic-release --save-dev

Plugins

# Changelog
npm install @semantic-release/changelog --save-dev
# Git (if the project does not use github)
npm install @semantic-release/git --save-dev
# Release Notes
npm install @semantic-release/release-notes-generator --save-dev
# Contributers List
npm install semantic-release-contributors --save-dev
# Update Release Version references in codebase
npm install @google/semantic-release-replace-plugin --save-dev

Add a Release Config

As documented here, and remove any features or plugins that you are not using.

Clean up

Release.Config.js

Package.json

For each of these config that has been created, remove it from the Package.json:

### CI/CD

⚠️ Warnings ⚠️

  1. The CI/CD must have rewite (history) access to the git repository.

    • Add read/write and ‘modify history’ rights for the CI/CD in the repo.
  2. Semantic Release will not work in the CI/CD unless it is specifically installed.

    • Add npx semantic-release to your build steps before you run npm scripts.

ie (circle CI):

  # Javascript Node CircleCI 2.0 configuration file
  #
  # Check https://circleci.com/docs/2.0/language-javascript/ for more details
  #
  version: 2

  defaults: &defaults
    working_directory: ~/repo
    docker:
      - image: circleci/node:12.16.3

  jobs: # Declare the jobs
    # Create a Job Named Test
    test:
      <<: *defaults
      steps:
        - checkout # Checkout the Code
        - run: npm install # Install dependencies
        - run: npm run build # Run the build
        - run: npm test # Run the tests
    # Create a Job Named Release
    release:
      <<: *defaults
      steps:
        - checkout # Checkout the Code
        - run: npm install # Install dependencies
        - run: npx semantic-release # Setup Semantic Release

  workflows: # Declare the workflows (there's only one)
    version: 2
    test-and-deploy:
      jobs:
        - test # Call the 'test' Job
        - release: # Call the Release job...but only if:
            requires:
              - test # the 'test' job has passed
            filters:
              branches:
                only:
                  - master # and this is the Master Banch
                ignore: /.*/

References

npm

semantic release gitbook

Semantic release Docs