@eclass/semantic-release-docker

中文文档
4.0.0发布于 2023/03/23MITCommonJS近 30 天下载 1992

semantic-release plugin to tag and push docker images

原始使用文档
文档目录7 节
  1. Install
  2. Usage
  3. Configuration
  4. Options
  5. Environment variables
  6. Examples
  7. License

@eclass/semantic-release-docker

npm Node.js CI downloads Libraries.io dependency status for latest release Coverage Status Maintainability semantic-release

semantic-release plugin to tag and push docker images

StepDescription
verifyConditionsVerify the presence of the baseImageName, and registries options in plugin config.
prepareTag docker images.
publishPush docker images.

Install

npm i -D @eclass/semantic-release-docker

Usage

The plugin can be configured in the semantic-release configuration file:

{
  "plugins": [
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    "@eclass/semantic-release-docker"
  ]
}

Configuration

Options

Config

VariableDescription
baseImageNameName of the previously constructed docker image. Required.
baseImageTagName of the previously constructed docker image tag. Optional. Default "latest"
releaseImageTagName of the docker image tag for new. Optional. Default "latest" or channel if use a custom branches or prerelase
registriesArray of Registry objects. Required. Example: {"user": "DOCKER_USER", "password": "DOCKER_PASSWORD", "url": "docker.pkg.github.com", "imageName": "docker.pkg.github.com/myuser/myrepo/myapp"}
additionalTagsArray of additional tags to push. Optional. Example: ["beta", "next"]

Registry

VariableDescription
urlUrl of the docker registry. Required. Example: "docker.pkg.github.com"
imageNameName of the docker image. Required. Example: "docker.pkg.github.com/myuser/myrepo/myapp"
userName of the environment variable used as user name for login to the docker registry. Required. Example: "DOCKER_USER"
passwordName of the environment variable used as password for login to the docker registry. Required. Example: "DOCKER_PASSWORD"
skipTagsArray of image tags that should not be pushed to the docker registry. Optional. Example: ["latest"]

Environment variables

Environment variables are variables. Depends of registries option.

VariableDescription
DOCKER_USERusername for docker registry.
DOCKER_PASSWORDpassword for docker registry.
DOCKER_BASE_IMAGE_TAGName of the previously constructed docker image tag. Optional. Default "latest".
DOCKER_RELEASE_IMAGE_TAGName of the docker image tag for new release. Optional. Default "latest" or channel if use a custom branches or prerelase

Examples

Push images to many docker registry

{
  "plugins": [
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/git",
    "@semantic-release/gitlab",
    [
      "@eclass/semantic-release-docker",
      {
        "baseImageName": "myapp",
        "registries": [
          {
            "url": "registry.gitlab.com",
            "imageName": "registry.gitlab.com/mygroup/myapp",
            "user": "CI_REGISTRY_USER",
            "password": "CI_REGISTRY_PASSWORD"
          },
          {
            "url": "docker.io",
            "imageName": "docker.io/myuser/myapp",
            "user": "DOCKER_REGISTRY_USER",
            "password": "DOCKER_REGISTRY_PASSWORD"
          },
          {
            "url": "docker.pkg.github.com",
            "imageName": "docker.pkg.github.com/myuser/myrepo/myapp",
            "user": "GITHUB_USER",
            "password": "GITHUB_TOKEN"
          },
          {
            "url": "123456789012.dkr.ecr.us-east-1.amazonaws.com",
            "imageName": "123456789012.dkr.ecr.us-east-1.amazonaws.com/myapp",
            "user": "AWS_DOCKER_USER",
            "password": "AWS_DOCKER_PASSWORD",
            "skipTags": ["latest"]
          }
        ],
        "additionalTags": ["next", "beta"]
      }
    ]
  ]
}
# .gitlab-ci.yml
release:
  image: node:alpine
  stage: release
  before_script:
    - docker build -t myapp .
  script:
    - npx semantic-release
  only:
    - master
# .travis.yml
language: node_js
cache:
  directories:
    - ~/.npm
node_js:
  - '12'
stages:
  - test
  - name: deploy
    if: branch = master
jobs:
  include:
    - stage: test
      script: npm t
    - stage: deploy
      before_script: docker build -t myapp .
      script: npx semantic-release

License

MIT

版本与发布记录

@eclass/semantic-release-docker 共发布 14 个版本,首次发布于 2020/02/04;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.0.0latest2023/03/233 年前
3.0.12022/08/304 年前
3.0.02022/02/114 年前
2.0.02021/11/045 年前
1.2.02021/10/185 年前
1.1.02021/08/175 年前

关于 @eclass/semantic-release-docker 的常见问题

@eclass/semantic-release-docker 是什么?

semantic-release plugin to tag and push docker images

如何安装 @eclass/semantic-release-docker?

在项目目录运行 npm install @eclass/semantic-release-docker,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:semantic-release(>=18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@eclass/semantic-release-docker 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/eclass__semantic-release-docker 是否存在。

@eclass/semantic-release-docker 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@eclass/semantic-release-docker 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14.17.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@eclass/semantic-release-docker 可以商用吗?

@eclass/semantic-release-docker 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@eclass/semantic-release-docker 的下载量有多少?

根据 npm 官方下载统计,@eclass/semantic-release-docker 在 2026/10/13 – 2026/11/11 这 30 天内被下载 1,992 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@eclass/semantic-release-docker 还在维护吗?

最新版本 4.0.0 发布于 2023/03/23(3 年前);至今共发布 14 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/02/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。