@codedependant/semantic-release-docker 5.1.0 → 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 CHANGED
@@ -1,5 +1,20 @@
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
+
3
18
  # [5.1.0](https://github.com/esatterwhite/semantic-release-docker/compare/v5.0.4...v5.1.0) (2024-12-30)
4
19
 
5
20
 
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const crypto = require('crypto')
4
3
  const docker = require('./lib/docker/index.js')
5
4
  const dockerPrepare = require('./lib/prepare.js')
6
5
  const dockerVerify = require('./lib/verify.js')
@@ -8,9 +7,9 @@ const dockerPublish = require('./lib/publish.js')
8
7
  const buildConfig = require('./lib/build-config.js')
9
8
  const dockerSuccess = require('./lib/success.js')
10
9
  const dockerFail = require('./lib/fail.js')
11
- const build_id = crypto.randomBytes(10).toString('hex')
12
10
 
13
- let image
11
+ // map multiple images to a unique sha
12
+ const IMAGES = new Map()
14
13
  module.exports = {
15
14
  buildConfig
16
15
  , fail
@@ -22,31 +21,41 @@ module.exports = {
22
21
 
23
22
  /* istanbul ignore next */
24
23
  async function fail(config, context) {
25
- const opts = await buildConfig(build_id, config, context)
26
- context.image = image || docker.Image.from(opts, context)
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)
27
28
  return dockerFail(opts, context)
28
29
  }
29
30
 
30
31
  async function prepare(config, context) {
31
- const opts = await buildConfig(build_id, config, context)
32
- image = await dockerPrepare(opts, context)
32
+ const opts = await buildConfig(null, config, context)
33
+ const image = await dockerPrepare(opts, context)
34
+ IMAGES.set(opts.build, image)
33
35
  return image
34
36
  }
35
37
 
36
38
  async function publish(config, context) {
37
- const opts = await buildConfig(build_id, config, context)
38
- context.image = image || docker.Image.from(opts, context)
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)
39
43
  return dockerPublish(opts, context)
40
44
  }
41
45
 
42
46
  async function success(config, context) {
43
- const opts = await buildConfig(build_id, config, context)
44
- context.image = image || docker.Image.from(opts, context)
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)
45
51
  return dockerSuccess(opts, context)
46
52
  }
47
53
 
48
54
  async function verifyConditions(config, context) {
49
- const opts = await buildConfig(build_id, config, context)
50
- context.image = image || docker.Image.from(opts, context)
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)
51
59
  return dockerVerify(opts, context)
52
60
  }
61
+
@@ -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
- async function buildConfig(build_id, config, context) {
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
- return {
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: build_id
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/publish.js CHANGED
@@ -12,12 +12,12 @@ async function publish(opts, context) {
12
12
  const sha256 = image.sha256 || opts.build_id
13
13
 
14
14
  actions.setOutput('docker_image', image.repo)
15
- actions.setOutput('docker_image_build_id', opts.build_id)
15
+ actions.setOutput('docker_image_build_id', image.opts.build_id)
16
16
  actions.setOutput('docker_image_sha_short', sha)
17
17
  actions.setOutput('docker_image_sha_long', sha256)
18
18
 
19
19
  actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE', image.repo)
20
- actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID', opts.build_id)
20
+ actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID', image.opts.build_id)
21
21
  actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_SHORT', sha)
22
22
  actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_LONG', sha256)
23
23
  await image.push()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codedependant/semantic-release-docker",
3
3
  "private": false,
4
- "version": "5.1.0",
4
+ "version": "5.1.1",
5
5
  "description": "docker package",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -74,6 +74,7 @@
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": {
@@ -82,6 +83,7 @@
82
83
  "debug": "^4.1.1",
83
84
  "execa": "^4.0.2",
84
85
  "handlebars": "^4.7.7",
86
+ "object-hash": "^3.0.0",
85
87
  "semver": "^7.3.2"
86
88
  }
87
89
  }