Semantic release shareable configuration for releasing docker images. This configuration makes use of the semantic-release-docker plugin to add image build functionality to the release process defined by @mezmoinc/release-config-core
// package.json
{
"release": {
"branches": ["main"],
"extends": "@mezmoinc/release-config-docker",
"dockerImage": "custom-image-name"
}
}For monorepos it may be desireable to use the same Dockerfile for multiple deployments.
This is possible by pointing the dockerfile option to its location relative to the sub project
// package.json
{
"release": {
"branches": ["main"],
"extends": "@mezmoinc/release-config-docker",
"dockerFile": "../../Dockerfile"
}
}Alternatively
// release.config.js
const path = require('path')
module.exports = {
branches : ['main'],
extends: '@mezmoinc/release-config-docker',
dockerFile: path.join(__dirname, '..', '..', 'Dockerfile')
}| Option | Description | Default |
|---|---|---|
dockerTags |
Optional. An array of strings allowing to specify additional tags to apply to the image. Supports templating | [latest, {major}-latest, {version}] |
dockerImage |
Optional. The name of the image to release. | Parsed from package.json name property |
dockerRegistry |
Optional. The hostname and port used by the the registry in format hostname[:port]. Omit the port if the registry uses the default port |
null (dockerhub) |
dockerProject |
Optional. The project or repository name to publish the image to | For scoped packages, the scope will be used, otherwise null |
dockerDockerfile |
Optional. The path, relative to $PWD to a Docker file to build the target image with |
Dockerfile |
dockerContext |
Optional. A path, relative to $PWD to use as the build context A |
. |
dockerLogin |
Optional. Set to false it by pass docker login if the docker daemon is already authorized | true |
dockerArgs |
Optional. Include additional values for docker's build-arg. Supports templating |
|
dockerPlatform |
Optional. An array of target platforms to build for. If specified, buildx Will be used to generate the final images | null (default docker build behavior) |
dockerPublish |
Optional. Automatically push image tags during the publish phase. | true |
Handlebars syntax {{}} may be used to template values. Dot notation can be used to extract values from objects
| Variable | Description | Type |
|---|---|---|
previous |
Object with major, minor, patch semver information of the last release published. |
Object |
next |
Object with major, minor, patch semver information of the release to be published. |
Object |
git_sha |
The commit SHA of the current release | String |
git_tag |
The git tag of the current release | String |
release_type |
The severity type of the current build (major, minor, patch) |
String |
relase_notes |
The release notes blob associated with the release | String |
version |
Sever string of the version being built | String |
major |
The major version of the next release | Number |
minor |
The minor version of the next release | Number |
patch |
The patch version of the next release | Number |
env |
Environment variables that were set at build time | Object |
pkg |
Values parsed from package.json |
Object |
build |
The Random build hash representing the current execution context | String |
now |
Current timestamp is ISO 8601 format | String |
The build step will be passed a number of default build arguments. If the value of the build argument is true
The build argument value will be omitted allowing the value to be pulled from an environment variable
// package.json
{
"name": "service-name",
"release": {
"extends": "@mezmoinc/release-config-docker",
"dockerFile": "../../Dockerfile",
"dockerTags": ["latest", "{{version}}", "{{major}}-latest", "{{major}}.{{minor}}"],
"dockerRegistry": "docker.io",
"dockerProject": "mezmo",
"dockerArgs": {
"GITHUB_TOKEN": true
}
}
}> export GITHUB_TOKEN=abc123
> docker build -t docker.io/mezmo/service-name --build-arg GITHUB_TOKEN -f ../../Dockerfile .The following handlebars template helpers are pre installed
| Helper name | Description | Return Type | Example |
|---|---|---|---|
endswith |
returns true if a string ends with another | Boolean | |
eq |
returns true if two values are strictly equal to each other | Boolean | |
gt |
returns true if the first value is greater than the second | Boolean | |
gte |
returns true if the first value is greater than or equal to the second | Boolean | |
includes |
returns true if the input (string | array) includes the second value | Boolean | |
lower |
returns the lower cased varient of the input string | String | |
lt |
returns true if the first value is less than the second | Boolean | |
lte |
returns true if the first value is less than or equal to the second | Boolean | |
neq |
returns true if two values are not equal to each other | Boolean | |
pick |
returns the first non null-ish value. Will treat false as a value |
any |
|
split |
splits csv values into a javascript array | Array | |
startswith |
returns true if a string starts with another | Boolean | |
upper |
returns the upper cased varient of the input string | String |
| Build Arg | Description | Example |
|---|---|---|
SRC_DIRECTORY |
The name of the directory the build is being executed | one |
TARGET_PATH |
The path to the current src directory relative to the project root | workspace/one |
NPM_PACKAGE_NAME |
The name of the current package the build is executing. Sans scope | package-one |
NPM_PACKAGE_SCOPE |
The Scope of the current package, if present. Sans @ |
scope |
CONFIG_NAME |
The name of the image as it is being built. Sans registry. | image-name |
CONFIG_PROJECT |
The name of the project the docker image will belong to | mezmo |
GIT_SHA |
The commit SHA of the current release | ec6e214f0 |
GIT_TAG |
The git tag of the current release | v1.0.0 |