From a9e01221e98a986edeab6137a5d8d3a421a5ba12 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Fri, 28 Nov 2025 16:16:44 +0530 Subject: [PATCH 01/12] feat: add release workflow and GoReleaser configuration --- .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ .goreleaser.yaml | 24 ++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..74c87563 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +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.DEV_ACTIONS_BOT_TOKEN }} + CHAT_ID: ${{ secrets.DEV_ACTIONS_GROUP_ID }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + 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: 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: | + curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \ + -d chat_id="${{ env.CHAT_ID }}" \ + -d text="๐Ÿš€ *New Release Published!*%0A%0A*Version:* ${{ steps.tag_version.outputs.new_tag }}%0A*Title:* ${{ github.event.pull_request.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" + + - name: Notify Telegram Failure + if: failure() + run: | + curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \ + -d chat_id="${{ env.CHAT_ID }}" \ + -d text="โŒ *Release Failed!*%0A%0AThe release workflow failed for PR: ${{ github.event.pull_request.title }}" \ + -d parse_mode="Markdown" diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..07222a8b --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,24 @@ +project_name: BitcoinDeepaBot +builds: + - env: + - CGO_ENABLED=1 + goos: + - linux + goarch: + - amd64 + flags: + - -a + - -installsuffix + - cgo + ldflags: + - -s -w +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' From 04694530305d3042115f2539450df0000237e5b9 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Fri, 28 Nov 2025 19:44:44 +0530 Subject: [PATCH 02/12] feat: implement memo caching in Send API and enhance Cache utility --- internal/api/lightning.go | 4 +++- internal/api/send.go | 17 +++++++++++++++-- internal/utils/cache.go | 6 ++++++ main.go | 9 +++++++-- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/internal/api/lightning.go b/internal/api/lightning.go index 105c3d1a..bbdcb1d7 100644 --- a/internal/api/lightning.go +++ b/internal/api/lightning.go @@ -9,12 +9,14 @@ import ( "github.com/LightningTipBot/LightningTipBot/internal" "github.com/LightningTipBot/LightningTipBot/internal/lnbits" "github.com/LightningTipBot/LightningTipBot/internal/telegram" + "github.com/LightningTipBot/LightningTipBot/internal/utils" "github.com/gorilla/mux" "github.com/r3labs/sse" ) type Service struct { - Bot *telegram.TipBot + Bot *telegram.TipBot + MemoCache *utils.Cache } type ErrorResponse struct { diff --git a/internal/api/send.go b/internal/api/send.go index 10b5b76f..bec2863f 100644 --- a/internal/api/send.go +++ b/internal/api/send.go @@ -118,7 +118,7 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { RespondError(w, "Authentication failed") return } - + walletID := authenticatedWallet.(string) wallet, exists := GetWhitelistedWallets()[walletID] if !exists { @@ -126,7 +126,7 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { RespondError(w, "Invalid wallet configuration") return } - + fromUsername := wallet.Username // Validate request @@ -150,6 +150,19 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { return } + if req.Memo != "" { + memoLockKey := fmt.Sprintf("api_send_memo_%s", req.Memo) + if _, exists := s.MemoCache.Get(memoLockKey); exists { + log.Warnf("[api/send] Transaction with memo '%s' is already processing", req.Memo) + RespondError(w, fmt.Sprintf("Transaction with memo '%s' is already processing", req.Memo)) + return + } + // Lock the memo + s.MemoCache.Set(memoLockKey, "locked") + // Unlock when done + defer s.MemoCache.Delete(memoLockKey) + } + // Clean usernames (remove @ if present) toIdentifier := strings.TrimPrefix(req.To, "@") diff --git a/internal/utils/cache.go b/internal/utils/cache.go index 8fe13674..638f4b42 100644 --- a/internal/utils/cache.go +++ b/internal/utils/cache.go @@ -43,3 +43,9 @@ func (c *Cache) Get(key string) (string, bool) { } return item.value, true } + +func (c *Cache) Delete(key string) { + c.mutex.Lock() + defer c.mutex.Unlock() + delete(c.data, key) +} diff --git a/main.go b/main.go index b78b798a..158613cd 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "net/http" "runtime/debug" "strings" + "time" "github.com/LightningTipBot/LightningTipBot/internal" "github.com/LightningTipBot/LightningTipBot/internal/api" @@ -21,6 +22,7 @@ import ( "github.com/LightningTipBot/LightningTipBot/internal/lnbits/webhook" "github.com/LightningTipBot/LightningTipBot/internal/price" + "github.com/LightningTipBot/LightningTipBot/internal/utils" log "github.com/sirupsen/logrus" ) @@ -89,7 +91,10 @@ func startApiServer(bot *telegram.TipBot) { s.AppendAuthorizedRoute(`/lndhub/ext`, api.AuthTypeBearerBase64, api.AccessKeyTypeAdmin, bot.DB.Users, hub.Handle) // starting api service - apiService := api.Service{Bot: bot} + apiService := api.Service{ + Bot: bot, + MemoCache: utils.NewCache(time.Minute * 5), + } s.AppendAuthorizedRoute(`/api/v1/paymentstatus/{payment_hash}`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.PaymentStatus, http.MethodPost) s.AppendAuthorizedRoute(`/api/v1/invoicestatus/{payment_hash}`, api.AuthTypeBasic, api.AccessKeyTypeInvoice, bot.DB.Users, apiService.InvoiceStatus, http.MethodPost) s.AppendAuthorizedRoute(`/api/v1/payinvoice`, api.AuthTypeBasic, api.AccessKeyTypeAdmin, bot.DB.Users, apiService.PayInvoice, http.MethodPost) @@ -101,7 +106,7 @@ func startApiServer(bot *telegram.TipBot) { if internal.IsAPISendEnabled() { s.AppendRoute(`/api/v1/send`, api.WalletHMACMiddleware(apiService.Send), http.MethodPost) log.Infof("API Send endpoint registered at /api/v1/send with wallet-based HMAC security") - + // User balance endpoint with wallet-based HMAC security s.AppendRoute(`/api/v1/userbalance`, api.WalletHMACMiddleware(apiService.UserBalance), http.MethodPost) log.Infof("API UserBalance endpoint registered at /api/v1/userbalance with wallet-based HMAC security") From b1503dec665ad93a3ed7e90a3568089202180002 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 15:12:45 +0530 Subject: [PATCH 03/12] feat: add duplicate memo check in Send API to prevent reprocessing transactions --- internal/api/send.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/internal/api/send.go b/internal/api/send.go index bec2863f..db66777e 100644 --- a/internal/api/send.go +++ b/internal/api/send.go @@ -157,6 +157,26 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { RespondError(w, fmt.Sprintf("Transaction with memo '%s' is already processing", req.Memo)) return } + + // Check if transaction with this memo already exists in database + // We search for the memo in the transaction memo field + // The stored memo format is: "๐Ÿ’ธ API Send from @User to @User. Memo: " + // So we search for the suffix "Memo: " + var count int64 + memoSearch := fmt.Sprintf("%%Memo: %s", req.Memo) + err := s.Bot.DB.Transactions.Model(&telegram.Transaction{}).Where("memo LIKE ? AND success = ?", memoSearch, true).Count(&count).Error + if err != nil { + log.Errorf("[api/send] Database error checking for duplicate memo: %v", err) + // Continue but log error - fail open or closed? Let's fail closed for safety + RespondError(w, "Internal server error checking transaction history") + return + } + if count > 0 { + log.Warnf("[api/send] Transaction with memo '%s' already completed", req.Memo) + RespondError(w, fmt.Sprintf("Transaction with memo '%s' already completed", req.Memo)) + return + } + // Lock the memo s.MemoCache.Set(memoLockKey, "locked") // Unlock when done From e0a75bd82b81592d9957b620a37a7fa262476432 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 15:33:51 +0530 Subject: [PATCH 04/12] feat: update Telegram notification logic in release workflow to support multiple chat IDs --- .github/workflows/release.yml | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 74c87563..e628435c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,8 +14,8 @@ jobs: if: github.event.pull_request.merged == true runs-on: ubuntu-latest env: - BOT_TOKEN: ${{ secrets.DEV_ACTIONS_BOT_TOKEN }} - CHAT_ID: ${{ secrets.DEV_ACTIONS_GROUP_ID }} + BOT_TOKEN: ${{ secrets.MAIN_BOT_TOKEN }} + CHAT_ID: ${{ secrets.RELEASE_CHAT_IDS }} steps: - name: Checkout uses: actions/checkout@v4 @@ -46,15 +46,22 @@ jobs: - name: Notify Telegram Success if: success() run: | - curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \ - -d chat_id="${{ env.CHAT_ID }}" \ - -d text="๐Ÿš€ *New Release Published!*%0A%0A*Version:* ${{ steps.tag_version.outputs.new_tag }}%0A*Title:* ${{ github.event.pull_request.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" + 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:* ${{ github.event.pull_request.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:* ${{ github.event.pull_request.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 - - name: Notify Telegram Failure - if: failure() - run: | - curl -s -X POST https://api.telegram.org/bot${{ env.BOT_TOKEN }}/sendMessage \ - -d chat_id="${{ env.CHAT_ID }}" \ - -d text="โŒ *Release Failed!*%0A%0AThe release workflow failed for PR: ${{ github.event.pull_request.title }}" \ - -d parse_mode="Markdown" From debec87921814c2b2ce41d729fbd821a42740b1c Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 15:44:03 +0530 Subject: [PATCH 05/12] ci: use Actions variables for release chat IDs (RELEASE_CHAT_IDS, DEV_RELEASE_CHAT_IDS) and support threads in Telegram notifications --- .github/workflows/release-dev.yml | 73 +++++++++++++++++++++++++++++++ .github/workflows/release.yml | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-dev.yml diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml new file mode 100644 index 00000000..7ff720bd --- /dev/null +++ b/.github/workflows/release-dev.yml @@ -0,0 +1,73 @@ +name: Dev Release + +on: + push: + branches: + - dev + +permissions: + contents: write + +jobs: + release-dev: + runs-on: ubuntu-latest + env: + BOT_TOKEN: ${{ secrets.MAIN_BOT_TOKEN }} + CHAT_ID: ${{ vars.DEV_RELEASE_CHAT_IDS }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Tag dev build + id: tag_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: dev-${{ github.sha }} + tag_prefix: "" + + - name: Run GoReleaser (dev) + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Mark as prerelease + run: gh release edit ${{ steps.tag_version.outputs.new_tag }} --prerelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Notify Telegram (Dev) + if: success() + run: | + IFS=',' read -ra TARGETS <<< "${{ env.CHAT_ID }}" + for target in "${TARGETS[@]}"; do + target=$(echo "$target" | xargs) + if [[ -z "$target" ]]; then + continue + fi + 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 Dev Build Published!*%0A%0A*Tag:* ${{ steps.tag_version.outputs.new_tag }}%0A*Commit:* ${{ github.sha }}%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 Dev Build Published!*%0A%0A*Tag:* ${{ steps.tag_version.outputs.new_tag }}%0A*Commit:* ${{ github.sha }}%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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e628435c..f72f730a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest env: BOT_TOKEN: ${{ secrets.MAIN_BOT_TOKEN }} - CHAT_ID: ${{ secrets.RELEASE_CHAT_IDS }} + CHAT_ID: ${{ vars.RELEASE_CHAT_IDS }} steps: - name: Checkout uses: actions/checkout@v4 From 7ba9fb4475bebb37093afaf80528d374060d46b9 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 15:52:46 +0530 Subject: [PATCH 06/12] feat: implement memo locking mechanism in Send API to prevent duplicate transactions --- internal/api/send.go | 11 +++++------ internal/utils/cache.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/internal/api/send.go b/internal/api/send.go index db66777e..0c3c353f 100644 --- a/internal/api/send.go +++ b/internal/api/send.go @@ -152,11 +152,15 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { if req.Memo != "" { memoLockKey := fmt.Sprintf("api_send_memo_%s", req.Memo) - if _, exists := s.MemoCache.Get(memoLockKey); exists { + + // Try to acquire lock first to prevent concurrent processing + if success := s.MemoCache.SetNX(memoLockKey, "locked"); !success { log.Warnf("[api/send] Transaction with memo '%s' is already processing", req.Memo) RespondError(w, fmt.Sprintf("Transaction with memo '%s' is already processing", req.Memo)) return } + // Unlock when done + defer s.MemoCache.Delete(memoLockKey) // Check if transaction with this memo already exists in database // We search for the memo in the transaction memo field @@ -176,11 +180,6 @@ func (s Service) Send(w http.ResponseWriter, r *http.Request) { RespondError(w, fmt.Sprintf("Transaction with memo '%s' already completed", req.Memo)) return } - - // Lock the memo - s.MemoCache.Set(memoLockKey, "locked") - // Unlock when done - defer s.MemoCache.Delete(memoLockKey) } // Clean usernames (remove @ if present) diff --git a/internal/utils/cache.go b/internal/utils/cache.go index 638f4b42..f90db015 100644 --- a/internal/utils/cache.go +++ b/internal/utils/cache.go @@ -49,3 +49,20 @@ func (c *Cache) Delete(key string) { defer c.mutex.Unlock() delete(c.data, key) } + +// SetNX sets the key if it does not exist or has expired. Returns true if set, false if already exists. +func (c *Cache) SetNX(key string, value string) bool { + c.mutex.Lock() + defer c.mutex.Unlock() + + item, exists := c.data[key] + if exists && time.Now().Before(item.expiration) { + return false + } + + c.data[key] = CacheItem{ + value: value, + expiration: time.Now().Add(c.ttl), + } + return true +} From 37dcf9703b580341733a3c881d3dd5fa1e026fb3 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 15:55:15 +0530 Subject: [PATCH 07/12] feat: add step to create local tag in release workflow --- .github/workflows/release-dev.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 7ff720bd..b4abc94b 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -33,6 +33,9 @@ jobs: custom_tag: dev-${{ github.sha }} tag_prefix: "" + - name: Create local tag + run: git tag ${{ steps.tag_version.outputs.new_tag }} + - name: Run GoReleaser (dev) uses: goreleaser/goreleaser-action@v5 with: From 7d5f4889d64479a240a05a4c93472a3be85e976b Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 16:27:14 +0530 Subject: [PATCH 08/12] feat: update custom tag format in release workflow to include version prefix --- .github/workflows/release-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index b4abc94b..c42001f9 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -30,7 +30,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: dev-${{ github.sha }} + custom_tag: v0.0.0-dev-${{ github.sha }} tag_prefix: "" - name: Create local tag From 13897a5b73d373a1f9f13682fd0f8d96e993e7a0 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Mon, 1 Dec 2025 16:54:42 +0530 Subject: [PATCH 09/12] feat: update version tagging logic in release workflows to use calculated version --- .github/workflows/release-dev.yml | 10 +++++++++- .github/workflows/release.yml | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index c42001f9..10daed44 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -25,12 +25,20 @@ jobs: with: go-version: '1.21' + - name: Calculate next version + id: calc_version + uses: mathieudutour/github-tag-action@v6.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + dry_run: true + tag_prefix: "v" + - name: Tag dev build id: tag_version uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: v0.0.0-dev-${{ github.sha }} + custom_tag: v${{ steps.calc_version.outputs.new_version }}-dev-${{ github.sha }} tag_prefix: "" - name: Create local tag diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f72f730a..9fc88c60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,9 @@ jobs: 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: From d85c77a60f26b3770ac00cdaac35283d9aa77904 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Tue, 2 Dec 2025 12:20:05 +0530 Subject: [PATCH 10/12] feat: upgrade setup-go action to v6 and use PR title in Telegram notifications --- .github/workflows/release-dev.yml | 2 +- .github/workflows/release.yml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 10daed44..a1f602c4 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -21,7 +21,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version: '1.21' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9fc88c60..142071b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,6 +16,7 @@ jobs: 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 @@ -23,7 +24,7 @@ jobs: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version: '1.21' @@ -58,12 +59,12 @@ jobs: 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:* ${{ github.event.pull_request.title }}%0A*Author:* ${{ github.actor }}%0A%0A[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.new_tag }})" \ + -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:* ${{ github.event.pull_request.title }}%0A*Author:* ${{ github.actor }}%0A%0A[View Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.tag_version.outputs.new_tag }})" \ + -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 From 33f57cfde0ab1bb22b964e2e903ec5d5d9e74852 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Tue, 2 Dec 2025 12:29:40 +0530 Subject: [PATCH 11/12] feat: update custom tag format in release workflow to use short SHA --- .github/workflows/release-dev.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index a1f602c4..023f6894 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -25,6 +25,10 @@ jobs: with: go-version: '1.21' + - name: Get short SHA + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Calculate next version id: calc_version uses: mathieudutour/github-tag-action@v6.1 @@ -38,7 +42,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: v${{ steps.calc_version.outputs.new_version }}-dev-${{ github.sha }} + custom_tag: v${{ steps.calc_version.outputs.new_version }}-${{ steps.vars.outputs.sha_short }} tag_prefix: "" - name: Create local tag From c24dca7d55683d660194ef81d13425d44f684300 Mon Sep 17 00:00:00 2001 From: Buddhi Thilakshana Date: Tue, 2 Dec 2025 12:32:58 +0530 Subject: [PATCH 12/12] feat: update custom tag format in release workflow to include version components --- .github/workflows/release-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 023f6894..63f6a5fc 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -42,7 +42,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: v${{ steps.calc_version.outputs.new_version }}-${{ steps.vars.outputs.sha_short }} + custom_tag: v${{ steps.calc_version.outputs.major }}.${{ steps.calc_version.outputs.minor }}.${{ steps.calc_version.outputs.patch }}-${{ steps.vars.outputs.sha_short }} tag_prefix: "" - name: Create local tag