Skip to content

Commit

Permalink
ci(docs): generate release from CHANGELOG.md + discordjs integration
Browse files Browse the repository at this point in the history
  • Loading branch information
JiPaix committed Aug 2, 2021
1 parent 4728fa8 commit 5b9ed61
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 21 deletions.
35 changes: 15 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
# Changelog

## [v4.2.6](https://github.com/jipaix/xdccjs/tree/v4.2.6)
### New feature
- Display list of failed package when a job is done [#236](https://github.com/JiPaix/xdccJS/pull/236)
- added an extra verbose notification when a job is complete with the list of all packages that failed
### Fix
- Client:
- changed profile location to user's home directory [#237](https://github.com/JiPaix/xdccJS/pull/237)
- some (linux) users couldn't save profile due to invalid write permission
- warn user if multiple profile option are used in the same command [#237](https://github.com/JiPaix/xdccJS/pull/237)
- if `--save/set/delete-profile` is set, downloads cannot be triggered [#237](https://github.com/JiPaix/xdccJS/pull/237)
### Misc:
- Chores:
- dev-deps:
- bump @types/node from 16.4.7 to 16.4.10 [#231](https://github.com/JiPaix/xdccJS/pull/231)
- bump typedoc from 0.21.4 to 0.21.5 [#232](https://github.com/JiPaix/xdccJS/pull/232)
- bump @types/node from 16.4.7 to 16.4.10 [#233](https://github.com/JiPaix/xdccJS/pull/232)
- CI:
- Keyword for skipping ci changed to `[ci skip]` [c252f207](https://github.com/JiPaix/xdccJS/commit/c252f2077ed6e729e69a89c20fdd3d634379a743)
- Dependency update check interval changed from daily to weekly [4da55709](https://github.com/JiPaix/xdccJS/commit/4da55709d55f32ae4b75a9ce146caefc1548e955)
- Docs:
- fixing header position and icons url [c02314d4](https://github.com/JiPaix/xdccJS/commit/c02314d499dc40d1af0e6de2630646373887c227) [cd3942dc](https://github.com/JiPaix/xdccJS/commit/cd3942dcad60e6885f5d571c9807a52b41d0421e)
### Features(gobal)
* added an extra verbose notification when a job is complete with the list of all packages that failed [#236](https://github.com/JiPaix/xdccJS/pull/236)
### Fix(bin)
* changed profile location to user's home directory, some (linux) users couldn't save profile due to invalid write permission [#237](https://github.com/JiPaix/xdccJS/pull/237)
* warn user if multiple profile option are used in the same command [#237](https://github.com/JiPaix/xdccJS/pull/237)
* downloads cannot be triggered if `--save/set/delete-profile` is set [#237](https://github.com/JiPaix/xdccJS/pull/237)
### Chores(dev-deps)
* bump @types/node from 16.4.7 to 16.4.10 [#231](https://github.com/JiPaix/xdccJS/pull/231)
* bump typedoc from 0.21.4 to 0.21.5 [#232](https://github.com/JiPaix/xdccJS/pull/232)
* bump @types/node from 16.4.7 to 16.4.10 [#233](https://github.com/JiPaix/xdccJS/pull/232)
### CI
* changed keyword for skipping ci to `[ci skip]` [c252f207](https://github.com/JiPaix/xdccJS/commit/c252f2077ed6e729e69a89c20fdd3d634379a743)
* changed dependency update check interval from daily to weekly [4da55709](https://github.com/JiPaix/xdccJS/commit/4da55709d55f32ae4b75a9ce146caefc1548e955)
### Docs
* fixing header position and icons url [c02314d4](https://github.com/JiPaix/xdccJS/commit/c02314d499dc40d1af0e6de2630646373887c227) [cd3942dc](https://github.com/JiPaix/xdccJS/commit/cd3942dcad60e6885f5d571c9807a52b41d0421e)
---
## [v4.2.5](https://github.com/jipaix/xdccjs/tree/v4.2.5)
### Fix:
Expand Down
53 changes: 53 additions & 0 deletions build/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const fs = require('fs')
const axios = require('axios')
const { Client, Intents, MessageEmbed } = require('discord.js');

const version = require('../package.json').version

let changelog = fs.readFileSync('./CHANGELOG.md').toString().split('---')[0].split(/(?=###)/gm)
changelog.shift()

const discordFields = []

axios.default.post('https://api.github.com/repos/jipaix/xdccjs/releases', {
tag_name: 'v'+version,
name: version,
body: changelog
},
{
headers: {
'Accept': 'application/vnd.github.v3+json',
'Authorization': 'token process.env.PA_TOKEN'
}
})
.then(r => {
discord.destroy()
}).catch(e => {
console.log(e.response.data)
})


const discord = new Client({
intents: Intents.NON_PRIVILEGED
});

const embed = new MessageEmbed()
for (const field of changelog) {
embed.addField(field.split(/\n|\r\n/g)[0].replace('### ', ''), field.replace(/###(.*)(\n|\r\n)/g, '').replace(/\[(.*)]\((.*)\)/g, ''), false)
console.log(embed.fields)
}
embed
.setTitle('v'+version+' has been released')
.setDescription('CHANGELOG')
.setURL('https://github.com/JiPaix/xdccJS/releases/tag/v'+version)
.setTimestamp(Date.now())
.setColor('DARK_GREEN')
.setThumbnail('https://github.com/JiPaix/xdccJS/raw/main/logo.png')
.setAuthor('JiPaix', 'https://avatars.githubusercontent.com/u/26584973?v=4', 'https://github.com/JiPaix')
discord.once('ready', () => {
discord.channels.fetch(process.env.DISCORD_CHANNEL_ID).then(channel => {
channel.send({embed}).then(console.log).catch(e => console.log(e))
})
});

discord.login(process.env.DISCORD_SECRET);
129 changes: 129 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"prepublishOnly": "npm run build",
"snyk-wiz": "node ./node_modules/snyk/dist/cli/index.js wizard",
"doc": "node ./node_modules/typedoc/bin/typedoc && node ./build/doc.js",
"intellisense": "node ./build/index.js"
"intellisense": "node ./build/index.js",
"postpublish": "node ./build/changelog.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -55,7 +56,9 @@
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"@wcardinal/typedoc-plugin-named-event": "^1.0.0",
"axios": "^0.21.1",
"chai": "^4.2.0",
"discord.js": "^12.5.3",
"dotenv-manipulator": "^3.0.1",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
Expand Down

0 comments on commit 5b9ed61

Please sign in to comment.