-
Notifications
You must be signed in to change notification settings - Fork 1
feat(plugin): Add ability to push multiple docker images #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
96850c9
4e4abe8
35e138e
0f6db97
9b055d1
4bf28d1
e50bb82
5d286e8
a0756b8
d29497b
c0d9416
1033f56
8edaa92
69b0458
5913501
9794172
fdee24d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,5 @@ dist | |
| coverage | ||
|
|
||
| *.log | ||
|
|
||
| develop.ts | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| FROM scratch | ||
| ARG TEST | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't burden yourself with creating actual images while developing this plugin. There is no benefit over (correctly) mocking/stubbing dockerode. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,25 +7,6 @@ | |
|
|
||
| A [semantic-release](https://github.com/semantic-release/semantic-release) plugin to use semantic versioning for docker images. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert back to the original structure and just add an example for the full configuration.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like it when relevant information comes first. In my mind the Question How do I use the Plugin? has to be the first one answered. Not which steps do what. This is something more specific that can be read by scrolling down. |
||
| ## Supported Steps | ||
|
|
||
| ### verifyConditions | ||
|
|
||
| verifies that environment variables for authentication via username and password are set. | ||
| It uses a registry server provided via config or environment variable (preferred) or defaults to docker hub if none is given. | ||
| It also verifies that the credentials are correct by logging in to the given registry. | ||
|
|
||
| ### prepare | ||
|
|
||
| tags the specified image with the version number determined by semantic-release and additional tags provided in the configuration. | ||
| In addition it supports specifying a complete image name (CIN) via configuration settings according to the canonical format specified by docker: | ||
|
|
||
| `[registryhostname[:port]/][username/]imagename[:tag]` | ||
|
|
||
| ### publish | ||
|
|
||
| pushes the tagged images to the registry. | ||
|
|
||
| ## Installation | ||
|
|
||
| Run `npm i --save-dev @iteratec/semantic-release-docker` to install this semantic-release plugin. | ||
|
|
@@ -36,46 +17,37 @@ Run `npm i --save-dev @iteratec/semantic-release-docker` to install this semanti | |
|
|
||
| The `docker registry` authentication is **required** and can be set via environment variables. | ||
|
|
||
| ### Environment variables | ||
|
|
||
| | Variable | Description | | ||
| | ------------------------ | ----------------------------------------------------------------------------------------- | | ||
| | DOCKER_REGISTRY_URL | The hostname and port used by the desired docker registry. Leave blank to use docker hub. | | ||
| | DOCKER_REGISTRY_USER | The user name to authenticate with at the registry. | | ||
| | DOCKER_REGISTRY_PASSWORD | The password used for authentication at the registry. | | ||
|
|
||
| ### Options | ||
| ### Plugin Configuration | ||
|
|
||
| | Option | Description | | ||
| | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | additionalTags | _Optional_. An array of strings allowing to specify additional tags to apply to the image. | | ||
| | imageName | **_Required_** The name of the image to release. | | ||
| | registryUrl | _Optional_. The hostname and port used by the the registry in format `hostname[:port]`. Omit the port if the registry uses the default port | | ||
| | repositoryName | _Optional_. The name of the repository in the registry, e.g. username on docker hub | | ||
|
|
||
| ## Usage | ||
|
|
||
| full configuration: | ||
| #### Full configuration | ||
|
|
||
| ```json | ||
| { | ||
| "verifyConfig": ["@iteratec/semantic-release-docker"], | ||
| "prepare": { | ||
| "path": "@iteratec/semantic-release-docker", | ||
| "additionalTags": ["test", "demo"], | ||
| "imageName": "my-image", | ||
| "registryUrl": "my-private-registry:5678", | ||
| "respositoryName": "my-repository" | ||
| }, | ||
| "prepare": [ | ||
| { | ||
| "path": "@iteratec/semantic-release-docker", | ||
| "additionalTags": ["test", "demo"], | ||
| "imageName": "my-image", | ||
| "registryUrl": "my-private-registry:5678", | ||
| "respositoryName": "my-repository" | ||
| } | ||
| ], | ||
| "publish": { | ||
| "path": "@iteratec/semantic-release-docker" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| results in `my-private-registry:5678/my-repository/my-image` with tags `test`, `demo` and the `<semver>` determined by `semantic-release`. | ||
| Results in `my-private-registry:5678/my-repository/my-image` with tags `test`, `demo` and the `<semver>` determined by `semantic-release`. | ||
|
|
||
| minimum configuration: | ||
| #### Minimum configuration | ||
|
|
||
| ```json | ||
| { | ||
|
|
@@ -90,4 +62,95 @@ minimum configuration: | |
| } | ||
| ``` | ||
|
|
||
| results in `my-image:<semver>` | ||
| Results in `my-image:<semver>`. | ||
|
|
||
| ### Options | ||
|
|
||
| | Option | Description | | ||
| | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | additionalTags | _Optional_. An array of strings allowing to specify additional tags to apply to the image. | | ||
| | imageName | **_Required_** The name of the image to release. | | ||
| | registryUrl | _Optional_. The hostname and port used by the the registry in format `hostname[:port]`. Omit the port if the registry uses the default port | | ||
| | repositoryName | _Optional_. The name of the repository in the registry, e.g. username on docker hub | | ||
|
|
||
| ## Steps | ||
|
|
||
| ### verifyConditions | ||
|
|
||
| It uses a registry server provided via config or environment variable (preferred) or defaults to docker hub if none is given. | ||
|
|
||
| 1. Verifies that environment variables for authentication via username and password are set. | ||
| 2. It also verifies that the credentials are correct by logging in to the given registry. | ||
|
|
||
| ### prepare | ||
|
|
||
| Tags the specified image with the version number determined by semantic-release and additional tags provided in the configuration. | ||
| In addition it supports specifying a complete image name (CIN) via configuration settings according to the canonical format specified by docker: | ||
|
|
||
| `[registryhostname[:port]/][username/]imagename[:tag]` | ||
|
|
||
| ### publish | ||
|
|
||
| Pushes the tagged images to the registry. | ||
|
|
||
| ## Contribute | ||
|
|
||
| ### Develop | ||
|
|
||
| 1. Create a develop.ts file in the root of this Git-Repository and copy this: | ||
|
|
||
| ```typescript | ||
| import { SemanticReleaseConfig, SemanticReleaseContext } from 'semantic-release'; | ||
| import { prepare, publish, verifyConditions } from './src'; | ||
| import { DockerPluginConfig } from './src/models'; | ||
|
|
||
| process.env.DOCKER_REGISTRY_USER = '<Your Docker Registry User>'; | ||
| process.env.DOCKER_REGISTRY_PASSWORD = '<Your Docker Registry Password>'; | ||
|
|
||
| const config: SemanticReleaseConfig = { | ||
| branch: '', | ||
| noCi: true, | ||
| repositoryUrl: '', | ||
| tagFormat: '' | ||
| }; | ||
| const context: SemanticReleaseContext = { | ||
| logger: { | ||
| // tslint:disable-next-line:no-empty | ||
| log: (message: string) => {} | ||
| }, | ||
| options: { | ||
| branch: '', | ||
| noCi: true, | ||
| prepare: [ | ||
| { | ||
| additionalTags: ['latest'], | ||
| imageName: 'testimage', | ||
| repositoryName: '<your test repository>', | ||
| path: '@iteratec/semantic-release-docker' | ||
| } as DockerPluginConfig, | ||
| { | ||
| additionalTags: ['latest'], | ||
| imageName: 'testimage1', | ||
| repositoryName: '<your test repository>', | ||
| path: '@iteratec/semantic-release-docker' | ||
| } as DockerPluginConfig | ||
| ], | ||
| repositoryUrl: '', | ||
| tagFormat: '' | ||
| }, | ||
| nextRelease: { | ||
| version: '1.0.3', | ||
| gitHead: '45jh345g', | ||
| gitTag: 'v1.0.3', | ||
| notes: 'Nothing special' | ||
| } | ||
| }; | ||
| context.logger.log = (string: string) => { | ||
| console.log(string); | ||
| }; | ||
| verifyConditions(config, context); | ||
| prepare(config, context); | ||
| publish(config, context); | ||
| ``` | ||
|
|
||
| 2. Simply run the "Debug" configuration in the Debug VS Code Tab. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,18 +5,23 @@ jobs: | |
| demands: npm | ||
| steps: | ||
| - task: NodeTool@0 | ||
| displayName: "Use Node 10" | ||
| displayName: 'Use Node 10' | ||
| inputs: | ||
| versionSpec: 10.x | ||
| - task: Npm@1 | ||
| displayName: "Install dependencies" | ||
| displayName: 'Install dependencies' | ||
| inputs: | ||
| verbose: false | ||
| - task: Npm@1 | ||
| displayName: Build | ||
| inputs: | ||
| command: custom | ||
| customCommand: run build | ||
| - task: Npm@1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this task |
||
| displayName: End2End Test | ||
| inputs: | ||
| command: custom | ||
| customCommand: run e2e | ||
| - task: Npm@1 | ||
| displayName: Test | ||
| inputs: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.