Skip to content

Commit 970e13c

Browse files
committed
update(workflows): Fix Webhooks
1 parent fb59b68 commit 970e13c

File tree

1 file changed

+64
-74
lines changed

1 file changed

+64
-74
lines changed

.github/workflows/build.yml

Lines changed: 64 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -339,97 +339,87 @@ jobs:
339339
if: github.ref == 'refs/heads/beta'
340340
id: beta_commits
341341
run: |
342-
COMMITS=$(git log -5 --pretty=format:"• %s (%h)" | head -c 1000)
342+
# Get the previous tag
343+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
344+
345+
# Get commits since previous tag, or last 10 if no previous tag
346+
if [ -n "$PREV_TAG" ]; then
347+
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"• %s (\`%h\`)" | head -c 900)
348+
else
349+
COMMITS=$(git log -10 --pretty=format:"• %s (\`%h\`)" | head -c 900)
350+
fi
351+
352+
# If commits are empty, set a default message
353+
if [ -z "$COMMITS" ]; then
354+
COMMITS="No commit information available"
355+
fi
356+
343357
echo "summary<<EOF" >> $GITHUB_OUTPUT
344358
echo "$COMMITS" >> $GITHUB_OUTPUT
345359
echo "EOF" >> $GITHUB_OUTPUT
346360
347361
- name: Send Discord notification (Beta)
348362
if: github.ref == 'refs/heads/beta'
349-
run: |
350-
curl -H "Content-Type: application/json" \
351-
-d '{
352-
"embeds": [{
353-
"title": "🚀 New Beta Release",
354-
"description": "**SwiftlyS2** v${{ needs.versioning.outputs.semVer }} has been released!",
355-
"color": 65261,
356-
"fields": [
357-
{
358-
"name": "📦 Version",
359-
"value": "`${{ needs.versioning.outputs.semVer }}`",
360-
"inline": true
361-
},
362-
{
363-
"name": "🔖 Tag",
364-
"value": "`${{ env.TAG_NAME }}`",
365-
"inline": true
366-
},
367-
{
368-
"name": "📝 Recent Commits",
369-
"value": "${{ steps.beta_commits.outputs.summary }}",
370-
"inline": false
371-
},
372-
{
373-
"name": "📥 Download",
374-
"value": "[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG_NAME }})",
375-
"inline": false
376-
}
377-
],
378-
"timestamp": "${{ github.event.head_commit.timestamp }}",
379-
"footer": {
380-
"text": "Beta Release • SwiftlyS2"
381-
}
382-
}]
383-
}' \
384-
${{ secrets.DISCORD_WEBHOOK_BETA }}
363+
uses: tsickert/[email protected]
364+
with:
365+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_BETA }}
366+
embed-title: "🚀 New Beta Release"
367+
embed-description: |
368+
**SwiftlyS2** v${{ needs.versioning.outputs.semVer }} has been released!
369+
370+
**📦 Version:** `${{ needs.versioning.outputs.semVer }}`
371+
**🔖 Tag:** `${{ env.TAG_NAME }}`
372+
373+
**📝 Recent Commits:**
374+
${{ steps.beta_commits.outputs.summary }}
375+
376+
**📥 Download:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG_NAME }})
377+
embed-color: 65261
378+
embed-timestamp: ${{ github.event.head_commit.timestamp }}
379+
embed-footer-text: "Beta Release • SwiftlyS2"
385380

386381
- name: Get commit summary for master
387382
if: github.ref == 'refs/heads/master'
388383
id: master_commits
389384
run: |
390-
COMMITS=$(git log -10 --pretty=format:"• %s (%h)" | head -c 1000)
385+
# Get the previous tag
386+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
387+
388+
# Get commits since previous tag, or last 15 if no previous tag
389+
if [ -n "$PREV_TAG" ]; then
390+
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"• %s (\`%h\`)" | head -c 900)
391+
else
392+
COMMITS=$(git log -15 --pretty=format:"• %s (\`%h\`)" | head -c 900)
393+
fi
394+
395+
# If commits are empty, set a default message
396+
if [ -z "$COMMITS" ]; then
397+
COMMITS="No commit information available"
398+
fi
399+
391400
echo "summary<<EOF" >> $GITHUB_OUTPUT
392401
echo "$COMMITS" >> $GITHUB_OUTPUT
393402
echo "EOF" >> $GITHUB_OUTPUT
394403
395404
- name: Send Discord notification (Master)
396405
if: github.ref == 'refs/heads/master'
397-
run: |
398-
curl -H "Content-Type: application/json" \
399-
-d '{
400-
"embeds": [{
401-
"title": "✨ New Stable Release",
402-
"description": "**SwiftlyS2** v${{ needs.versioning.outputs.semVer }} is now available!",
403-
"color": 65261,
404-
"fields": [
405-
{
406-
"name": "📦 Version",
407-
"value": "`${{ needs.versioning.outputs.semVer }}`",
408-
"inline": true
409-
},
410-
{
411-
"name": "🔖 Tag",
412-
"value": "`${{ env.TAG_NAME }}`",
413-
"inline": true
414-
},
415-
{
416-
"name": "📝 Changelog Summary",
417-
"value": "${{ steps.master_commits.outputs.summary }}",
418-
"inline": false
419-
},
420-
{
421-
"name": "📥 Download",
422-
"value": "[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG_NAME }})",
423-
"inline": false
424-
}
425-
],
426-
"timestamp": "${{ github.event.head_commit.timestamp }}",
427-
"footer": {
428-
"text": "Stable Release • SwiftlyS2"
429-
}
430-
}]
431-
}' \
432-
${{ secrets.DISCORD_WEBHOOK_MASTER }}
406+
uses: tsickert/[email protected]
407+
with:
408+
webhook-url: ${{ secrets.DISCORD_WEBHOOK_MASTER }}
409+
embed-title: "✨ New Stable Release"
410+
embed-description: |
411+
**SwiftlyS2** v${{ needs.versioning.outputs.semVer }} is now available!
412+
413+
**📦 Version:** `${{ needs.versioning.outputs.semVer }}`
414+
**🔖 Tag:** `${{ env.TAG_NAME }}`
415+
416+
**📝 Changelog Summary:**
417+
${{ steps.master_commits.outputs.summary }}
418+
419+
**📥 Download:** [View Release](https://github.com/${{ github.repository }}/releases/tag/${{ env.TAG_NAME }})
420+
embed-color: 65261
421+
embed-timestamp: ${{ github.event.head_commit.timestamp }}
422+
embed-footer-text: "Stable Release • SwiftlyS2"
433423
nuget:
434424
if: ${{ github.event_name == 'push' && github.repository_owner == 'swiftly-solution' }}
435425
needs: [versioning, releasing]

0 commit comments

Comments
 (0)