@codedependant/semantic-release-docker 4.2.0 → 4.3.0

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,12 @@
1
1
  # Semantic Release Docker
2
2
 
3
+ # [4.3.0](https://github.com/esatterwhite/semantic-release-docker/compare/v4.2.0...v4.3.0) (2022-12-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * **config**: add option to disable post publish image removal [0c03cbd](https://github.com/esatterwhite/semantic-release-docker/commit/0c03cbd16bf7aa34cb435e3782492ad294e9bdfd) - Eric Satterwhite, closes: [#28](https://github.com/esatterwhite/semantic-release-docker/issues/28)
9
+
3
10
  # [4.2.0](https://github.com/esatterwhite/semantic-release-docker/compare/v4.1.0...v4.2.0) (2022-12-19)
4
11
 
5
12
 
package/README.md CHANGED
@@ -42,19 +42,20 @@ omitted, it is assumed the docker daemon is already authenticated with the targe
42
42
 
43
43
  ### Options
44
44
 
45
- | Option | Description | Default |
46
- |-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
47
- | `dockerTags` | _Optional_. An array of strings allowing to specify additional tags to apply to the image. Supports templating | [`latest`, `{{major}}-latest`, `{{version}}`] |
48
- | `dockerImage` | _Optional_. The name of the image to release. | Parsed from package.json `name` property |
49
- | `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) |
50
- | `dockerProject` | _Optional_. The project or repository name to publish the image to | For scoped packages, the scope will be used, otherwise `null` |
51
- | `dockerFile` | _Optional_. The path, relative to `$PWD` to a Docker file to build the target image with | `Dockerfile` |
52
- | `dockerContext` | _Optional_. A path, relative to `$PWD` to use as the build context A | `.` |
53
- | `dockerLogin` | _Optional_. Set to false it by pass docker login if the docker daemon is already authorized | `true` |
54
- | `dockerArgs` | _Optional_. Include additional values for docker's `build-arg`. Supports templating | |
55
- | `dockerPublish` | _Optional_. Automatically push image tags during the publish phase. | `true` |
56
- | `dockerVerifyCmd` | _Optional_. If specified, during the verify stage, the specified command will execute in a container of the build image. If the command errors, the release will fail. | `false` |
57
- | `dockerNetwork` | _Optional_. Specify the Docker network to use while the image is building. | `default` |
45
+ | Option | Description | Type | Default |
46
+ |-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------|---------------------------------------------------------------|
47
+ | `dockerTags` | _Optional_. An array of strings allowing to specify additional tags to apply to the image. Supports templating | [Array][]<[String][]> | [`latest`, `{{major}}-latest`, `{{version}}`] |
48
+ | `dockerImage` | _Optional_. The name of the image to release. | [String][] | Parsed from package.json `name` property |
49
+ | `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 | [String][] | `null` (dockerhub) |
50
+ | `dockerProject` | _Optional_. The project or repository name to publish the image to | [String][] | For scoped packages, the scope will be used, otherwise `null` |
51
+ | `dockerFile` | _Optional_. The path, relative to `$PWD` to a Docker file to build the target image with | [String][] | `Dockerfile` |
52
+ | `dockerContext` | _Optional_. A path, relative to `$PWD` to use as the build context A | [String][] | `.` |
53
+ | `dockerLogin` | _Optional_. Set to false it by pass docker login if the docker daemon is already authorized | [String][] | `true` |
54
+ | `dockerArgs` | _Optional_. Include additional values for docker's `build-arg`. Supports templating | [Object][] | |
55
+ | `dockerPublish` | _Optional_. Automatically push image tags during the publish phase. | [Boolean][] | `true` |
56
+ | `dockerVerifyCmd` | _Optional_. If specified, during the verify stage, the specified command will execute in a container of the build image. If the command errors, the release will fail. | [String][] | `false` |
57
+ | `dockerNetwork` | _Optional_. Specify the Docker network to use while the image is building. | [String][] | `default` |
58
+ | `dockerAutoClean` | _Optional_. If set to true | [Boolean][] | `true` |
58
59
 
