Giter Club home page Giter Club logo

semantics's Introduction

@priestine/semantics

Build Status codecov npm npm

licence: MIT code style: prettier versioning: semantics

@priestine/semantics automates version bumping for your projects. It determines the next SemVer version number, generates the release notes, updates the CHANGELOG and publishes the release tag.

Features

  • Compatibility with Github, Gitlab and Bitbucket
  • Automated versioning that follows SemVer
  • Automatically generated release notes
  • Simple and transparent way of releasing your code
  • Support for formalized commits that follow widely adopted Conventional Commits specification
  • Works with any programming loanguage
  • Simple integration with any CI/CD tool
  • Convenience Docker images for your entertainment

Installation

npm i -g @priestine/semantics

GitLab CI using Docker image

The easiest way to use the app is to go get the Docker image from Docker Cloud. You can create a separate job in your .gitlab-ci.yml that will bump your versions. In fact, it is as simple as:

# .gitab-ci.yml

stages:
  - versioning

versioning:
  stage: versioning
  image: priestine/semantics:latest
  script:
  - priestine-semantics --prefix=v
  only:
  - master

Travis CI

# .travis.yml

language: node_js
node_js:
  - "10"
stages:
  - name: versioning
    if: branch = master
jobs:
  include:
    - stage: versioning
      script:
        - npm install -g @priestine/semantics
        - priestine-semantics --user=$CI_USER --password=$CI_PASSWORD --prefix=v

Docker image info

Docker Pulls Docker Stars MicroBadger Layers MicroBadger Size

priestine/semantics:latest Docker image is built from node:10-alpine.

There are also priestine/semantics@alpine version which is equal to priestine/semantics:latest as well as priestine/semantics:slim with the same contents yet based on node:10-slim.

Docker images are built on each priestine/semantics release so you can stick to the version you are comfortable with, e.g. priestine/semantics:2.8.0-alpine or priestine/semantics:2.8.0-slim.

Manual usage

If you want to run @priestine/semantics yourself locally (or elsewhere except for CI) you will need Node.js 8 or higher installed on your machine. Simply install the package globally. Then, in your project directory, run:

priestine-semantics

Customizing behaviour

