@codedependant/semantic-release-docker 4.1.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 +26 -0
- package/README.md +42 -38
- package/index.js +14 -3
- package/lib/build-config.js +5 -0
- package/lib/docker/image.js +7 -0
- package/lib/fail.js +9 -0
- package/lib/lang/string/index.js +1 -0
- package/lib/lang/string/typecast.js +32 -0
- package/lib/post-publish.js +23 -0
- package/lib/prepare.js +1 -0
- package/lib/publish.js +0 -2
- package/lib/success.js +9 -0
- package/lib/verify.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
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
|
+
|
|
10
|
+
# [4.2.0](https://github.com/esatterwhite/semantic-release-docker/compare/v4.1.0...v4.2.0) (2022-12-19)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Chores
|
|
14
|
+
|
|
15
|
+
* **ci**: downgrade github actions runner version [c6f1935](https://github.com/esatterwhite/semantic-release-docker/commit/c6f1935aec63e21a85c8e513dd74fed29a84562b) - Eric Satterwhite
|
|
16
|
+
* **test**: regenerate the local docker registry certs [4cfa6e2](https://github.com/esatterwhite/semantic-release-docker/commit/4cfa6e2a912b69ff3cfc496b88dae449a982e5f4) - Eric Satterwhite
|
|
17
|
+
* **test**: remove ci test temporarily [c28f199](https://github.com/esatterwhite/semantic-release-docker/commit/c28f199ab3d2e9bb85846e562c936c782f9440a5) - Eric Satterwhite
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Documentation
|
|
21
|
+
|
|
22
|
+
* fix broken table in readme [e85e6f3](https://github.com/esatterwhite/semantic-release-docker/commit/e85e6f38f48e3c11ef88953e0cfa74276aab09a6) - Eric Satterwhite
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* added dockerNetwork config option [d6f2def](https://github.com/esatterwhite/semantic-release-docker/commit/d6f2defa0a4cfa3a36b1b63e7cdfe13c700e632a) - Eric Satterwhite, closes: [#29](https://github.com/esatterwhite/semantic-release-docker/issues/29)
|
|
28
|
+
|
|
3
29
|
# [4.1.0](https://github.com/esatterwhite/semantic-release-docker/compare/v4.0.0...v4.1.0) (2022-04-10)
|
|
4
30
|
|
|
5
31
|
|
package/README.md
CHANGED
|
@@ -42,18 +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` |
|
|
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` |
|
|
57
59
|
|
|
58
60
|
### Build Arguments
|
|
59
61
|
|
|
@@ -63,37 +65,37 @@ build argument is explicitly `true`, the value will be omitted and the value fro
|
|
|
63
65
|
a matching environment variable will be utilized instead. This can be useful when trying to include
|
|
64
66
|
secrets and other sensitive information
|
|
65
67
|
|
|
66
|
-
| Argument Name | Description
|
|
67
|
-
|
|
68
|
-
| `SRC_DIRECTORY` | The of the directory the build was triggered from
|
|
68
|
+
| Argument Name | Description | Default |
|
|
69
|
+
|---------------------|-------------------------------------------------------------------------------------------|------------------------------|
|
|
70
|
+
| `SRC_DIRECTORY` | The of the directory the build was triggered from | The directory name of CWD |
|
|
69
71
|
| `TARGET_PATH` | Path relative to the execution root. Useful for Sharing a Single Docker file in monorepos | |
|
|
70
|
-
| `NPM_PACKAGE_NAME` | The `name` property extracted from `package.json` - if present
|
|
71
|
-
| `NPM_PACKAGE_SCOPE` | The parsed scope from the `name` property from `package.json` - sans `@`
|
|
72
|
-
| `CONFIG_NAME` | The configured name of the docker image.
|
|
73
|
-
| `CONFIG_PROJECT` | The configured docker repo project name
|
|
74
|
-
| `GIT_SHA` | The commit SHA of the current release
|
|
75
|
-
| `GIT_TAG` | The git tag of the current release
|
|
72
|
+
| `NPM_PACKAGE_NAME` | The `name` property extracted from `package.json` - if present | |
|
|
73
|
+
| `NPM_PACKAGE_SCOPE` | The parsed scope from the `name` property from `package.json` - sans `@` | |
|
|
74
|
+
| `CONFIG_NAME` | The configured name of the docker image. | The parsed package name |
|
|
75
|
+
| `CONFIG_PROJECT` | The configured docker repo project name | The package scope if present |
|
|
76
|
+
| `GIT_SHA` | The commit SHA of the current release | |
|
|
77
|
+
| `GIT_TAG` | The git tag of the current release | |
|
|
76
78
|
|
|
77
79
|
### Template Variables
|
|
78
80
|
|
|
79
81
|
String template will be passed these
|
|
80
82
|
|
|
81
|
-
| Variable name | Description | Type
|
|
82
|
-
|
|
83
|
-
| `git_sha` | The commit SHA of the current release |
|
|
84
|
-
| `git_tag` | The git tag of the current release |
|
|
85
|
-
| `release_type` | The severity type of the current build (`major`, `minor`, `patch`) |
|
|
86
|
-
| `relase_notes` | The release notes blob associated with the release |
|
|
87
|
-
| `next` | Semver object representing the next release |
|
|
88
|
-
| `previous` | Semver object representing the previous release |
|
|
89
|
-
| `major` | The major version of the next release |
|
|
90
|
-
| `minor` | The minor version of the next release |
|
|
91
|
-
| `patch` | The patch version of the next release |
|
|
92
|
-
| `prerelease` | The prerelease versions of the next release |
|
|
93
|
-
| `env` | Environment variables that were set at build time |
|
|
94
|
-
| `pkg` | Values parsed from `package.json` |
|
|
95
|
-
| `build` | A Random build hash representing the current execution context |
|
|
96
|
-
| `now` | Current timestamp is ISO 8601 format |
|
|
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][]<[Number][]> |
|
|
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][] |
|
|
97
99
|
|
|
98
100
|
### Template Helpers
|
|
99
101
|
|
|
@@ -208,7 +210,7 @@ the default docker image tags for the 1.0.0 release would be `1.0.0`, `1-latest`
|
|
|
208
210
|
}
|
|
209
211
|
```
|
|
210
212
|
|
|
211
|
-
the docker tags for version `1.2.3` will be `1.2.3`, `1.2-latest`, `1-latest` and `latest`
|
|
213
|
+
the docker tags for version `1.2.3` will be `1.2.3`, `1.2-latest`, `1-latest` and `latest`
|
|
212
214
|
the docker tags for version `2.3.4-beta.6` will be `2.3.4-beta.6`, `2.3-beta`, `2-beta` and `beta`
|
|
213
215
|
|
|
214
216
|
## Development
|
|
@@ -229,3 +231,5 @@ $ openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -o
|
|
|
229
231
|
[Boolean]: https://mdn.io/boolean
|
|
230
232
|
[String]: https://mdn.io/string
|
|
231
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
|
-
|
|
13
|
+
buildConfig
|
|
14
|
+
, fail
|
|
15
|
+
, prepare
|
|
12
16
|
, publish
|
|
17
|
+
, success
|
|
13
18
|
, verifyConditions
|
|
14
|
-
|
|
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
|
-
|
package/lib/build-config.js
CHANGED
|
@@ -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
|
|
@@ -21,6 +22,8 @@ async function buildConfig(build_id, config, context) {
|
|
|
21
22
|
, dockerPublish: publish = true
|
|
22
23
|
, dockerContext = '.'
|
|
23
24
|
, dockerVerifyCmd: verifycmd = null
|
|
25
|
+
, dockerNetwork: network = 'default'
|
|
26
|
+
, dockerAutoClean: clean = true
|
|
24
27
|
} = config
|
|
25
28
|
|
|
26
29
|
let name = null
|
|
@@ -62,5 +65,7 @@ async function buildConfig(build_id, config, context) {
|
|
|
62
65
|
, login: login
|
|
63
66
|
, env: context.env
|
|
64
67
|
, context: dockerContext
|
|
68
|
+
, network: network
|
|
69
|
+
, clean: typeCast(clean) === true
|
|
65
70
|
}
|
|
66
71
|
}
|
package/lib/docker/image.js
CHANGED
|
@@ -16,6 +16,7 @@ class Image {
|
|
|
16
16
|
, dockerfile = 'Dockerfile'
|
|
17
17
|
, cwd = process.cwd()
|
|
18
18
|
, context = '.'
|
|
19
|
+
, network = 'default'
|
|
19
20
|
} = opts || {}
|
|
20
21
|
|
|
21
22
|
if (!name || typeof name !== 'string') {
|
|
@@ -33,6 +34,7 @@ class Image {
|
|
|
33
34
|
, dockerfile: dockerfile
|
|
34
35
|
, context: context
|
|
35
36
|
, cwd: cwd
|
|
37
|
+
, network: network
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
|
@@ -66,6 +68,10 @@ class Image {
|
|
|
66
68
|
return path.resolve(this.opts.cwd, this.opts.dockerfile)
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
get network() {
|
|
72
|
+
return this.opts.network
|
|
73
|
+
}
|
|
74
|
+
|
|
69
75
|
arg(key, val) {
|
|
70
76
|
this.opts.args.set(key, val)
|
|
71
77
|
return this
|
|
@@ -82,6 +88,7 @@ class Image {
|
|
|
82
88
|
}
|
|
83
89
|
return [
|
|
84
90
|
'build'
|
|
91
|
+
, `--network=${this.network}`
|
|
85
92
|
, '--quiet'
|
|
86
93
|
, '--tag'
|
|
87
94
|
, this.name
|
package/lib/fail.js
ADDED
package/lib/lang/string/index.js
CHANGED
|
@@ -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/prepare.js
CHANGED
package/lib/publish.js
CHANGED
package/lib/success.js
ADDED
package/lib/verify.js
CHANGED