1.5.2 • Published 8 years ago

semantique v1.5.2

Weekly downloads
13
License
MIT
Repository
github
Last release
8 years ago

semantique

Semver, the old fashioned way

Semantic versioning based purely on current Git workspace without dependencies on package registries or CI systems (though you can integrate one if you want).

Current VersionLatest BuildDependenciesDev DependenciesNPMDocker
npm versionBuild StatusProd DependenciesDev DependenciesNPM DownloadsDocker Pulls

How It Works

The semantique package checks the current working directory to determine any changes that have been made since the last tag on the branch. Commits use semver like directives to indicate the nature of the change.

The following prefixes are recognised by default:

PrefixesSemver MeaningNotesExamples
breakMajorWhen a breaking change has occured.break(module): No longer default X to YBreaks all of the stuff.
featMinorA new feature or widening change to an operational contract/API.feat(something): Added widget frobber.Feature: Something else.
patch / bugfix / fixPatchA fix to correct a deviation from specified behaviours.fix(something): Shouldn't do that.PATCH: Urgently prevent disaster.

Any other commits that are not prefixed with the above are assumed to be non-consequential and not trigger a new version.

In short:

  1. Run npm install -g semantique
  2. Commit your changes to your projects.
  3. Run semantique

The package will then read the commits and tags, determine the next tag (defaulting to 1.0.0 for the first hit)

Example Projects

I've switched many of my own packages to use semantique, such as my IOC module, somersault. The .drone.yml for that project represents what I'd consider best practices for using this module.

Running with CI Systems (Drone, GoCD)

To run with a CI system, I publish a convienient docker image. This image can be used with your pipeline such as:

    pipeline:
       install_npm_packages:
            image: node:4
            commands:
                - npm install
                - npm test

        run_semantique_self:
            image: eventualconsistency/semantique
            pull: true
            when:
                branch: master
                event: push

It is assumed that the upstream origin URL is already set on your git workspace for the purposes of publishing. You need to set the following environment variables (as secrets in Drone/GoCD):

Environment VariableUsed For
GIT_USERUsername for publishing changes back to the upstream Git repository.
GIT_PASSPassword or personal access token (recommended) for publishing changes back to upstream.

The following environment variables are used to configure other aspects of the behaviour of semantique:

Environment VariableDefaultNotes
SQ_CMD_FETCHgit fetch --tagsThe command to fetch the tags for the current repo. Runs before processing.
SQ_CMD_LOGSgit log --date=iso --pretty=format:\"%H ||| %an ||| %s ||| %d\"Command to extract the logs from SCM for parsing.
SQ_CMD_LOGDELIMITER|||Log delimiter for output.
SQ_CMD_LINEEND\nLine ending for parsing output
SQ_CMD_WORKSPACEPENDINGgit diff --name-onlyCommand for checking if the workspace is clean.
SQ_CMD_PUSHgit push origin master --tagsCommand for pushing back to upstream branch.
SQ_COMMIT_MESSAGEUpdated to version %s for release.Default message for commits
SQ_DEFAULT_VERSION1.0.0Initial version when no previous tags found on repo.
SQ_OPT_CHECKCLEANtrueCheck if the workspace is clean. Set to 0/false to allow dirty workspaces.
SQ_OPT_APPLYVERSIONtrueApply the versioning command to the package type. Set to 0/false to skip the version bump command
SQ_OPT_PUSHtruePush to upstream repository after success?

Security and other Considerations

Be sure to:

  • Configure the GIT_USER / GIT_PASS secrets only for push operations for the semantique image.
  • Make sure semantique only runs on the main release branch for your project (branch: master in Drone or similiar), otherwise commits to other branches will trigger competing releases.
  • Due to the lack of a conditional publish operation in Drone, I typically configure the pipelines in my examples such that pushing the tag back is what triggers the actual NPM release on a second build run.
  • If you're using this in anger I'd recommend specifying a particular version of the image for Docker - rather than defaulting to latest. I'll never rewrite a version tag, but latest/smoke/onbuild will be subject to dramatic breaking changes.

Contributing

Feature suggestions and improvements welcome. Early days.

1.5.2

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.6

8 years ago