From ce13b71f06efab97835df3a10d7f6da098097373 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 16:33:32 +0800 Subject: [PATCH 01/10] refactor: update fields type in userStatus and check registered. --- go.mod | 2 +- go.sum | 4 ++-- internal/api/router.go | 1 + internal/api/user.go | 6 +++--- internal/msggateway/hub_server.go | 8 ++++---- internal/rpc/auth/auth.go | 16 ++++++++++++++++ internal/rpc/group/callback.go | 2 +- internal/rpc/user/online.go | 3 ++- 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 789821d5b7..9e35bca6a9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.72-alpha.32 + github.com/openimsdk/protocol v0.0.72-alpha.36 github.com/openimsdk/tools v0.0.50-alpha.15 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 diff --git a/go.sum b/go.sum index 5f1b0a27e3..05951b9e40 100644 --- a/go.sum +++ b/go.sum @@ -319,8 +319,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y= github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.72-alpha.32 h1:GnGNVPc9Q/J1kA9KlxIcfciNtxXhxJXpwjFmGUYMJXY= -github.com/openimsdk/protocol v0.0.72-alpha.32/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8= +github.com/openimsdk/protocol v0.0.72-alpha.36 h1:j1hanJjvAgLfRZSGSdGoYkH3L0siBf5n6gFbvs2y5M0= +github.com/openimsdk/protocol v0.0.72-alpha.36/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8= github.com/openimsdk/tools v0.0.50-alpha.15 h1:HV9aKZ4vvCZCGG4wFDsgUONkkdJeCcrFNn3BT52nUVQ= github.com/openimsdk/tools v0.0.50-alpha.15/go.mod h1:h1cYmfyaVtgFbKmb1Cfsl8XwUOMTt8ubVUQrdGtsUh4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= diff --git a/internal/api/router.go b/internal/api/router.go index 8d2a688f40..7ef21bfaeb 100644 --- a/internal/api/router.go +++ b/internal/api/router.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "github.com/openimsdk/open-im-server/v3/internal/api/jssdk" "github.com/gin-contrib/gzip" diff --git a/internal/api/user.go b/internal/api/user.go index 306cedfb55..b499f71dc2 100644 --- a/internal/api/user.go +++ b/internal/api/user.go @@ -107,14 +107,14 @@ func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) { if v2.UserID == v1 { flag = true res.UserID = v1 - res.Status = constant.OnlineStatus + res.Status = constant.Online res.DetailPlatformStatus = append(res.DetailPlatformStatus, v2.DetailPlatformStatus...) break } } if !flag { res.UserID = v1 - res.Status = constant.OfflineStatus + res.Status = constant.Offline } respResult = append(respResult, res) } @@ -160,7 +160,7 @@ func (u *UserApi) GetUsersOnlineTokenDetail(c *gin.Context) { if v2.UserID == v1 { flag = true temp.UserID = v1 - temp.Status = constant.OnlineStatus + temp.Status = constant.Online for _, status := range v2.DetailPlatformStatus { if v, ok := m[status.PlatformID]; ok { m[status.PlatformID] = append(v, status.Token) diff --git a/internal/msggateway/hub_server.go b/internal/msggateway/hub_server.go index 66cb776342..e96ab4b0dc 100644 --- a/internal/msggateway/hub_server.go +++ b/internal/msggateway/hub_server.go @@ -16,6 +16,8 @@ package msggateway import ( "context" + "sync/atomic" + "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/servererrs" "github.com/openimsdk/open-im-server/v3/pkg/common/startrpc" @@ -30,7 +32,6 @@ import ( "github.com/openimsdk/tools/mq/memamq" "github.com/openimsdk/tools/utils/datautil" "google.golang.org/grpc" - "sync/atomic" ) func (s *Server) InitServer(ctx context.Context, config *Config, disCov discovery.SvcDiscoveryRegistry, server *grpc.Server) error { @@ -112,14 +113,13 @@ func (s *Server) GetUsersOnlineStatus( ps := new(msggateway.GetUsersOnlineStatusResp_SuccessDetail) ps.PlatformID = int32(client.PlatformID) - ps.Status = constant.OnlineStatus ps.ConnID = client.ctx.GetConnID() ps.Token = client.token ps.IsBackground = client.IsBackground - uresp.Status = constant.OnlineStatus + uresp.Status = constant.Online uresp.DetailPlatformStatus = append(uresp.DetailPlatformStatus, ps) } - if uresp.Status == constant.OnlineStatus { + if uresp.Status == constant.Online { resp.SuccessResult = append(resp.SuccessResult, uresp) } } diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index d870a6c58f..7834a92d7a 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -76,13 +76,24 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* if req.Secret != s.config.Share.Secret { return nil, errs.ErrNoPermission.WrapMsg("secret invalid") } + + if err := authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil { + return nil, err + } + + if req.PlatformID != constant.AdminPlatformID { + return nil, errs.ErrNoPermission.WrapMsg("platformID invalid. platformID must be adminPlatformID") + } + if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil { return nil, err } + token, err := s.authDatabase.CreateToken(ctx, req.UserID, int(req.PlatformID)) if err != nil { return nil, err } + prommetrics.UserLoginCounter.Inc() resp.Token = token resp.ExpireTimeSeconds = s.config.RpcConfig.TokenPolicy.Expire * 24 * 60 * 60 @@ -93,6 +104,11 @@ func (s *authServer) GetUserToken(ctx context.Context, req *pbauth.GetUserTokenR if err := authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil { return nil, err } + + if req.PlatformID == constant.AdminPlatformID { + return nil, errs.ErrNoPermission.WrapMsg("platformID invalid. platformID must not be adminPlatformID") + } + resp := pbauth.GetUserTokenResp{} if authverify.IsManagerUserID(req.UserID, s.config.Share.IMAdminUserID) { diff --git a/internal/rpc/group/callback.go b/internal/rpc/group/callback.go index e748c66dc5..559d64ff47 100644 --- a/internal/rpc/group/callback.go +++ b/internal/rpc/group/callback.go @@ -374,7 +374,7 @@ func (s *groupServer) webhookBeforeSetGroupInfoEx(ctx context.Context, before *c if req.Ex != nil { cbReq.Ex = req.Ex } - log.ZDebug(ctx, "debug CallbackBeforeSetGroupInfoEX", "ex", cbReq.Ex) + log.ZDebug(ctx, "debug CallbackBeforeSetGroupInfoEx", "ex", cbReq.Ex) if req.NeedVerification != nil { cbReq.NeedVerification = req.NeedVerification diff --git a/internal/rpc/user/online.go b/internal/rpc/user/online.go index 4e7823306f..0e5365ed93 100644 --- a/internal/rpc/user/online.go +++ b/internal/rpc/user/online.go @@ -2,6 +2,7 @@ package user import ( "context" + "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/protocol/constant" @@ -61,7 +62,7 @@ func (s *userServer) SetUserStatus(ctx context.Context, req *pbuser.SetUserStatu case constant.Online: online = []int32{req.PlatformID} case constant.Offline: - online = []int32{req.PlatformID} + offline = []int32{req.PlatformID} } if err := s.online.SetUserOnline(ctx, req.UserID, online, offline); err != nil { return nil, err From 90f73a18a095b6c978fd6d9c3ada40be226e1ca9 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:08:54 +0800 Subject: [PATCH 02/10] fix: usertoken auth. --- internal/rpc/auth/auth.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 7834a92d7a..745293db19 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -20,6 +20,7 @@ import ( "github.com/openimsdk/open-im-server/v3/pkg/common/config" redis2 "github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis" "github.com/openimsdk/tools/db/redisutil" + "github.com/openimsdk/tools/utils/datautil" "github.com/redis/go-redis/v9" "github.com/openimsdk/open-im-server/v3/pkg/authverify" @@ -77,19 +78,16 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* return nil, errs.ErrNoPermission.WrapMsg("secret invalid") } - if err := authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil { - return nil, err - } + if datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { + return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.") - if req.PlatformID != constant.AdminPlatformID { - return nil, errs.ErrNoPermission.WrapMsg("platformID invalid. platformID must be adminPlatformID") } if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil { return nil, err } - token, err := s.authDatabase.CreateToken(ctx, req.UserID, int(req.PlatformID)) + token, err := s.authDatabase.CreateToken(ctx, req.UserID, int(constant.AdminPlatformID)) if err != nil { return nil, err } From be75e96b15ed27863ad52f7da21b2c0612bc8f9b Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:18:36 +0800 Subject: [PATCH 03/10] update contents. --- internal/rpc/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 745293db19..19c1b1be71 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -79,7 +79,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* } if datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { - return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.") + return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.", "userID", req.UserID) } From fad89852829a40e98122983f2fc7e36ab6a22916 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:18:53 +0800 Subject: [PATCH 04/10] update content. --- internal/rpc/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 19c1b1be71..1df49de7e9 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -79,7 +79,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* } if datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { - return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.", "userID", req.UserID) + return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.", "userID", req.UserID, "adminUserID", s.config.Share.IMAdminUserID) } From 28fce5951af494075cfe1f3786cf916e8d479e71 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:20:28 +0800 Subject: [PATCH 05/10] update --- internal/rpc/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 1df49de7e9..aec22cfe52 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -79,7 +79,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* } if datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { - return nil, errs.ErrNoPermission.WrapMsg("userID is not admin permission.", "userID", req.UserID, "adminUserID", s.config.Share.IMAdminUserID) + return nil, errs.ErrArgs.WrapMsg("userID is error.", "userID", req.UserID, "adminUserID", s.config.Share.IMAdminUserID) } From 7b5df55423f94d2ea45bd0ca7ed42819842e4af9 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:22:38 +0800 Subject: [PATCH 06/10] fix --- internal/rpc/auth/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index aec22cfe52..7d33ef9282 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -78,7 +78,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (* return nil, errs.ErrNoPermission.WrapMsg("secret invalid") } - if datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { + if !datautil.Contain(req.UserID, s.config.Share.IMAdminUserID...) { return nil, errs.ErrArgs.WrapMsg("userID is error.", "userID", req.UserID, "adminUserID", s.config.Share.IMAdminUserID) } From f74636e6454c4a258ea5a2fffe8325fd7c4eada9 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 27 Sep 2024 17:42:30 +0800 Subject: [PATCH 07/10] update pb file. --- go.mod | 2 +- go.sum | 4 ++-- tools/url2im/pkg/api.go | 6 ++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 9e35bca6a9..10765aa861 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.72-alpha.36 + github.com/openimsdk/protocol v0.0.72-alpha.38 github.com/openimsdk/tools v0.0.50-alpha.15 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 diff --git a/go.sum b/go.sum index 05951b9e40..a2a0626170 100644 --- a/go.sum +++ b/go.sum @@ -319,8 +319,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y= github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.72-alpha.36 h1:j1hanJjvAgLfRZSGSdGoYkH3L0siBf5n6gFbvs2y5M0= -github.com/openimsdk/protocol v0.0.72-alpha.36/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8= +github.com/openimsdk/protocol v0.0.72-alpha.38 h1:v0GLgS9cNm627NSG3B2k2VF2AMoo90DSKixxiBMKPS4= +github.com/openimsdk/protocol v0.0.72-alpha.38/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8= github.com/openimsdk/tools v0.0.50-alpha.15 h1:HV9aKZ4vvCZCGG4wFDsgUONkkdJeCcrFNn3BT52nUVQ= github.com/openimsdk/tools v0.0.50-alpha.15/go.mod h1:h1cYmfyaVtgFbKmb1Cfsl8XwUOMTt8ubVUQrdGtsUh4= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= diff --git a/tools/url2im/pkg/api.go b/tools/url2im/pkg/api.go index 5bf48c4ea5..b769872992 100644 --- a/tools/url2im/pkg/api.go +++ b/tools/url2im/pkg/api.go @@ -23,7 +23,6 @@ import ( "net/http" "github.com/openimsdk/protocol/auth" - "github.com/openimsdk/protocol/constant" "github.com/openimsdk/protocol/third" "github.com/openimsdk/tools/errs" ) @@ -90,9 +89,8 @@ func (a *Api) apiPost(ctx context.Context, path string, req any, resp any) error func (a *Api) GetToken(ctx context.Context) (string, error) { req := auth.UserTokenReq{ - UserID: a.UserID, - Secret: a.Secret, - PlatformID: constant.AdminPlatformID, + UserID: a.UserID, + Secret: a.Secret, } var resp auth.UserTokenResp if err := a.apiPost(ctx, "/auth/user_token", &req, &resp); err != nil { From d1d70133caa7284e4bea9528ffda750635f9664d Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Sun, 29 Sep 2024 11:11:32 +0800 Subject: [PATCH 08/10] feat: add update version file on release workflows. --- .../update-version-file-on-release.yml | 84 +++++++++++++++++++ internal/rpc/auth/auth.go | 3 - 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/update-version-file-on-release.yml diff --git a/.github/workflows/update-version-file-on-release.yml b/.github/workflows/update-version-file-on-release.yml new file mode 100644 index 0000000000..f582edf486 --- /dev/null +++ b/.github/workflows/update-version-file-on-release.yml @@ -0,0 +1,84 @@ +name: Update Version File on Release + +on: + release: + types: [created] + +jobs: + update-version: + runs-on: ubuntu-latest + env: + TAG_VERSION: ${{ github.event.release.tag_name }} + steps: + # Step 1: Checkout the original repository's code + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Step 2: Set up Git with official account + - name: Set up Git + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + # Step 3: Check and delete existing tag + - name: Check and delete existing tag + run: | + if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then + git tag -d ${{ env.TAG_VERSION }} + git push --delete origin ${{ env.TAG_VERSION }} + fi + + # Step 4: Update version file + - name: Update version file + run: | + echo "${{ env.TAG_VERSION }}" > version/version + + # Step 5: Commit and push changes + - name: Commit and push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git add version/version + git commit -m "Update version to ${{ env.TAG_VERSION }}" + git push origin HEAD:${{ github.ref }} + + # Step 6: Create and push tag + - name: Create and push tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git tag ${{ env.TAG_VERSION }} + git push origin ${{ env.TAG_VERSION }} + + # Step 8: Find and Publish Draft Release + - name: Find and Publish Draft Release + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + // Get the list of releases + const releases = await github.rest.repos.listReleases({ + owner: context.repo.owner, + repo: context.repo.repo + }); + + // Find the draft release where the title and tag_name are the same + const draftRelease = releases.data.find(release => + release.draft && release.name === release.tag_name + ); + + if (draftRelease) { + // Publish the draft release using the release_id + await github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: draftRelease.id, // Use release_id + draft: false + }); + + core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); + } else { + core.info("No matching draft release found."); + } \ No newline at end of file diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index 7d33ef9282..d33bc2a1a5 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -109,9 +109,6 @@ func (s *authServer) GetUserToken(ctx context.Context, req *pbauth.GetUserTokenR resp := pbauth.GetUserTokenResp{} - if authverify.IsManagerUserID(req.UserID, s.config.Share.IMAdminUserID) { - return nil, errs.ErrNoPermission.WrapMsg("don't get Admin token") - } if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil { return nil, err } From 53331295246c45c773328ce371b813589a4ea73a Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Sun, 29 Sep 2024 11:48:17 +0800 Subject: [PATCH 09/10] comment workflows. --- .../update-version-file-on-release.yml | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/.github/workflows/update-version-file-on-release.yml b/.github/workflows/update-version-file-on-release.yml index f582edf486..9bd6e38fdc 100644 --- a/.github/workflows/update-version-file-on-release.yml +++ b/.github/workflows/update-version-file-on-release.yml @@ -1,84 +1,84 @@ -name: Update Version File on Release +# name: Update Version File on Release -on: - release: - types: [created] +# on: +# release: +# types: [created] -jobs: - update-version: - runs-on: ubuntu-latest - env: - TAG_VERSION: ${{ github.event.release.tag_name }} - steps: - # Step 1: Checkout the original repository's code - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 +# jobs: +# update-version: +# runs-on: ubuntu-latest +# env: +# TAG_VERSION: ${{ github.event.release.tag_name }} +# steps: +# # Step 1: Checkout the original repository's code +# - name: Checkout code +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 - # Step 2: Set up Git with official account - - name: Set up Git - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" +# # Step 2: Set up Git with official account +# - name: Set up Git +# run: | +# git config user.name "github-actions[bot]" +# git config user.email "github-actions[bot]@users.noreply.github.com" - # Step 3: Check and delete existing tag - - name: Check and delete existing tag - run: | - if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then - git tag -d ${{ env.TAG_VERSION }} - git push --delete origin ${{ env.TAG_VERSION }} - fi +# # Step 3: Check and delete existing tag +# - name: Check and delete existing tag +# run: | +# if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then +# git tag -d ${{ env.TAG_VERSION }} +# git push --delete origin ${{ env.TAG_VERSION }} +# fi - # Step 4: Update version file - - name: Update version file - run: | - echo "${{ env.TAG_VERSION }}" > version/version +# # Step 4: Update version file +# - name: Update version file +# run: | +# echo "${{ env.TAG_VERSION }}" > version/version - # Step 5: Commit and push changes - - name: Commit and push changes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git add version/version - git commit -m "Update version to ${{ env.TAG_VERSION }}" - git push origin HEAD:${{ github.ref }} +# # Step 5: Commit and push changes +# - name: Commit and push changes +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: | +# git add version/version +# git commit -m "Update version to ${{ env.TAG_VERSION }}" +# git push origin HEAD:${{ github.ref }} - # Step 6: Create and push tag - - name: Create and push tag - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git tag ${{ env.TAG_VERSION }} - git push origin ${{ env.TAG_VERSION }} +# # Step 6: Create and push tag +# - name: Create and push tag +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: | +# git tag ${{ env.TAG_VERSION }} +# git push origin ${{ env.TAG_VERSION }} - # Step 8: Find and Publish Draft Release - - name: Find and Publish Draft Release - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - // Get the list of releases - const releases = await github.rest.repos.listReleases({ - owner: context.repo.owner, - repo: context.repo.repo - }); +# # Step 8: Find and Publish Draft Release +# - name: Find and Publish Draft Release +# uses: actions/github-script@v6 +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# script: | +# // Get the list of releases +# const releases = await github.rest.repos.listReleases({ +# owner: context.repo.owner, +# repo: context.repo.repo +# }); - // Find the draft release where the title and tag_name are the same - const draftRelease = releases.data.find(release => - release.draft && release.name === release.tag_name - ); +# // Find the draft release where the title and tag_name are the same +# const draftRelease = releases.data.find(release => +# release.draft && release.name === release.tag_name +# ); - if (draftRelease) { - // Publish the draft release using the release_id - await github.rest.repos.updateRelease({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: draftRelease.id, // Use release_id - draft: false - }); +# if (draftRelease) { +# // Publish the draft release using the release_id +# await github.rest.repos.updateRelease({ +# owner: context.repo.owner, +# repo: context.repo.repo, +# release_id: draftRelease.id, // Use release_id +# draft: false +# }); - core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); - } else { - core.info("No matching draft release found."); - } \ No newline at end of file +# core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); +# } else { +# core.info("No matching draft release found."); +# } \ No newline at end of file From 05ea0ed2934e8bca1c76813eeaf118e1e0e4795b Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Sun, 29 Sep 2024 11:49:50 +0800 Subject: [PATCH 10/10] remove workflows. --- .../update-version-file-on-release.yml | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 .github/workflows/update-version-file-on-release.yml diff --git a/.github/workflows/update-version-file-on-release.yml b/.github/workflows/update-version-file-on-release.yml deleted file mode 100644 index 9bd6e38fdc..0000000000 --- a/.github/workflows/update-version-file-on-release.yml +++ /dev/null @@ -1,84 +0,0 @@ -# name: Update Version File on Release - -# on: -# release: -# types: [created] - -# jobs: -# update-version: -# runs-on: ubuntu-latest -# env: -# TAG_VERSION: ${{ github.event.release.tag_name }} -# steps: -# # Step 1: Checkout the original repository's code -# - name: Checkout code -# uses: actions/checkout@v4 -# with: -# fetch-depth: 0 - -# # Step 2: Set up Git with official account -# - name: Set up Git -# run: | -# git config user.name "github-actions[bot]" -# git config user.email "github-actions[bot]@users.noreply.github.com" - -# # Step 3: Check and delete existing tag -# - name: Check and delete existing tag -# run: | -# if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then -# git tag -d ${{ env.TAG_VERSION }} -# git push --delete origin ${{ env.TAG_VERSION }} -# fi - -# # Step 4: Update version file -# - name: Update version file -# run: | -# echo "${{ env.TAG_VERSION }}" > version/version - -# # Step 5: Commit and push changes -# - name: Commit and push changes -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# run: | -# git add version/version -# git commit -m "Update version to ${{ env.TAG_VERSION }}" -# git push origin HEAD:${{ github.ref }} - -# # Step 6: Create and push tag -# - name: Create and push tag -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# run: | -# git tag ${{ env.TAG_VERSION }} -# git push origin ${{ env.TAG_VERSION }} - -# # Step 8: Find and Publish Draft Release -# - name: Find and Publish Draft Release -# uses: actions/github-script@v6 -# with: -# github-token: ${{ secrets.GITHUB_TOKEN }} -# script: | -# // Get the list of releases -# const releases = await github.rest.repos.listReleases({ -# owner: context.repo.owner, -# repo: context.repo.repo -# }); - -# // Find the draft release where the title and tag_name are the same -# const draftRelease = releases.data.find(release => -# release.draft && release.name === release.tag_name -# ); - -# if (draftRelease) { -# // Publish the draft release using the release_id -# await github.rest.repos.updateRelease({ -# owner: context.repo.owner, -# repo: context.repo.repo, -# release_id: draftRelease.id, // Use release_id -# draft: false -# }); - -# core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); -# } else { -# core.info("No matching draft release found."); -# } \ No newline at end of file