Skip to content

Commit

Permalink
[tools] bot notify release
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed May 27, 2024
1 parent e236792 commit 6061192
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
with:
branch: ${{ github.ref }}

- name: Send Message to Group
- name: Notify the latest building
continue-on-error: true
run: |
node tools/bot-notify-build.mjs ${{ secrets.gocq_sendgroupmsg_url }} -g ${{ secrets.gocq_group_number }} -v ${{ env.LATEST_VERSION }}
node tools/bot-notify-build.mjs ${{ secrets.gocq_sendgroupmsg_url }} -v ${{ env.LATEST_VERSION }}
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ jobs:
cd tools && npm i && cd ..
- name: Upload artifacts onto SIT-MC sever
if: github.repository == 'liplum-dev/mimir'
run: |
node tools/upload-release-sitmc.mjs -k ${{ secrets.SITMC_TEMP_SERVER_AUTH }}
- name: Deploy
if: github.repository == 'liplum-dev/mimir'
run: |
node tools/publish-release.mjs
- name: Notify the latest release
continue-on-error: true
run: |
node tools/bot-notify-release.mjs ${{ secrets.gocq_sendgroupmsg_url }}
14 changes: 5 additions & 9 deletions tools/bot-notify-build.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import esMain from "es-main"
import { sendMessageToQQGroup } from "./lib/bot.mjs"
import { cli } from '@liplum/cli'
import { qqGroupNumber } from "./r.mjs"

async function main() {
const args = cli({
name: 'bot-notify-build',
description: 'Bot sends a notification about the latest building in the specified QQ group.',
examples: ['node ./bot-notify-build.mjs -u <url> -g <number> -v <version>',],
require: ["url", 'groupNumber', 'version'],
description: 'Bot sends a notification about the latest building in the QQ group.',
examples: ['node ./bot-notify-build.mjs <url> -v <version>',],
require: ["url", 'version'],
options: [{
name: 'url',
alias: "u",
defaultOption: true,
description: 'The bot url.'
}, {
name: 'groupNumber',
alias: "g",
description: 'The number of QQ group to send notifications.'
}, {
name: 'version',
alias: "v",
Expand All @@ -25,9 +22,8 @@ async function main() {
})
const botUrl = args.url
const version = args.version
const groupNumber = args.groupNumber
const message = `最新测试版${version}已完成构建,Android用户可在群公告中访问最新预览版下载地址;请iOS用户等待发布TestFlight测试`
const result = await sendMessageToQQGroup({ botUrl, groupNumber, message })
const result = await sendMessageToQQGroup({ botUrl, groupNumber: qqGroupNumber, message })
console.log(result)
}

Expand Down
32 changes: 32 additions & 0 deletions tools/bot-notify-release.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import esMain from "es-main"
import { sendMessageToQQGroup } from "./lib/bot.mjs"
import { cli } from '@liplum/cli'
import { qqGroupNumber } from "./r.mjs"
import { getReleaseNote } from "./publish-release.mjs"

async function main() {
const args = cli({
name: 'bot-notify-release',
description: 'Bot sends a notification about the latest release in the QQ group.',
examples: ['node ./bot-notify-release.mjs <url> -v <version>',],
require: ["url"],
options: [{
name: 'url',
alias: "u",
defaultOption: true,
description: 'The bot url.'
},],
})
const botUrl = args.url
const releaseNote = getReleaseNote()
const result = await sendMessageToQQGroup({
botUrl,
groupNumber: qqGroupNumber,
message: releaseNote,
})
console.log(result)
}

if (esMain(import.meta)) {
main()
}
2 changes: 1 addition & 1 deletion tools/publish-release.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getVersion() {
return github.release.tag_name.slice(1)
}

function getReleaseNote() {
export function getReleaseNote() {
const text = github.release.body
const startLine = text.indexOf('## 更改')
const endLine = text.indexOf('## How to download')
Expand Down
1 change: 1 addition & 0 deletions tools/r.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const qqGroupNumber = "917740212"

0 comments on commit 6061192

Please sign in to comment.