@codedependant/semantic-release-docker 5.0.4 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +28 -0
- package/index.js +29 -7
- package/lib/build-config.js +59 -3
- package/lib/docker/image.js +5 -4
- package/lib/prepare.js +1 -2
- package/lib/publish.js +15 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# Semantic Release Docker
|
|
2
2
|
|
|
3
|
+
## [5.1.1](https://github.com/esatterwhite/semantic-release-docker/compare/v5.1.0...v5.1.1) (2025-05-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **ci**: update actions runner dependencies [1f23b01](https://github.com/esatterwhite/semantic-release-docker/commit/1f23b01b6f8ddec193eada6e9a441bba95c739dc) - Eric Satterwhite
|
|
9
|
+
* **plugin**: better support for multiple plugin instances [8b6621c](https://github.com/esatterwhite/semantic-release-docker/commit/8b6621c60a4ba40d16d5ed026cd49c23396c6e98) - Eric Satterwhite, closes: [#60](https://github.com/esatterwhite/semantic-release-docker/issues/60)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* **compose**: update docker registry certs [4513f83](https://github.com/esatterwhite/semantic-release-docker/commit/4513f83a3eb9eb0bdab4e05ef132290cfccc0f8e) - Eric Satterwhite
|
|
15
|
+
* **deps**: object-hash@3.0.0 [e04e9d3](https://github.com/esatterwhite/semantic-release-docker/commit/e04e9d373c44c6145ebae3170d2b878dedccafc5) - Eric Satterwhite
|
|
16
|
+
* **deps**: stream-buffers@3.0.3 [b937a46](https://github.com/esatterwhite/semantic-release-docker/commit/b937a4693ab054d3496a6f902024cd70ff7c7543) - Eric Satterwhite
|
|
17
|
+
|
|
18
|
+
# [5.1.0](https://github.com/esatterwhite/semantic-release-docker/compare/v5.0.4...v5.1.0) (2024-12-30)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Chores
|
|
22
|
+
|
|
23
|
+
* **deps**: actions/core@1.11.1 [dd03ed4](https://github.com/esatterwhite/semantic-release-docker/commit/dd03ed4c4e9624e578b7f9b35e370c32463810f5) - Eric Satterwhite
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **plugin**: add basic support for github actions [01085f6](https://github.com/esatterwhite/semantic-release-docker/commit/01085f68ffba854f1a4923879d9dfcfdf589eaf0) - Eric Satterwhite, closes: [#49](https://github.com/esatterwhite/semantic-release-docker/issues/49)
|
|
29
|
+
|
|
3
30
|
## [5.0.4](https://github.com/esatterwhite/semantic-release-docker/compare/v5.0.3...v5.0.4) (2024-12-23)
|
|
4
31
|
|
|
5
32
|
|
package/README.md
CHANGED
|
@@ -277,6 +277,34 @@ the default docker image tags for the 1.0.0 release would be `1.0.0`, `1-latest`
|
|
|
277
277
|
the docker tags for version `1.2.3` will be `1.2.3`, `1.2-latest`, `1-latest` and `latest`
|
|
278
278
|
the docker tags for version `2.3.4-beta.6` will be `2.3.4-beta.6`, `2.3-beta`, `2-beta` and `beta`
|
|
279
279
|
|
|
280
|
+
## GitHub Actions
|
|
281
|
+
|
|
282
|
+
The plugin has some basic support for github actions by exposing several outputs and environment variables
|
|
283
|
+
during the publish stage
|
|
284
|
+
|
|
285
|
+
> [!WARNING]
|
|
286
|
+
>
|
|
287
|
+
> When using buildx image shas are different per platform, and as such using the shas directly
|
|
288
|
+
> is not supported and may result in unexpected results.
|
|
289
|
+
|
|
290
|
+
### Outputs
|
|
291
|
+
|
|
292
|
+
| name | description | example |
|
|
293
|
+
|--------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------|
|
|
294
|
+
| `docker_image` | The full name of the docker image including the registry, sans any tag information | quay.io/codedependant/my-image |
|
|
295
|
+
| `docker_image_build_id` | The unique build id used to initial build the image during a release | |
|
|
296
|
+
| `docker_image_sha_short` | A shorted version of the image sha value suitable for referencing the image | `b94d27b9934d3e0` |
|
|
297
|
+
| `docker_image_sha_long` | The full sha256 value that points the image that was build during a release | `b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` |
|
|
298
|
+
|
|
299
|
+
### Environment Variables
|
|
300
|
+
|
|
301
|
+
| name | description | example |
|
|
302
|
+
|-------------------------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------|
|
|
303
|
+
| `SEMANTIC_RELEASE_DOCKER_IMAGE` | The full name of the docker image including the registry, sans any tag information | quay.io/codedependant/my-image |
|
|
304
|
+
| `SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID` | The unique build id used to initial build the image during a release | |
|
|
305
|
+
| `SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_SHORT` | A shorted version of the image sha value suitable for referencing the image | `b94d27b9934d3e0` |
|
|
306
|
+
| `SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_LONG` | The full sha256 value that points the image that was build during a release | `b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` |
|
|
307
|
+
|
|
280
308
|
## Development
|
|
281
309
|
|
|
282
310
|
### Docker Registry
|
package/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const docker = require('./lib/docker/index.js')
|
|
4
4
|
const dockerPrepare = require('./lib/prepare.js')
|
|
5
5
|
const dockerVerify = require('./lib/verify.js')
|
|
6
6
|
const dockerPublish = require('./lib/publish.js')
|
|
7
7
|
const buildConfig = require('./lib/build-config.js')
|
|
8
8
|
const dockerSuccess = require('./lib/success.js')
|
|
9
9
|
const dockerFail = require('./lib/fail.js')
|
|
10
|
-
const build_id = crypto.randomBytes(10).toString('hex')
|
|
11
10
|
|
|
11
|
+
// map multiple images to a unique sha
|
|
12
|
+
const IMAGES = new Map()
|
|
12
13
|
module.exports = {
|
|
13
14
|
buildConfig
|
|
14
15
|
, fail
|
|
@@ -18,22 +19,43 @@ module.exports = {
|
|
|
18
19
|
, verifyConditions
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
/* istanbul ignore next */
|
|
21
23
|
async function fail(config, context) {
|
|
22
|
-
|
|
24
|
+
const opts = await buildConfig(null, config, context)
|
|
25
|
+
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
|
|
26
|
+
context.image = image
|
|
27
|
+
IMAGES.set(opts.build, image)
|
|
28
|
+
return dockerFail(opts, context)
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
async function prepare(config, context) {
|
|
26
|
-
|
|
32
|
+
const opts = await buildConfig(null, config, context)
|
|
33
|
+
const image = await dockerPrepare(opts, context)
|
|
34
|
+
IMAGES.set(opts.build, image)
|
|
35
|
+
return image
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
async function publish(config, context) {
|
|
30
|
-
|
|
39
|
+
const opts = await buildConfig(null, config, context)
|
|
40
|
+
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
|
|
41
|
+
context.image = image
|
|
42
|
+
IMAGES.set(opts.build, image)
|
|
43
|
+
return dockerPublish(opts, context)
|
|
31
44
|
}
|
|
32
45
|
|
|
33
46
|
async function success(config, context) {
|
|
34
|
-
|
|
47
|
+
const opts = await buildConfig(null, config, context)
|
|
48
|
+
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
|
|
49
|
+
context.image = image
|
|
50
|
+
IMAGES.set(opts.build, image)
|
|
51
|
+
return dockerSuccess(opts, context)
|
|
35
52
|
}
|
|
36
53
|
|
|
37
54
|
async function verifyConditions(config, context) {
|
|
38
|
-
|
|
55
|
+
const opts = await buildConfig(null, config, context)
|
|
56
|
+
const image = IMAGES.get(opts.build) || docker.Image.from(opts, context)
|
|
57
|
+
context.image = image
|
|
58
|
+
IMAGES.set(opts.build, image)
|
|
59
|
+
return dockerVerify(opts, context)
|
|
39
60
|
}
|
|
61
|
+
|
package/lib/build-config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const hash = require('object-hash')
|
|
3
4
|
const path = require('path')
|
|
4
5
|
const readPkg = require('./read-pkg.js')
|
|
5
6
|
const object = require('./lang/object/index.js')
|
|
@@ -7,10 +8,13 @@ const array = require('./lang/array/index.js')
|
|
|
7
8
|
const parsePkgName = require('./parse-pkg-name.js')
|
|
8
9
|
const typeCast = require('./lang/string/typecast.js')
|
|
9
10
|
const PWD = '.'
|
|
11
|
+
const PID = `${process.pid}`
|
|
12
|
+
const TIMESTAMP = new Date().toISOString()
|
|
10
13
|
|
|
11
14
|
module.exports = buildConfig
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
function applyDefaults(config) {
|
|
17
|
+
|
|
14
18
|
const {
|
|
15
19
|
dockerFile: dockerfile = 'Dockerfile'
|
|
16
20
|
, dockerNoCache: nocache = false
|
|
@@ -31,9 +35,54 @@ async function buildConfig(build_id, config, context) {
|
|
|
31
35
|
, dryRun: dry_run = false
|
|
32
36
|
} = config
|
|
33
37
|
|
|
38
|
+
return {
|
|
39
|
+
dockerfile
|
|
40
|
+
, nocache
|
|
41
|
+
, tags
|
|
42
|
+
, args
|
|
43
|
+
, build_flags
|
|
44
|
+
, cache_from
|
|
45
|
+
, registry
|
|
46
|
+
, login
|
|
47
|
+
, image
|
|
48
|
+
, platform
|
|
49
|
+
, publish
|
|
50
|
+
, dockerContext
|
|
51
|
+
, verifycmd
|
|
52
|
+
, network
|
|
53
|
+
, clean
|
|
54
|
+
, quiet
|
|
55
|
+
, dry_run
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function buildConfig(build_id, config, context) {
|
|
34
60
|
let name = null
|
|
35
61
|
let scope = null
|
|
36
62
|
let pkg = {}
|
|
63
|
+
|
|
64
|
+
const normalized = applyDefaults(config)
|
|
65
|
+
|
|
66
|
+
const {
|
|
67
|
+
dockerfile
|
|
68
|
+
, nocache
|
|
69
|
+
, tags
|
|
70
|
+
, args
|
|
71
|
+
, build_flags
|
|
72
|
+
, cache_from
|
|
73
|
+
, registry
|
|
74
|
+
, login
|
|
75
|
+
, image
|
|
76
|
+
, platform
|
|
77
|
+
, publish
|
|
78
|
+
, dockerContext
|
|
79
|
+
, verifycmd
|
|
80
|
+
, network
|
|
81
|
+
, clean
|
|
82
|
+
, quiet
|
|
83
|
+
, dry_run
|
|
84
|
+
} = normalized
|
|
85
|
+
|
|
37
86
|
try {
|
|
38
87
|
pkg = await readPkg({cwd: context.cwd})
|
|
39
88
|
const parsed = parsePkgName(pkg.name)
|
|
@@ -48,7 +97,7 @@ async function buildConfig(build_id, config, context) {
|
|
|
48
97
|
|
|
49
98
|
if (cache_from) build_flags.cache_from = array.toArray(cache_from)
|
|
50
99
|
|
|
51
|
-
|
|
100
|
+
const configuration = {
|
|
52
101
|
registry
|
|
53
102
|
, dockerfile
|
|
54
103
|
, nocache
|
|
@@ -71,7 +120,7 @@ async function buildConfig(build_id, config, context) {
|
|
|
71
120
|
, ...(args || {})
|
|
72
121
|
}
|
|
73
122
|
, name: image || name
|
|
74
|
-
, build:
|
|
123
|
+
, build: null
|
|
75
124
|
, login: login
|
|
76
125
|
, env: context.env
|
|
77
126
|
, context: dockerContext
|
|
@@ -80,4 +129,11 @@ async function buildConfig(build_id, config, context) {
|
|
|
80
129
|
, clean: typeCast(clean) === true
|
|
81
130
|
, platform: array.toArray(platform)
|
|
82
131
|
}
|
|
132
|
+
|
|
133
|
+
configuration.build = build_id || genBuildId(normalized)
|
|
134
|
+
return configuration
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function genBuildId(configuration) {
|
|
138
|
+
return hash([configuration, PID, TIMESTAMP], {algorithm: 'sha256'})
|
|
83
139
|
}
|
package/lib/docker/image.js
CHANGED
|
@@ -7,7 +7,7 @@ const execa = require('execa')
|
|
|
7
7
|
const buildTemplateVars = require('../build-template-vars.js')
|
|
8
8
|
const array = require('../lang/array/index.js')
|
|
9
9
|
const string = require('../lang/string/index.js')
|
|
10
|
-
const SHA_REGEX = /(?:writing image\s)?[^@](?:sha\d{3}):(?<sha>\w+)/i
|
|
10
|
+
const SHA_REGEX = /(?:writing image\s)?[^@]?(?:sha\d{3}):(?<sha>\w+)/i
|
|
11
11
|
|
|
12
12
|
function render(item, vars) {
|
|
13
13
|
if (Array.isArray(item)) {
|
|
@@ -43,6 +43,7 @@ class Image {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
this.sha = sha
|
|
46
|
+
this.sha256 = null
|
|
46
47
|
this.opts = {
|
|
47
48
|
build_id: build_id
|
|
48
49
|
, args: new Map()
|
|
@@ -62,7 +63,6 @@ class Image {
|
|
|
62
63
|
|
|
63
64
|
if (quiet) this.flag('quiet', null)
|
|
64
65
|
|
|
65
|
-
|
|
66
66
|
for (const tag of this.tags) {
|
|
67
67
|
this.flag('tag', tag)
|
|
68
68
|
}
|
|
@@ -273,11 +273,12 @@ class Image {
|
|
|
273
273
|
const line = lines[x]
|
|
274
274
|
const match = SHA_REGEX.exec(line)
|
|
275
275
|
if (match) {
|
|
276
|
-
this.
|
|
276
|
+
this.sha256 = match.groups.sha
|
|
277
|
+
this.sha = this.sha256.substring(0, 12)
|
|
277
278
|
return this.sha
|
|
278
279
|
}
|
|
279
280
|
}
|
|
280
|
-
this.sha = this.build_id
|
|
281
|
+
this.sha = this.opts.build_id
|
|
281
282
|
return this.sha
|
|
282
283
|
}
|
|
283
284
|
|
package/lib/prepare.js
CHANGED
|
@@ -5,10 +5,9 @@ const docker = require('./docker/index.js')
|
|
|
5
5
|
module.exports = dockerPrepare
|
|
6
6
|
|
|
7
7
|
async function dockerPrepare(opts, context) {
|
|
8
|
-
const image = docker.Image.from(opts, context)
|
|
8
|
+
const {image = docker.Image.from(opts, context)} = context
|
|
9
9
|
context.logger.info('building image', image.name)
|
|
10
10
|
context.logger.info('build command: docker %s', image.build_cmd.join(' '))
|
|
11
|
-
|
|
12
11
|
await image.build()
|
|
13
12
|
return image
|
|
14
13
|
}
|
package/lib/publish.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const actions = require('@actions/core')
|
|
3
4
|
const docker = require('./docker/index.js')
|
|
4
5
|
|
|
5
6
|
module.exports = publish
|
|
6
7
|
|
|
7
8
|
async function publish(opts, context) {
|
|
8
|
-
const image = docker.Image.from(opts, context)
|
|
9
|
+
const {image = docker.Image.from(opts, context)} = context
|
|
10
|
+
|
|
11
|
+
const sha = image.sha || opts.build_id
|
|
12
|
+
const sha256 = image.sha256 || opts.build_id
|
|
13
|
+
|
|
14
|
+
actions.setOutput('docker_image', image.repo)
|
|
15
|
+
actions.setOutput('docker_image_build_id', image.opts.build_id)
|
|
16
|
+
actions.setOutput('docker_image_sha_short', sha)
|
|
17
|
+
actions.setOutput('docker_image_sha_long', sha256)
|
|
18
|
+
|
|
19
|
+
actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE', image.repo)
|
|
20
|
+
actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID', image.opts.build_id)
|
|
21
|
+
actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_SHORT', sha)
|
|
22
|
+
actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_LONG', sha256)
|
|
9
23
|
await image.push()
|
|
10
24
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codedependant/semantic-release-docker",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.1.1",
|
|
5
5
|
"description": "docker package",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -74,13 +74,16 @@
|
|
|
74
74
|
"eslint-config-codedependant": "^3.0.0",
|
|
75
75
|
"semantic-release": "17",
|
|
76
76
|
"sinon": "^9.0.2",
|
|
77
|
+
"stream-buffers": "^3.0.3",
|
|
77
78
|
"tap": "^16.0.0"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
81
|
+
"@actions/core": "^1.11.1",
|
|
80
82
|
"@semantic-release/error": "^3.0.0",
|
|
81
83
|
"debug": "^4.1.1",
|
|
82
84
|
"execa": "^4.0.2",
|
|
83
85
|
"handlebars": "^4.7.7",
|
|
86
|
+
"object-hash": "^3.0.0",
|
|
84
87
|
"semver": "^7.3.2"
|
|
85
88
|
}
|
|
86
89
|
}
|