release-it-docker-plugin 0.0.6 → 2.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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://unpkg.com/release-it@17/schema/release-it.json",
3
+ "git": {
4
+ "commitMessage": "chore(release): v${version}"
5
+ },
6
+ "github": {
7
+ "release": true
8
+ },
9
+ "npm": {
10
+ "publish": true
11
+ }
12
+ }
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 | Description |
48
- |-----------|---------------|--------------------------------------------------|
49
- | build | false | if plugin should build docker image |
50
- | push | false | if plugin should push docker image to docker hub |
51
- | latestTag | false | if also `latest` tag should be built and pushed |
52
- | imageName | undefined | name of docker image to build and push |
48
+ | Name | Default value | Description |
49
+ |-----------|---------------|-------------------------------------------------------------------------------------------------------------|
50
+ | imageName | undefined | name of docker image to build and push |
51
+ | latestTag | false | if also `latest` tag should be built and pushed |
52
+ | buildx | false | if plugin should use new buildx tool |
53
+ | build | false | if plugin should build docker image, only applicable without with buildx |
54
+ | push | false | if plugin should push docker image to docker hub, only applicable without with buildx |
55
+ | builder | undefined | builder name, only applicable together with buildx |
56
+ | output | docker | where image will be stored (available options `docker` or `registry`), 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.6",
3
+ "version": "2.0.0",
4
4
  "description": "Plugin to ability build docker images and push to docker hub in release-it workflow.",
5
- "keywords": ["release-it", "docker plugin", "docker", "plugin", "docker hub", "automatic release", "release"],
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
- return this.step({ task: () => this.build(), label: 'docker build', prompt: 'build'});
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.step({ task: () => this.push(), label: 'docker push', prompt: 'push'});
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,24 @@ export default class DockerPlugin {
74
79
  );
75
80
  }
76
81
 
82
+ buildx() {
83
+ const { imageName, latestTag, builder, output, 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
+ ...(output === 'docker' ? ['--load'] : ['--push']),
90
+ ];
91
+ return this.exec(`docker buildx build ${args.filter(Boolean).join(' ')} .`).then(
92
+ () => this.setContext({ isBuilt: true }),
93
+ (err) => {
94
+ this.debug(err);
95
+ throw new Error(err);
96
+ }
97
+ );
98
+ }
99
+
77
100
  getInitialOptions(options, namespace) {
78
101
  return options[namespace] || {};
79
102
  }