1.2.3 • Published 5 months ago

semantic-release-docker-tag v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

semantic-release-docker-tag

A package to use semantic-release with docker images, without the need of a docker binary.

Why?

Other semantic-release plugins for docker will require a docker binary and the image pulled/build to local storage. This plugins adds the new version tag to an already pushed image.

Supported Steps

verifyConditions

Verifies that required settings are set and tries to load source manifest with provided credentials

publish

Fetches the source manifest and pushes it with the new version

Tested registries

The authentication was tested with the following registries

  • harbor
  • nexus
  • github
  • dockerhub
  • gitlab registry

Installation

npm i --save-dev semantic-release-docker-tag

or

yarn add -D semantic-release-docker-tag

And include the plugin inside the plugins section of the semantic-release configuration.

{
  "plugins": [
    ...,
    "semantic-release-docker-tag"
  ]
}

Configuration

Every option can be set using Environment variable or the plugin config

Example:

{
  "plugins": [
    ["semantic-release-docker-tag", {
            
      }
    ]
  ]
}
Config OptionEnvironment variableRequiredDefaultDescription
registryUrlREGISTRY_URLNoregistry.docker.ioURL of the remote registry, without any protocol
registryProtocolREGISTRY_PROTOCOLNohttpsProtocol of the remote registry, https or http
registryUserREGISTRY_USERYes-The user used to access the registry
registryPasswordREGISTRY_PASSWORDYes-The password for the user used
sourceTagSOURCE_TAGYes-The source tag which should be retagged (ex. $COMMIT_SHA)
registryImageREGISTRY_IMAGEYes-The image receiving the version (ex hello/world)

Example CI Config

Gitlab

stages:
  - build-docker
  - semantic-release

build-image:
  stage: build-docker
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  script:
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor --context . --dockerfile ./Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG --destination $CI_REGISTRY_IMAGE:branch-$CI_COMMIT_BRANCH
    
semantic-release:
  stage: semantic-release
  image: node
  before_script:
    - npm install semantic-release
    - npm install @semantic-release/git
    - npm install @semantic-release/gitlab    
    - npm install semantic-release-docker-tag
  script:
     # Gitlab CI Variables already set in project settings
     # REGISTRY_USER, REGISTRY_PASSWORD, REGISTRY_URL, REGISTRY_IMAGE
    - export SOURCE_TAG=$CI_COMMIT_SHA
    - |
      cat > .releaserc << EOF
      {
        "branches": ["master", "main"],
        "debug": true,
        "plugins": [
          "@semantic-release/commit-analyzer",
          "@semantic-release/gitlab",
          "semantic-release-docker-tag"
        ]
      }
      EOF
    - semantic-release
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH 
      when: always
1.2.3

5 months ago

1.2.2

7 months ago

1.2.0

10 months ago

1.1.4

10 months ago

1.2.1

10 months ago

1.1.3

12 months ago

1.1.2

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago