release-it-docker-plugin 0.0.6 → 1.0.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/.release-it.json +12 -0
- package/README.md +10 -6
- package/package.json +14 -3
- package/src/index.js +26 -2
package/.release-it.json
ADDED
package/README.md
CHANGED
@@ -31,6 +31,7 @@ Use the plugin in `.release-it.json` as follows:
|
|
31
31
|
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
|
32
32
|
...
|
33
33
|
"plugins": {
|
34
|
+
...
|
34
35
|
"release-it-docker-plugin": {
|
35
36
|
"build": true,
|
36
37
|
"push": true,
|
@@ -44,12 +45,15 @@ Use the plugin in `.release-it.json` as follows:
|
|
44
45
|
## Options
|
45
46
|
The plugin can be configured with the following options:
|
46
47
|
|
47
|
-
| Name | Default value
|
48
|
-
|
49
|
-
| build | false
|
50
|
-
| push | false
|
51
|
-
| latestTag | false
|
52
|
-
| imageName | undefined
|
48
|
+
| Name | Default value | Description |
|
49
|
+
|-----------|-------------------------|--------------------------------------------------------|
|
50
|
+
| build | false | if plugin should build docker image |
|
51
|
+
| push | false | if plugin should push docker image to docker hub |
|
52
|
+
| latestTag | false | if also `latest` tag should be built and pushed |
|
53
|
+
| imageName | undefined | name of docker image to build and push |
|
54
|
+
| buildx | false | if plugin should use new buildx tool |
|
55
|
+
| builder | undefined | builder name, only applicable together with buildx |
|
56
|
+
| platform | linux/arm64,linux/amd64 | target platforms, only applicable together with buildx |
|
53
57
|
|
54
58
|
# 📖 License
|
55
59
|
MIT
|
package/package.json
CHANGED
@@ -1,15 +1,26 @@
|
|
1
1
|
{
|
2
2
|
"name": "release-it-docker-plugin",
|
3
|
-
"version": "0.0
|
3
|
+
"version": "1.0.0",
|
4
4
|
"description": "Plugin to ability build docker images and push to docker hub in release-it workflow.",
|
5
|
-
"keywords": [
|
5
|
+
"keywords": [
|
6
|
+
"release-it",
|
7
|
+
"docker plugin",
|
8
|
+
"docker",
|
9
|
+
"plugin",
|
10
|
+
"docker hub",
|
11
|
+
"automatic release",
|
12
|
+
"release",
|
13
|
+
"release-it-plugin"
|
14
|
+
],
|
6
15
|
"repository": "https://github.com/Raiper34/release-it-docker-plugin",
|
7
16
|
"homepage": "https://github.com/Raiper34/release-it-docker-plugin",
|
8
17
|
"author": "Raiper34",
|
9
18
|
"license": "MIT",
|
10
19
|
"main": "src/index.js",
|
11
20
|
"type": "module",
|
12
|
-
"scripts": {
|
21
|
+
"scripts": {
|
22
|
+
"release": "release-it"
|
23
|
+
},
|
13
24
|
"devDependencies": {
|
14
25
|
"release-it": "^18.1.1"
|
15
26
|
},
|
package/src/index.js
CHANGED
@@ -26,16 +26,21 @@ export default class DockerPlugin {
|
|
26
26
|
|
27
27
|
this.registerPrompts({
|
28
28
|
build: {type: 'confirm', message: () => 'Build docker image?', default: !!this.options.build},
|
29
|
+
buildx: {type: 'confirm', message: () => 'Run docker buildx?', default: true},
|
29
30
|
push: {type: 'confirm', message: () => 'Push to docker hub?', default: !!this.options.push},
|
30
31
|
});
|
31
32
|
}
|
32
33
|
|
33
34
|
async beforeRelease() {
|
34
|
-
|
35
|
+
if (!this.options.buildx) {
|
36
|
+
return this.step({ task: () => this.build(), label: 'docker build', prompt: 'build'});
|
37
|
+
}
|
35
38
|
}
|
36
39
|
|
37
40
|
async release() {
|
38
|
-
return this.
|
41
|
+
return this.options.buildx ?
|
42
|
+
this.step({ task: () => this.buildx(), label: 'docker buildx build', prompt: 'buildx'}) :
|
43
|
+
this.step({ task: () => this.push(), label: 'docker push', prompt: 'push'});
|
39
44
|
}
|
40
45
|
|
41
46
|
afterRelease() {
|
@@ -74,6 +79,25 @@ export default class DockerPlugin {
|
|
74
79
|
);
|
75
80
|
}
|
76
81
|
|
82
|
+
buildx() {
|
83
|
+
const { imageName, latestTag, builder, build, push, platform = 'linux/arm64,linux/amd64' } = this.options;
|
84
|
+
const args = [
|
85
|
+
'-t', `${imageName}:${this.config.contextOptions.version}`,
|
86
|
+
...(latestTag ? ['-t', `${imageName}:latest`] : []),
|
87
|
+
'--platform', platform,
|
88
|
+
...(builder ? ['--builder', builder] : []),
|
89
|
+
...(build ? ['--load'] : []),
|
90
|
+
...(push ? ['--push'] : []),
|
91
|
+
];
|
92
|
+
return this.exec(`docker buildx build ${args.filter(Boolean).join(' ')} .`).then(
|
93
|
+
() => this.setContext({ isBuilt: true }),
|
94
|
+
(err) => {
|
95
|
+
this.debug(err);
|
96
|
+
throw new Error(err);
|
97
|
+
}
|
98
|
+
);
|
99
|
+
}
|
100
|
+
|
77
101
|
getInitialOptions(options, namespace) {
|
78
102
|
return options[namespace] || {};
|
79
103
|
}
|