From c6b143e238dcb0358d443a031e069f345a0f3aab Mon Sep 17 00:00:00 2001
From: Pk-web6936 <202365630+Pk-web6936@users.noreply.github.com>
Date: Fri, 18 Apr 2025 14:36:05 +0330
Subject: [PATCH] Update release.yml

---
 .github/workflows/release.yml | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 1d267b5d..a8319a92 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,13 +1,17 @@
-name: Release 3X-UI
+name: Build and Release 3X-UI
 
 on:
   workflow_dispatch:
+  release:
+    types: [published]
   push:
-    tags:
-      - "v*.*.*"
+  pull_request:
+    types: [opened, synchronize, reopened]
 
 jobs:
   build:
+    permissions:
+      contents: write
     strategy:
       matrix:
         platform:
@@ -18,7 +22,7 @@ jobs:
           - 386
           - armv5
           - s390x
-    runs-on: ubuntu-22.04
+    runs-on: ubuntu-latest
     steps:
       - name: Checkout repository
         uses: actions/checkout@v4
@@ -27,6 +31,7 @@ jobs:
         uses: actions/setup-go@v5
         with:
           go-version-file: go.mod
+          check-latest: true
 
       - name: Install dependencies
         run: |
@@ -45,7 +50,7 @@ jobs:
             sudo apt install gcc-s390x-linux-gnu
           fi
 
-      - name: Build x-ui
+      - name: Build 3x-ui
         run: |
           export CGO_ENABLED=1
           export GOOS=linux
@@ -134,6 +139,7 @@ jobs:
 
       - name: Upload files to GH release
         uses: svenstaro/upload-release-action@v2
+        if: github.event_name == 'release'
         with:
           repo_token: ${{ secrets.GITHUB_TOKEN }}
           tag: ${{ github.ref }}