@codedependant/semantic-release-docker 5.0.4 → 5.1.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,17 @@
1
1
  # Semantic Release Docker
2
2
 
3
+ # [5.1.0](https://github.com/esatterwhite/semantic-release-docker/compare/v5.0.4...v5.1.0) (2024-12-30)
4
+
5
+
6
+ ### Chores
7
+
8
+ * **deps**: actions/core@1.11.1 [dd03ed4](https://github.com/esatterwhite/semantic-release-docker/commit/dd03ed4c4e9624e578b7f9b35e370c32463810f5) - Eric Satterwhite
9
+
10
+
11
+ ### Features
12
+
13
+ * **plugin**: add basic support for github actions [01085f6](https://github.com/esatterwhite/semantic-release-docker/commit/01085f68ffba854f1a4923879d9dfcfdf589eaf0) - Eric Satterwhite, closes: [#49](https://github.com/esatterwhite/semantic-release-docker/issues/49)
14
+
3
15
  ## [5.0.4](https://github.com/esatterwhite/semantic-release-docker/compare/v5.0.3...v5.0.4) (2024-12-23)
4
16
 
5
17
 
package/README.md CHANGED
@@ -277,6 +277,34 @@ the default docker image tags for the 1.0.0 release would be `1.0.0`, `1-latest`
277
277
  the docker tags for version `1.2.3` will be `1.2.3`, `1.2-latest`, `1-latest` and `latest`
278
278
  the docker tags for version `2.3.4-beta.6` will be `2.3.4-beta.6`, `2.3-beta`, `2-beta` and `beta`
279
279
 
280
+ ## GitHub Actions
281
+
282
+ The plugin has some basic support for github actions by exposing several outputs and environment variables
283
+ during the publish stage
284
+
285
+ > [!WARNING]
286
+ >
287
+ > When using buildx image shas are different per platform, and as such using the shas directly
288
+ > is not supported and may result in unexpected results.
289
+
290
+ ### Outputs
291
+
292
+ | name | description | example |
293
+ |--------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------|
294
+ | `docker_image` | The full name of the docker image including the registry, sans any tag information | quay.io/codedependant/my-image |
295
+ | `docker_image_build_id` | The unique build id used to initial build the image during a release | |
296
+ | `docker_image_sha_short` | A shorted version of the image sha value suitable for referencing the image | `b94d27b9934d3e0` |
297
+ | `docker_image_sha_long` | The full sha256 value that points the image that was build during a release | `b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` |
298
+
299
+ ### Environment Variables
300
+
301
+ | name | description | example |
302
+ |-------------------------------------------|------------------------------------------------------------------------------------|--------------------------------------------------------------------|
303
+ | `SEMANTIC_RELEASE_DOCKER_IMAGE` | The full name of the docker image including the registry, sans any tag information | quay.io/codedependant/my-image |
304
+ | `SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID` | The unique build id used to initial build the image during a release | |
305
+ | `SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_SHORT` | A shorted version of the image sha value suitable for referencing the image | `b94d27b9934d3e0` |
306
+ | `SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_LONG` | The full sha256 value that points the image that was build during a release | `b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9` |
307
+
280
308
  ## Development
281
309
 
282
310
  ### Docker Registry
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  const crypto = require('crypto')
4
+ const docker = require('./lib/docker/index.js')
4
5
  const dockerPrepare = require('./lib/prepare.js')
5
6
  const dockerVerify = require('./lib/verify.js')
6
7
  const dockerPublish = require('./lib/publish.js')
@@ -9,6 +10,7 @@ const dockerSuccess = require('./lib/success.js')
9
10
  const dockerFail = require('./lib/fail.js')
10
11
  const build_id = crypto.randomBytes(10).toString('hex')
11
12
 
13
+ let image
12
14
  module.exports = {
13
15
  buildConfig
14
16
  , fail
@@ -18,22 +20,33 @@ module.exports = {
18
20
  , verifyConditions
19
21
  }
20
22
 
23
+ /* istanbul ignore next */
21
24
  async function fail(config, context) {
22
- return dockerFail(await buildConfig(build_id, config, context), context)
25
+ const opts = await buildConfig(build_id, config, context)
26
+ context.image = image || docker.Image.from(opts, context)
27
+ return dockerFail(opts, context)
23
28
  }
24
29
 
25
30
  async function prepare(config, context) {
26
- return dockerPrepare(await buildConfig(build_id, config, context), context)
31
+ const opts = await buildConfig(build_id, config, context)
32
+ image = await dockerPrepare(opts, context)
33
+ return image
27
34
  }
28
35
 
29
36
  async function publish(config, context) {
30
- return dockerPublish(await buildConfig(build_id, config, context), context)
37
+ const opts = await buildConfig(build_id, config, context)
38
+ context.image = image || docker.Image.from(opts, context)
39
+ return dockerPublish(opts, context)
31
40
  }
32
41
 
33
42
  async function success(config, context) {
34
- return dockerSuccess(await buildConfig(build_id, config, context), context)
43
+ const opts = await buildConfig(build_id, config, context)
44
+ context.image = image || docker.Image.from(opts, context)
45
+ return dockerSuccess(opts, context)
35
46
  }
36
47
 
37
48
  async function verifyConditions(config, context) {
38
- return dockerVerify(await buildConfig(build_id, config, context), context)
49
+ const opts = await buildConfig(build_id, config, context)
50
+ context.image = image || docker.Image.from(opts, context)
51
+ return dockerVerify(opts, context)
39
52
  }
@@ -7,7 +7,7 @@ const execa = require('execa')
7
7
  const buildTemplateVars = require('../build-template-vars.js')
8
8
  const array = require('../lang/array/index.js')
9
9
  const string = require('../lang/string/index.js')
10
- const SHA_REGEX = /(?:writing image\s)?[^@](?:sha\d{3}):(?<sha>\w+)/i
10
+ const SHA_REGEX = /(?:writing image\s)?[^@]?(?:sha\d{3}):(?<sha>\w+)/i
11
11
 
12
12
  function render(item, vars) {
13
13
  if (Array.isArray(item)) {
@@ -43,6 +43,7 @@ class Image {
43
43
  }
44
44
 
45
45
  this.sha = sha
46
+ this.sha256 = null
46
47
  this.opts = {
47
48
  build_id: build_id
48
49
  , args: new Map()
@@ -62,7 +63,6 @@ class Image {
62
63
 
63
64
  if (quiet) this.flag('quiet', null)
64
65
 
65
-
66
66
  for (const tag of this.tags) {
67
67
  this.flag('tag', tag)
68
68
  }
@@ -273,11 +273,12 @@ class Image {
273
273
  const line = lines[x]
274
274
  const match = SHA_REGEX.exec(line)
275
275
  if (match) {
276
- this.sha = match.groups.sha.substring(0, 12)
276
+ this.sha256 = match.groups.sha
277
+ this.sha = this.sha256.substring(0, 12)
277
278
  return this.sha
278
279
  }
279
280
  }
280
- this.sha = this.build_id
281
+ this.sha = this.opts.build_id
281
282
  return this.sha
282
283
  }
283
284
 
package/lib/prepare.js CHANGED
@@ -5,10 +5,9 @@ const docker = require('./docker/index.js')
5
5
  module.exports = dockerPrepare
6
6
 
7
7
  async function dockerPrepare(opts, context) {
8
- const image = docker.Image.from(opts, context)
8
+ const {image = docker.Image.from(opts, context)} = context
9
9
  context.logger.info('building image', image.name)
10
10
  context.logger.info('build command: docker %s', image.build_cmd.join(' '))
11
-
12
11
  await image.build()
13
12
  return image
14
13
  }
package/lib/publish.js CHANGED
@@ -1,10 +1,24 @@
1
1
  'use strict'
2
2
 
3
+ const actions = require('@actions/core')
3
4
  const docker = require('./docker/index.js')
4
5
 
5
6
  module.exports = publish
6
7
 
7
8
  async function publish(opts, context) {
8
- const image = docker.Image.from(opts, context)
9
+ const {image = docker.Image.from(opts, context)} = context
10
+
11
+ const sha = image.sha || opts.build_id
12
+ const sha256 = image.sha256 || opts.build_id
13
+
14
+ actions.setOutput('docker_image', image.repo)
15
+ actions.setOutput('docker_image_build_id', opts.build_id)
16
+ actions.setOutput('docker_image_sha_short', sha)
17
+ actions.setOutput('docker_image_sha_long', sha256)
18
+
19
+ actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE', image.repo)
20
+ actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_BUILD_ID', opts.build_id)
21
+ actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_SHORT', sha)
22
+ actions.exportVariable('SEMANTIC_RELEASE_DOCKER_IMAGE_SHA_LONG', sha256)
9
23
  await image.push()
10
24
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codedependant/semantic-release-docker",
3
3
  "private": false,
4
- "version": "5.0.4",
4
+ "version": "5.1.0",
5
5
  "description": "docker package",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -77,6 +77,7 @@
77
77
  "tap": "^16.0.0"
78
78
  },
79
79
  "dependencies": {
80
+ "@actions/core": "^1.11.1",
80
81
  "@semantic-release/error": "^3.0.0",
81
82
  "debug": "^4.1.1",
82
83
  "execa": "^4.0.2",