A semantic-release plugin to use semantic versioning for docker images.
npm i --save @iteratec/semantic-release-docker
The docker registry
authentication is required and can be set via environment variables.
Variable | Description |
---|---|
DOCKER_REGISTRY_URL | The hostname and port used by the desired docker registry. Leave blank to use docker hub. |
DOCKER_REGISTRY_USER | The user name to authenticate with at the registry. |
DOCKER_REGISTRY_PASSWORD | The password used for authentication at the registry. |
{
"verifyConfig": ["@iteratec/semantic-release-docker"],
"prepare": [
{
"path": "@iteratec/semantic-release-docker",
"additionalTags": ["test", "demo"],
"imageName": "my-image",
"registryUrl": "my-private-registry:5678",
"respositoryName": "my-repository",
"pushVersionTag": true
}
],
"publish": {
"path": "@iteratec/semantic-release-docker"
}
}
Results in my-private-registry:5678/my-repository/my-image
with tags test
, demo
and the <semver>
determined by semantic-release
.
{
"verifyConfig": ["@iteratec/semantic-release-docker"],
"prepare": {
"path": "@iteratec/semantic-release-docker",
"imageName": "my-image"
},
"publish": {
"path": "@iteratec/semantic-release-docker"
}
}
Results in my-image:<semver>
.
Option | Description |
---|---|
additionalTags | Optional. An array of strings allowing to specify additional tags to apply to the image. |
imageName | Required The name of the image to release. |
registryUrl | Optional. The hostname and port used by the the registry in format hostname[:port] . Omit the port if the registry uses the default port |
repositoryName | Optional. The name of the repository in the registry, e.g. username on docker hub |
pushVersionTag | Optional. Whether the semantic release tag, determined by the version, should be pushed. Default is true . |
It uses a registry server provided via config or environment variable (preferred) or defaults to docker hub if none is given.
- Verifies that environment variables for authentication via username and password are set.
- It also verifies that the credentials are correct by logging in to the given registry.
Tags the specified image with the version number determined by semantic-release and additional tags provided in the configuration. In addition it supports specifying a complete image name (CIN) via configuration settings according to the canonical format specified by docker:
[registryhostname[:port]/][username/]imagename[:tag]
Pushes the tagged images to the registry.
- Create a develop.ts file in the root of this Git-Repository and copy this:
import { SemanticReleaseConfig, SemanticReleaseContext } from 'semantic-release';
import { prepare, publish, verifyConditions } from './src';
import { DockerPluginConfig } from './src/models';
process.env.DOCKER_REGISTRY_USER = '<Your Docker Registry User>';
process.env.DOCKER_REGISTRY_PASSWORD = '<Your Docker Registry Password>';
const config: SemanticReleaseConfig = {
branch: '',
noCi: true,
repositoryUrl: '',
tagFormat: ''
};
const context: SemanticReleaseContext = {
logger: {
// tslint:disable-next-line:no-empty
log: (message: string) => {}
},
options: {
branch: '',
noCi: true,
prepare: [
{
additionalTags: ['latest'],
imageName: 'testimage',
repositoryName: '<your test repository>',
path: '@iteratec/semantic-release-docker'
} as DockerPluginConfig,
{
additionalTags: ['latest'],
imageName: 'testimage1',
repositoryName: '<your test repository>',
path: '@iteratec/semantic-release-docker'
} as DockerPluginConfig
],
repositoryUrl: '',
tagFormat: ''
},
nextRelease: {
version: '1.0.3',
gitHead: '45jh345g',
gitTag: 'v1.0.3',
notes: 'Nothing special'
}
};
context.logger.log = (string: string) => {
console.log(string);
};
verifyConditions(config, context);
prepare(config, context);
publish(config, context);
- Simply run the "Debug" VS Code Task