forked from BlackPeter13/LightningTipBot
-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (62 loc) · 2.44 KB
/
Copy pathrelease.yml
File metadata and controls
71 lines (62 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Release
on:
pull_request:
types: [closed]
branches:
- main
permissions:
contents: write
jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
BOT_TOKEN: ${{ secrets.MAIN_BOT_TOKEN }}
CHAT_ID: ${{ vars.RELEASE_CHAT_IDS }}
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.21'
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
- name: Create local tag
run: git tag ${{ steps.tag_version.outputs.new_tag }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify Telegram Success
if: success()
run: |
IFS=',' read -ra TARGETS <<< "${{ env.CHAT_ID }}"
for target in "${TARGETS[@]}"; do
target=$(echo "$target" | xargs)
if [[ "$target" == *":"* ]]; then
chat_id=${target%%:*}
thread_id=${target#*:}
curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \
-d chat_id="$chat_id" \
-d message_thread_id="$thread_id" \
-d text="🚀 *New Release Published!*%0A%0A*Version:* ${{ steps.tag_version.outputs.new_tag }}%0A*Title:* ${PR_TITLE}%0A*Author:* ${{ github.actor }}%0A%0A[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.new_tag }})" \
-d parse_mode="Markdown"
else
curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \
-d chat_id="$target" \
-d text="🚀 *New Release Published!*%0A%0A*Version:* ${{ steps.tag_version.outputs.new_tag }}%0A*Title:* ${PR_TITLE}%0A*Author:* ${{ github.actor }}%0A%0A[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.new_tag }})" \
-d parse_mode="Markdown"
fi
done