diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 05d90f92..3e19a84a 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -153,3 +153,17 @@ jobs: git add VERSION package.json git commit -m "chore(release): ${{ steps.bump.outputs.new }} [skip ci]" git push origin dev + + - name: Notify Discord + if: success() + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + VERSION: ${{ steps.bump.outputs.new }} + run: | + if [ -z "$DISCORD_WEBHOOK_URL" ]; then + echo "DISCORD_WEBHOOK_URL not set, skipping notification" + exit 0 + fi + curl -s -X POST "$DISCORD_WEBHOOK_URL" \ + -H "Content-Type: application/json" \ + -d "{\"username\":\"CCS Dev Release\",\"embeds\":[{\"title\":\"Dev Release $VERSION\",\"url\":\"https://www.npmjs.com/package/@kaitranntt/ccs/v/$VERSION\",\"color\":15638323,\"description\":\"Pre-release version available for testing.\",\"footer\":{\"text\":\"npm i @kaitranntt/ccs@dev\"}}]}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ca53cf5..467f8907 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,3 +52,42 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: bunx semantic-release + + - name: Notify Discord + if: success() + uses: actions/github-script@v7 + env: + DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + if (!process.env.DISCORD_WEBHOOK_URL) { + core.warning('DISCORD_WEBHOOK_URL not set, skipping notification') + return + } + const { data: releases } = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo, + per_page: 1 + }) + if (!releases.length) { + core.warning('No releases found, skipping notification') + return + } + const r = releases[0] + const desc = (r.body || 'No changelog available').slice(0, 2000) + await fetch(process.env.DISCORD_WEBHOOK_URL, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + username: 'CCS Release', + embeds: [{ + title: `Release ${r.name || r.tag_name}`, + url: r.html_url, + color: 0x10B981, + description: desc, + timestamp: r.created_at, + footer: { text: 'npm i @kaitranntt/ccs@latest' } + }] + }) + })