Skip to content

Commit ac6e42f

Browse files
committed
fix(docker): allow set base image tag (default latest)
fix #66
1 parent 2d9f780 commit ac6e42f

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
4646
| Variable | Description |
4747
| -------------------- | ----------------------------------------------------------------- |
4848
| `baseImageName` | Name of the previously constructed docker image. Required. |
49+
| `baseImageTag` | Name of the previously constructed docker image tag. Optional. Default `"latest"` |
4950
| `registries` | Array of objects with username, password, url and imageName. "username" and "password" are environment variables. Required. Example: `{"username": "DOCKER_USER", "password": "DOCKER_PASSWORD", "url": "docker.pkg.github.com", "imageName": "docker.pkg.github.com/myuser/myrepo/myapp"}` |
5051
| `additionalTags` | Array of addiotional tags to push. Optional. Example: `["beta", "next"]` |
5152

src/prepare.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ module.exports = async (pluginConfig, ctx) => {
2222
if (pluginConfig.additionalTags && pluginConfig.additionalTags.length > 0) {
2323
tags.push(...pluginConfig.additionalTags)
2424
}
25+
const baseImageTag = pluginConfig.baseImageTag || 'latest'
2526
for (const tag of tags) {
2627
ctx.logger.log(
27-
`Tagging docker image ${pluginConfig.baseImageName}:latest to ${pluginConfig.baseImageName}:${tag}`
28+
`Tagging docker image ${pluginConfig.baseImageName}:${baseImageTag} to ${pluginConfig.baseImageName}:${tag}`
2829
)
2930
await image.tag({ repo: pluginConfig.baseImageName, tag })
3031
}
3132
for (const { imageName } of pluginConfig.registries) {
32-
for (const tag of [...tags, 'latest']) {
33+
for (const tag of [...tags, baseImageTag]) {
3334
ctx.logger.log(
34-
`Tagging docker image ${pluginConfig.baseImageName}:latest to ${imageName}:${tag}`
35+
`Tagging docker image ${pluginConfig.baseImageName}:${baseImageTag} to ${imageName}:${tag}`
3536
)
3637
await image.tag({ repo: imageName, tag })
3738
}

src/publish.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const pushImage = response => {
4747
module.exports = async (pluginConfig, ctx) => {
4848
try {
4949
const docker = new Dockerode()
50-
const tags = ['latest', ctx.nextRelease.version]
50+
const baseImageTag = pluginConfig.baseImageTag || 'latest'
51+
const tags = [baseImageTag, ctx.nextRelease.version]
5152
if (pluginConfig.additionalTags && pluginConfig.additionalTags.length > 0) {
5253
tags.push(...pluginConfig.additionalTags)
5354
}

src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface Config extends SemanticReleaseConfig {
1717
additionalTags?: string[]
1818
registries?: Registry[]
1919
baseImageName?: string
20+
baseImageTag?: string
2021
}
2122

2223
export interface ExecOptions {

0 commit comments

Comments
 (0)