-
Notifications
You must be signed in to change notification settings - Fork 1
/
release.config.js
67 lines (65 loc) · 2.57 KB
/
release.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const dockerImageName = 'fossapps/micro.starter'
class SemanticReleaseError extends Error {
constructor(message, code, details) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = 'SemanticReleaseError';
this.details = details;
this.code = code;
this.semanticRelease = true;
}
}
module.exports = {
verifyConditions: [
() => {
if (!process.env.DOCKERHUB_LOGIN) {
throw new SemanticReleaseError(
"No DOCKERHUB_LOGIN specified",
"ENODOCKERHUB_LOGIN",
"Please make sure to add docker hub user in `DOCKERHUB_LOGIN` environment variable on your CI environment. The token must be able to push docker image");
}
if (!process.env.GH_TOKEN) {
throw new SemanticReleaseError(
"No GH_TOKEN specified",
"ENOGH_TOKEN",
"Please make sure to github token in `GH_TOKEN` environment variable on your CI environment. The token must be able to create releases");
}
if (!process.env.DOCKERHUB_PASSWORD) {
throw new SemanticReleaseError(
"No DOCKERHUB_PASSWORD specified",
"ENODOCKERHUB_PASSWORD",
"Please make sure to add docker password in `DOCKERHUB_PASSWORD` environment variable on your CI environment.");
}
},
"@semantic-release/github"
],
prepare: [
{
path: "@semantic-release/exec",
cmd: "echo \"$DOCKERHUB_PASSWORD\" | docker login --username \"$DOCKERHUB_LOGIN\" --password-stdin"
},
{
path: "@semantic-release/exec",
cmd: `docker pull ${dockerImageName}:\`git rev-parse --short=4 ${process.env.GITHUB_SHA}\``
},
{
path: "@semantic-release/exec",
cmd: `docker tag ${dockerImageName}:\`git rev-parse --short=4 ${process.env.GITHUB_SHA}\` ${dockerImageName}:\${nextRelease.version}`
},
{
path: "@semantic-release/exec",
cmd: `docker tag ${dockerImageName}:\`git rev-parse --short=4 ${process.env.GITHUB_SHA}\` ${dockerImageName}:latest`
}
],
publish: [
{
path: "@semantic-release/exec",
cmd: `docker push ${dockerImageName}:\${nextRelease.version}`
},
{
path: "@semantic-release/exec",
cmd: `docker push ${dockerImageName}:latest`
},
"@semantic-release/github"
]
};