Skip to content

Commit 478eba0

Browse files
committed
feat: first release
1 parent 0b6265d commit 478eba0

File tree

13 files changed

+462
-79
lines changed

13 files changed

+462
-79
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cache:
44
- ~/.npm
55
- .nyc_output
66
node_js:
7-
- "12.13.0"
7+
- "12.14.1"
88
notifications:
99
email: false
1010
stages:
@@ -29,7 +29,7 @@ jobs:
2929
before_script:
3030
- npm i -g coveralls
3131
script:
32-
- npx nyc check-coverage --lines 85 --per-file
32+
- npx nyc check-coverage --lines 100 --per-file
3333
after_success:
3434
- npx nyc report > lcov.info
3535
- coveralls < lcov.info

README.md

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
[![Maintainability](https://api.codeclimate.com/v1/badges/f84f0bcb39c9a5c5fb99/maintainability)](https://codeclimate.com/github/eclass/semantic-release-ssh-commands/maintainability)
1010
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
1111

12-
> [semantic-release](https://github.com/semantic-release/semantic-release) plugin to deploy app
12+
> [semantic-release](https://github.com/semantic-release/semantic-release) plugin to deploy app with ssh commands
1313
1414
| Step | Description |
1515
|--------------------|---------------------------------------------------------------------------------------------|
16-
| `verifyConditions` | Verify the presence of the `CUSTOM_ENV` environment variable. |
17-
| `publish` | Deploy app. |
16+
| `verifyConditions` | Verify the presence of the `SSH_USER`, `SSH_HOST` environment variables. |
17+
| `publish` | Deploy app over ssh. |
1818

1919
## Install
2020

@@ -33,7 +33,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
3333
"@semantic-release/npm",
3434
"@semantic-release/git",
3535
"@semantic-release/gitlab",
36-
"@eclass/semantic-release-ssh-commands"
36+
[
37+
"@eclass/semantic-release-ssh-commands",
38+
{
39+
"verifyConditionsCmd": "sh /usr/local/verifyConditionsCmd.sh",
40+
"publishCmd": "sh /usr/local/publishCmd.sh",
41+
}
42+
]
3743
]
3844
}
3945
```
@@ -44,7 +50,17 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
4450

4551
| Variable | Description |
4652
| -------------------- | ----------------------------------------------------------------- |
47-
| `CUSTOM_ENV` | A custom env var |
53+
| `SSH_USER` | A ssh user |
54+
| `SSH_HOST` | A ssh host |
55+
| `SSH_PRIVATE_KEY` | Content of private ssh key (Optional) |
56+
57+
### Options
58+
59+
| Variable | Description |
60+
| --------- | ----------------------------------------------------------------- |
61+
| `verifyConditionsCmd` | A command to verificate. Required. Ex: "sh /usr/local/verifyConditionsCmd.sh" |
62+
| `publishCmd` | A command to publish new release. This step inject VERSIOn environment variable to use in you command. Required. Ex: "sh /usr/local/publishCmd.sh" |
63+
4864

4965
### Examples
5066

@@ -55,7 +71,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
5571
"@semantic-release/npm",
5672
"@semantic-release/git",
5773
"@semantic-release/gitlab",
58-
"@eclass/semantic-release-ssh-commands"
74+
[
75+
"@eclass/semantic-release-ssh-commands",
76+
{
77+
"verifyConditionsCmd": "sh /usr/local/verifyConditionsCmd.sh",
78+
"publishCmd": "sh /usr/local/publishCmd.sh",
79+
}
80+
]
5981
]
6082
}
6183
```
@@ -65,6 +87,14 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
6587
release:
6688
image: node:alpine
6789
stage: release
90+
before_script:
91+
- apk add --no-cache git openssh-client
92+
- mkdir -p /root/.ssh
93+
- chmod 0700 /root/.ssh
94+
- ssh-keyscan $SSH_HOST > /root/.ssh/known_hosts
95+
- echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
96+
- chmod 600 /root/.ssh/id_rsa
97+
- echo " IdentityFile /root/.ssh/id_rsa" >> /etc/ssh/ssh_config
6898
script:
6999
- npx semantic-release
70100
only:
@@ -88,6 +118,13 @@ jobs:
88118
- stage: test
89119
script: npm t
90120
- stage: deploy
121+
addons:
122+
ssh_known_hosts: $SSH_HOST
123+
before_deploy:
124+
- eval "$(ssh-agent -s)"
125+
- echo "$SSH_PRIVATE_KEY" > /tmp/deploy_rsa
126+
- chmod 600 /tmp/deploy_rsa
127+
- ssh-add /tmp/deploy_rsa
91128
script: npx semantic-release
92129

93130
```

0 commit comments

Comments
 (0)