You can customize the behaviour of priestine-semantics command by providing command line options. All CL options resemble ConfigInterface properties written as kebab-case keys with double hyphen (--) before the key and equals sign (=) between the key and the value (=<value> is optional and converts to =true if it wasn't provided). To provide CL options, simply provide them after the command itself, e.g.:

priestine-semantics --prefix=v --precise-version-matching

Alternatively, you can use environment variables. All env variables exposed by @priestine/semantics resemble ConfigInterface properties written as UPPER_SNAKE_CASE keys with an equals sign (=) between the key and the value. Unlike CL options, environment variables MUST have a value.

PREFIX=v priestine-semantics

Command Line Options

  • --user=<username> - existing user that has access to the repository.
  • --password=<value> - user password or access token for publishing tags.
  • --git-user-name=<value> - name of a git user who will be associated with the release.
  • --git-user-email=<value> - email of a git user who will be associated with the release.
  • --publish-tag[=<true|false>] - if true, @priestine/semantics will attempt to publish release tag to the platform. Defaults to true.
  • --oldest-commits-first[=<true|false>] - if true, commits in the release notes will be sorted chronologically, oldest to latest. Defaults to true.
  • --tag-message[=<true|false>] - if true, tag release notes will be generated and added as release message when publishing. Defaults to true.
  • --prefix=<value> - set prefix for newly created version (e.g. --prefix=v -> v1.0.0).
  • --postfix=<value> - set postfix for newly created version (e.g. --postfix=-beta -> 1.0.0-beta).
  • --write-to-changelog[=<true|false>] - if true, tag release notes will be prepended to ./CHANGELOG.md. Defaults to true.
  • --origin=<value> - custom remote origin to push release tag to. If not specified, updates are pushed to the current repository.
  • --write-temporary-files[=<true|false>] - if true, @priestine/semantics will create temporary files containing the data gathered during its execution (NOTE: temporary files are not generated if there are no reasons for version bumping)
  • --precise-version-matching[=<true|false>] - if true, @priestine/semantics will look for previous versions with given prefix and/or postfix instead of just looking for any previous SemVer-like tag. This is helpful for leading several changelogs for various types of releases.
  • --exclude-merges[=<true|false>] - if true, merge request commits will be excluded when evaluating changes since latest version. Defaults to true.

Environment Variables

  • USER=<username> - existing user that will be associated with the release.
  • PASSWORD=<value> - user password or access token for publishing tags.
  • GIT_USER_NAME=<value> - name of a git user who will be associated with the release.
  • GIT_USER_EMAIL=<value> - email of a git user who will be associated with the release.
  • PROJECT_PATH=<value> - project path for building the URL in chosen platform for publishing the release tag. E.g. priestine/semantics stored on Github will mean publishing to https://api.github.com/repos/priestine/semantics/releases.
  • PUBLISH_TAG=<true|false> - if true, @priestine/semantics will attempt to publish release tag to the platform. Defaults to true.
  • OLDEST_COMMITS_FIRST=<true|false> - if true, commits in the release notes will be sorted chronologically, oldest to latest. Defaults to true.
  • TAG_MESSAGE=<true|false> - if true, tag release notes will be generated and added as release message when publishing. Defaults to true.
  • PREFIX=<value> - set prefix for newly created version (e.g. PREFIX=v -> v1.0.0).
  • POSTFIX=<value> - set postfix for newly created version (e.g. POSTFIX=-beta -> 1.0.0-beta).
  • WRITE_TO_CHANGELOG=<true|false> - if true, tag release notes will be prepended to ./CHANGELOG.md. Defaults to true.
  • ORIGIN=<value> - custom remote origin to push release tag to. If not specified, updates are pushed to the current repository.
  • WRITE_TEMPORARY_FILES=<true|false> - if true, @priestine/semantics will create temporary files containing the data gathered during its execution (NOTE: temporary files are not generated if there are no reasons for version bumping)
  • PRECISE_VERSION_MATCHING=<true|false> - if true, @priestine/semantics will look for previous versions with given prefix and/or postfix instead of just looking for any previous SemVer-like tag. This is helpful for leading several changelogs for various types of releases.
  • EXCLUDE_MERGES=<true|false> - if true, merge request commits will be excluded when evaluating changes since latest version. Defaults to true.

Temporary files

While running, @priestine/semantics generates a few temporary files for your disposal.

Temporary file output will only be created if a new release is required.

Temporary file description

.tmp.current_commit_data (Example)

The commit assigned to the previous tag (if there was previous release tag in place for current project).

4ed93c713f65eff843406a549c740132c99da123

.tmp.current_tag_data (Example)

Previous tag (if there was previous release tag in place for current project).

2.2.3

.tmp.version_data (Example)

The version that should be assigned according to the contents of the commits.

2.2.4

.tmp.current_changes.json (Example)

JSON containing all the commits that were evaluated.

[
  {
    "hash": "4ed93c713f65eff843406a549c740132c99da123",
    "abbrevHash": "4ed93c7",
    "author": {
      "name": "priestine1",
      "email": "[email protected]"
    },
    "subject": "Correct writing of normalized changes to JSON",
    "body": [],
    "issueReference": "#25",
    "type": "fix",
    "breakingChanges": []
  },
  {
    "hash": "36af8aaa38cea6613c773ce55390a09d7e5898d0",
    "abbrevHash": "36af8aa",
    "author": {
      "name": "priestine1",
      "email": "[email protected]"
    },
    "subject": "Last attempt to fix publishing for today",
    "body": [],
    "issueReference": "#14",
    "type": "fix",
    "breakingChanges": []
  }
]

.tmp.changelog.md (Example)

Markdown changelog for evaluated commits.

# 2.2.4


## Bug Fixes

`A bug fix`

* **4ed93c7**: Correct writing of normalized changes to JSON (**#25**)
* **36af8aa**: Last attempt to fix publishing for today (**#14**)

Supported Versions

Version Supported
5.1.x
5.0.x
4.0.x
< 4.0

Badge

Let people know that your package is published using @priestine/semantics by including the badge in your README:

[![versioning: semantics](https://img.shields.io/badge/versioning-semantics-912e5c.svg)](https://github.com/priestine/semantics)

semantics's People

Contributors

dependabot[bot] avatar orlowdev avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

semantics's Issues

Support for command line options

Add support for CL options alongside long options:

  • --repository -r
  • --publish-tag -p
  • --oldest-commits-first -c
  • --commit-types-included-in-tag-message -i
  • --commit-types-excluded-from-tag-message -e
  • --tag-message -m
  • --private-token -t
  • --write-temporary-files -w
  • --precise-version-matching -M

Options must support single token syntax if they do not require a value (-cMpw === -c -M -p -w).

Options must support value provision with or without space if they require a value (-t12345 === -t 12345).

Only options listed before -- argument are taken into consideration.

Fix GLOB postfix exclusion if precise version matching is on

If there is both prefix and postfix set for versions without precise version matching (e.g. v1.2.3-rc and v1.2.4-rc already existing) and prefix set for versions with precise version matching (e.g. v1.2.3which does not exist yet) and current version isv1.2.2, the version update suggestion will be v1.2.5instead ofv1.2.3` because the GLOB pattern for finding the appropriate tag will be v*.

CL long options without value default to true

If a command line argument does not require a value, =$VALUE can be omitted and it will automatically be referred to as true.

Example

priestine-semantics --tag-message

is equivalent to

priestine-semantics --tag-message=true

If the default value for the option is true, =false MUST be specified to disable it.

This applies to both options and long options.

Support for setting array options via CL and env

Environment variables

In environment variables, array values can be specified with valid JSON string:

COMMIT_TYPES_EXCLUDED_FROM_TAG_MESSAGE=["fix", "feat"]

CL args

With command line, the same key can be passed multiple times with different values and they will be collected (works both with options and long options):

priestine-semantics -e fix -e feat

Support for setting config via semantics.config.js

Extracting @priestine/semantics configuration from semantics.config.js. This file must export an object containing the values that override defaults.

If configFilePath option is specified, it should be referenced instead of current working directory to look for the configuration file.

These options have lower priority than command line args and environment variables.

Support for setting config via semantics.yml (semantics.yaml)

Extracting @priestine/semantics configuration from semantics.yml or semantics.yaml. This file must export an object containing the values that override defaults.

If configFilePath option is specified, it should be referenced instead of current working directory to look for the configuration file.

These options have lower priority than command line args and environment variables.

Support for setting config via .semanticsrc

Extracting @priestine/semantics configuration from .semanticsrc. This file must export an object containing the values that override defaults.

If configFilePath option is specified, it should be referenced instead of current working directory to look for the configuration file.

These options have lower priority than command line args and environment variables.

Automatic project path resolution for Gitlab-hosted projects running in Gitlab CI

In Gitlab CI, the CI_PROJECT_PATH environment variable is available for getting the project path. This variable can be used to automatically deduce the projectPath setting value if the chosen platform is gitlab and the projectPath setting is not specified.

This check should happen after updating the config object with ENV contents.

Add setting for controlling --no-merge flag

Add option for ignoring or including merge request commits in commit log since latest version for deducing the new version release.

This can be helpful for cases when developers do not use Conventional Commits and version bumping is supposed to be based on contents of the merge request that MUST follow Conventional Commits specification or each commit will be considered a fix.

[ENHANCEMENT] Move CLI args/env vars description to a single table

Is your feature request related to a problem? Please describe.
Priestine Semantics configuration description is repeated twice in README. Putting it in a single table could improve readability and visually connect both approaches.

Describe the solution you'd like

CLI options Environment Variables Default value Description
--repository=<github|gitlab> REPOSITORY=<github|gitlab> github Blah

Support for setting config via semantics.json

Extracting @priestine/semantics configuration from semantics.json. This file must export an object containing the values that override defaults.

If configFilePath option is specified, it should be referenced instead of current working directory to look for the configuration file.

These options have lower priority than command line args and environment variables.

Support for setting config via package.json

Extracting @priestine/semantics configuration from package.json (config -> priestine-semantics).

If configFilePath option is specified, it should be referenced instead of current working directory to look for the configuration file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.