Skip to content

Commit

Permalink
New: adds telegra.ph integration. Closes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovitDmytro committed Dec 18, 2021
1 parent 1271abe commit da2e0f9
Show file tree
Hide file tree
Showing 18 changed files with 902 additions and 463 deletions.
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if needed, the configuration can be extended:
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["semantic-release-heroku", {
["semantic-release-telegram", {
"name": "funny-app",
"chats": [ 123456789 ],
"templates": {
Expand All @@ -92,6 +92,8 @@ Config attribute description:
| `chats` | yes | ```array``` | List of chats for sending. The bot should have access to each chat. | |
| `templates.success` | no | ```string``` | HTML template, send in case of success. | [SUCCESS.html](templates/SUCCESS.html) |
| `templates.fail` | no | ```string``` | HTML template, send in case of fail. | [FAIL.html](templates/FAIL.html) |
| `assets` | no | ```array``` | List of files to upload. See [Assets](#assets) | `[]` |
| `telegra.ph` | no | ```object``` | Publish and attach [Telegraph](#Telegraph) story | `null` |

Template variables:

Expand All @@ -113,6 +115,37 @@ To use this package, you need to [register](https://core.telegram.org/bots#3-how
TELEGRAM_BOT_ID=123456
TELEGRAM_BOT_TOKEN=ABC-DEF1234ghIkl-zyx57W2v1u123ew11
```

### Assets

Can be [glob](https://github.com/isaacs/node-glob#glob-primer) or relative file path. `name` specifies file label in telegram. In the case of glob pattern, all files are uploaded in a single archive, `name` is required.

Example:

```json
"assets" : [
{ "path": "README.md" },
{ "glob": [ ".docs/*" ], "name": "Documentation.zip" }
]
```

Assets will be attached to release message as separate files.
### Telegraph

Upload bulky markdowns, as [telegra.ph](https://telegra.ph/) stories. Use next api for this:

```json
"telegra.ph" : {
"title" : "{name} v.{version}",
"message" : "<a href='{telegraph_url}'>Release Notes</a>",
"content" : "{release_notes}"
}
```

`title` and `content` represent story content.

`message` is a telegram message, sent to telegram chats (It is reasonable to include `{telegraph_url}` here). Success template is extended with new variables `{telegraph_url}` and `{telegraph_title}` when `telegra.ph` is used.

[sr-url]: https://github.com/semantic-release/semantic-release
[sr-config]: https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration
[tg-url]: https://telegram.org/
Expand Down
70 changes: 46 additions & 24 deletions bin/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import path from 'path';
import { docopt } from 'docopt';
import success from '../src/success';
import verifyConditions from '../src/verifyConditions';
import fail from '../src/fail';
import success from '../src/success';
import verifyConditions from '../src/verifyConditions';
import fail from '../src/fail';

const doc =
`Usage:
Expand All @@ -17,33 +17,55 @@ Options:
-h --help Run test with real credentials.
`;

const options = {
repositoryUrl : 'https://github.com/pustovitDmytro/semantic-release-telegram.git',
'telegra.ph' : {
title : '{name} v.{version}',
message : '<a href=\'{telegraph_url}\'>Release Notes</a>',
content : '{release_notes}'
},
assets : [
{ path: 'README.md' },
{ glob: [ '.docs/*' ], name: 'Docs.zip' }
]
};
const branch = { name: 'master' };

// eslint-disable-next-line no-secrets/no-secrets
const notes = `
## [1.2.15](https://github.com/pustovitDmytro/semantic-release-telegram/compare/v1.2.14...v1.2.15) (2021-09-09)
### Chore
* fixes audit [devDependencies] ([d08b1fc](https://github.com/pustovitDmytro/semantic-release-telegram/commit/d08b1fc075b7eef59c59f755e1ee96748824e415))
* Lock file maintenance ([47bfacf](https://github.com/pustovitDmytro/semantic-release-telegram/commit/47bfacf4e2ffe672c96345481ddfa6811d4d4d69))
* Lock file maintenance ([19c2389](https://github.com/pustovitDmytro/semantic-release-telegram/commit/19c23891056afb813e4dde92e7f40f0905896bc9))
* Lock file maintenance ([2b00aec](https://github.com/pustovitDmytro/semantic-release-telegram/commit/2b00aec84097bd21c51a43ab785225798753dbae))
* Lock file maintenance ([dea06c9](https://github.com/pustovitDmytro/semantic-release-telegram/commit/dea06c9d3e2dd4448e997ee081425b1a765fae87))
* Lock file maintenance ([e0043d8](https://github.com/pustovitDmytro/semantic-release-telegram/commit/e0043d89de5576939e701f567ab1a871c2c8a057))
* Update devDependencies (non-major) ([73a2388](https://github.com/pustovitDmytro/semantic-release-telegram/commit/73a2388bb59f4bb31566db3fd06fda707b9761a7))
* Update devDependencies (non-major) ([33211c3](https://github.com/pustovitDmytro/semantic-release-telegram/commit/33211c31d168fc187eb028f92eaeeff48ccfd085))
* Update devDependencies (non-major) (#44) ([e8b6f98](https://github.com/pustovitDmytro/semantic-release-telegram/commit/e8b6f98cfd1bb5b89e4211116c86a14e8b296ba1)), closes [#44](https://github.com/pustovitDmytro/semantic-release-telegram/issues/44)
### Upgrade
* Update dependency git-url-parse to v11.6.0 ([0ee4167](https://github.com/pustovitDmytro/semantic-release-telegram/commit/0ee4167d974808539e5b749ec2d43fc61599d8eb))
`;

const nextRelease = {
type : 'patch',
version : '1.2.15',
commit : '13b16914f2893fa09e9a39f1dcda78af1fff0dbd',
notes
};

async function main(opts) {
try {
const chats = opts['--chats'].split(' ');
const rootDir = opts['<rootDir>'] || process.cwd();
const options = {
repositoryUrl : 'https://github.com/pustovitDmytro/semantic-release-telegram.git'
};
const branch = { name: 'master' };

if (opts.success) {
const notes = '# [1.1.0](https://github.com/pustovitDmytro/semantic-release-test/compare/v1.0.0...v1.1.0) (2021-05-01)\n' +
'\n' +
'\n' +
'### New\n' +
'\n' +
// eslint-disable-next-line no-secrets/no-secrets
'* adds log ([13b1691](https://github.com/pustovitDmytro/semantic-release-test/commit/13b16914f2893fa09e9a39f1dcda78af1fff0dbd))\n' +
'\n' +
'\n' +
'\n';
const nextRelease = {
type : 'minor',
version : '1.1.0',
commit : '13b16914f2893fa09e9a39f1dcda78af1fff0dbd',
notes
};

const context = {};

await verifyConditions.call(
Expand Down
Loading

0 comments on commit da2e0f9

Please sign in to comment.