59
60
  ### Build Arguments
60
61
 
@@ -79,22 +80,22 @@ secrets and other sensitive information
79
80
 
80
81
  String template will be passed these
81
82
 
82
- | Variable name | Description | Type |
83
- |----------------|--------------------------------------------------------------------|-----------------|
84
- | `git_sha` | The commit SHA of the current release | `String` |
85
- | `git_tag` | The git tag of the current release | `String` |
86
- | `release_type` | The severity type of the current build (`major`, `minor`, `patch`) | `String` |
87
- | `relase_notes` | The release notes blob associated with the release | `String` |
88
- | `next` | Semver object representing the next release | `Object` |
89
- | `previous` | Semver object representing the previous release | `Object` |
90
- | `major` | The major version of the next release | `Number` |
91
- | `minor` | The minor version of the next release | `Number` |
92
- | `patch` | The patch version of the next release | `Number` |
93
- | `prerelease` | The prerelease versions of the next release | `Array<Number>` |
94
- | `env` | Environment variables that were set at build time | `Object` |
95
- | `pkg` | Values parsed from `package.json` | `Object` |
96
- | `build` | A Random build hash representing the current execution context | `String` |
97
- | `now` | Current timestamp is ISO 8601 format | `String` |
83
+ | Variable name | Description | Type |
84
+ |----------------|--------------------------------------------------------------------|-----------------------------|
85
+ | `git_sha` | The commit SHA of the current release | [String][] |
86
+ | `git_tag` | The git tag of the current release | [String][] |
87
+ | `release_type` | The severity type of the current build (`major`, `minor`, `patch`) | [String][] |
88
+ | `relase_notes` | The release notes blob associated with the release | [String][] |
89
+ | `next` | Semver object representing the next release | [Object][] |
90
+ | `previous` | Semver object representing the previous release | [Object][] |
91
+ | `major` | The major version of the next release | [Number][] |
92
+ | `minor` | The minor version of the next release | [Number][] |
93
+ | `patch` | The patch version of the next release | [Number][] |
94
+ | `prerelease` | The prerelease versions of the next release | [Array][]&lt;[Number][]&gt; |
95
+ | `env` | Environment variables that were set at build time | [Object][] |
96
+ | `pkg` | Values parsed from `package.json` | [Object][] |
97
+ | `build` | A Random build hash representing the current execution context | [String][] |
98
+ | `now` | Current timestamp is ISO 8601 format | [String][] |
98
99
 
99
100
  ### Template Helpers
100
101
 
@@ -230,3 +231,5 @@ $ openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -o
230
231
  [Boolean]: https://mdn.io/boolean
231
232
  [String]: https://mdn.io/string
232
233
  [Array]: https://mdn.io/array
234
+ [Object]: https://mdn.io/object
235
+ [Number]: https://mdn.io/number
package/index.js CHANGED
@@ -5,13 +5,21 @@ 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
+ const dockerSuccess = require('./lib/success.js')
9
+ const dockerFail = require('./lib/fail.js')
8
10
  const build_id = crypto.randomBytes(10).toString('hex')
9
11
 
10
12
  module.exports = {
11
- prepare
13
+ buildConfig
14
+ , fail
15
+ , prepare
12
16
  , publish
17
+ , success
13
18
  , verifyConditions
14
- , buildConfig
19
+ }
20
+
21
+ async function fail(config, context) {
22
+ return dockerFail(await buildConfig(build_id, config, context), context)
15
23
  }
16
24
 
