diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f99aab08f..20f6b8519 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87b06cefc..572e0b53c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,6 +37,7 @@ 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 }} @@ -44,3 +45,8 @@ jobs: 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 }} diff --git a/tools/bot-notify-build.mjs b/tools/bot-notify-build.mjs index 031c4848b..c4a0980d6 100644 --- a/tools/bot-notify-build.mjs +++ b/tools/bot-notify-build.mjs @@ -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 -g -v ',], - require: ["url", 'groupNumber', 'version'], + description: 'Bot sends a notification about the latest building in the QQ group.', + examples: ['node ./bot-notify-build.mjs -v ',], + 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", @@ -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) } diff --git a/tools/bot-notify-release.mjs b/tools/bot-notify-release.mjs new file mode 100644 index 000000000..ea8bf30fd --- /dev/null +++ b/tools/bot-notify-release.mjs @@ -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 -v ',], + 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() +} diff --git a/tools/publish-release.mjs b/tools/publish-release.mjs index 13b17002a..c63001747 100644 --- a/tools/publish-release.mjs +++ b/tools/publish-release.mjs @@ -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') diff --git a/tools/r.mjs b/tools/r.mjs new file mode 100644 index 000000000..9fc236475 --- /dev/null +++ b/tools/r.mjs @@ -0,0 +1 @@ +export const qqGroupNumber = "917740212"