17
25
  async function prepare(config, context) {
@@ -22,7 +30,10 @@ async function publish(config, context) {
22
30
  return dockerPublish(await buildConfig(build_id, config, context), context)
23
31
  }
24
32
 
33
+ async function success(config, context) {
34
+ return dockerSuccess(await buildConfig(build_id, config, context), context)
35
+ }
36
+
25
37
  async function verifyConditions(config, context) {
26
38
  return dockerVerify(await buildConfig(build_id, config, context), context)
27
39
  }
28
-
@@ -5,6 +5,7 @@ const readPkg = require('./read-pkg.js')
5
5
  const object = require('./lang/object/index.js')
6
6
  const array = require('./lang/array/index.js')
7
7
  const parsePkgName = require('./parse-pkg-name.js')
8
+ const typeCast = require('./lang/string/typecast.js')
8
9
  const PWD = '.'
9
10
 
10
11
  module.exports = buildConfig
@@ -22,6 +23,7 @@ async function buildConfig(build_id, config, context) {
22
23
  , dockerContext = '.'
23
24
  , dockerVerifyCmd: verifycmd = null
24
25
  , dockerNetwork: network = 'default'
26
+ , dockerAutoClean: clean = true
25
27
  } = config
26
28
 
27
29
  let name = null
@@ -64,5 +66,6 @@ async function buildConfig(build_id, config, context) {
64
66
  , env: context.env
65
67
  , context: dockerContext
66
68
  , network: network
69
+ , clean: typeCast(clean) === true
67
70
  }
68
71
  }
package/lib/fail.js ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ const postPublish = require('./post-publish.js')
4
+
5
+ module.exports = fail
6
+
7
+ function fail(opts, context) {
8
+ return postPublish(opts, context)
9
+ }
@@ -2,4 +2,5 @@
2
2
 
3
3
  module.exports = {
4
4
  template: require('./template.js')
5
+ , typecast: require('./typecast.js')
5
6
  }
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ /**
4
+ * @module lib/string/typecast
5
+ * @author Eric Satterwhite
6
+ **/
7
+
8
+ module.exports = function typecast(value) {
9
+ if (value === 'null' || value === null) return null
10
+ if (value === 'undefined' || value === undefined) return undefined
11
+ if (value === 'true' || value === true) return true
12
+ if (value === 'false' || value === false) return false
13
+ if (value === '' || isNaN(value)) return value
14
+ if (isFinite(value)) return parseFloat(value)
15
+ return value
16
+ }
17
+
18
+ /**
19
+ * Best effort to cast a string to its native couter part where possible
20
+ * Supported casts are booleans, numbers, null and undefined
21
+ * @function module:lib/string/typecast
22
+ * @param {String} str The string value to typecast
23
+ * @return {*} The coerced value
24
+ * @example
25
+ * typecast('null') // null
26
+ * @example
27
+ * typecast('true') // true
28
+ * @example
29
+ * typecast('10.01') // 10.01
30
+ * @example
31
+ * typecast({}) // {}
32
+ **/
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ const docker = require('./docker/index.js')
4
+
5
+ module.exports = postPublish
6
+
7
+ async function postPublish(opts, context) {
8
+ const {cwd, logger} = context
9
+ const image = new docker.Image({
10
+ registry: opts.registry
11
+ , project: opts.project
12
+ , name: opts.name
13
+ , dockerfile: opts.dockerfile
14
+ , build_id: opts.build
15
+ , cwd: cwd
16
+ , context: opts.context
17
+ })
18
+
19
+ if (!opts.clean) return
20
+
21
+ logger.info(`removing images for ${image.repo}`)
22
+ await image.clean()
23
+ }
package/lib/publish.js CHANGED
@@ -28,6 +28,4 @@ async function publish(opts, context) {
28
28
  logger.info(`pushing image: ${image.repo} tag: ${tag}`)
29
29
  await image.tag(tag, opts.publish)
30
30
  }
31
-
32
- await image.clean()
33
31
  }
package/lib/success.js ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ const postPublish = require('./post-publish.js')
4
+
5
+ module.exports = success
6
+
7
+ function success(opts, context) {
8
+ return postPublish(opts, context)
9
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codedependant/semantic-release-docker",
3
3
  "private": false,
4
- "version": "4.2.0",
4
+ "version": "4.3.0",
5
5
  "description": "docker package",
6
6
  "main": "index.js",
7
7
  "files": [