You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	fix: remove disgo dependency (#4521)
closes #4520 it was easy enough to remove it :)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							0becc41508
						
					
				
				
					commit
					2ab840b675
				
			
							
								
								
									
										4
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.mod
									
									
									
									
									
								
							| @@ -20,8 +20,6 @@ require ( | ||||
| 	github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 | ||||
| 	github.com/dghubble/go-twitter v0.0.0-20211115160449-93a8679adecb | ||||
| 	github.com/dghubble/oauth1 v0.7.2 | ||||
| 	github.com/disgoorg/disgo v0.17.0 | ||||
| 	github.com/disgoorg/snowflake/v2 v2.0.1 | ||||
| 	github.com/distribution/distribution/v3 v3.0.0-20221021092657-c47a966fded8 | ||||
| 	github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible | ||||
| 	github.com/google/go-containerregistry v0.17.0 | ||||
| @@ -142,7 +140,6 @@ require ( | ||||
| 	github.com/davidmz/go-pageant v1.0.2 // indirect | ||||
| 	github.com/dghubble/sling v1.4.0 // indirect | ||||
| 	github.com/dimchansky/utfbom v1.1.1 // indirect | ||||
| 	github.com/disgoorg/json v1.1.0 // indirect | ||||
| 	github.com/docker/cli v24.0.7+incompatible // indirect | ||||
| 	github.com/docker/distribution v2.8.3+incompatible // indirect | ||||
| 	github.com/docker/docker v24.0.7+incompatible // indirect | ||||
| @@ -227,7 +224,6 @@ require ( | ||||
| 	github.com/prometheus/procfs v0.12.0 // indirect | ||||
| 	github.com/rivo/uniseg v0.4.2 // indirect | ||||
| 	github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||||
| 	github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b // indirect | ||||
| 	github.com/sergi/go-diff v1.2.0 // indirect | ||||
| 	github.com/shopspring/decimal v1.2.0 // indirect | ||||
| 	github.com/sigstore/cosign/v2 v2.2.1 // indirect | ||||
|   | ||||
							
								
								
									
										8
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								go.sum
									
									
									
									
									
								
							| @@ -278,12 +278,6 @@ github.com/dghubble/sling v1.4.0 h1:/n8MRosVTthvMbwlNZgLx579OGVjUOy3GNEv5BIqAWY= | ||||
| github.com/dghubble/sling v1.4.0/go.mod h1:0r40aNsU9EdDUVBNhfCstAtFgutjgJGYbO1oNzkMoM8= | ||||
| github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U= | ||||
| github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= | ||||
| github.com/disgoorg/disgo v0.17.0 h1:/LcgXgPDhzHt3GkQ4cpjmIJBim1/VYfS31VhGYif3Ms= | ||||
| github.com/disgoorg/disgo v0.17.0/go.mod h1:AE2J/8oLR2PtYfqcARsk1mgBxQ5z3Z1OD6Lc2SA0gak= | ||||
| github.com/disgoorg/json v1.1.0 h1:7xigHvomlVA9PQw9bMGO02PHGJJPqvX5AnwlYg/Tnys= | ||||
| github.com/disgoorg/json v1.1.0/go.mod h1:BHDwdde0rpQFDVsRLKhma6Y7fTbQKub/zdGO5O9NqqA= | ||||
| github.com/disgoorg/snowflake/v2 v2.0.1 h1:CuUxGLwggUxEswZOmZ+mZ5i0xSumQdXW9tXW7uGqe+0= | ||||
| github.com/disgoorg/snowflake/v2 v2.0.1/go.mod h1:SPU9c2CNn5DSyb86QcKtdZgix9osEtKrHLW4rMhfLCs= | ||||
| github.com/distribution/distribution/v3 v3.0.0-20221021092657-c47a966fded8 h1:zuxvqNfQKyGNH3a1yFh1ofD4Y7ycgdwQhHX6QRH+Cwo= | ||||
| github.com/distribution/distribution/v3 v3.0.0-20221021092657-c47a966fded8/go.mod h1:6rIc5NMSjXjjnwzWWy3HAm9gDBu+X7aCzL8VrHIKgxM= | ||||
| github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= | ||||
| @@ -759,8 +753,6 @@ github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9c | ||||
| github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= | ||||
| github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= | ||||
| github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= | ||||
| github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b h1:qYTY2tN72LhgDj2rtWG+LI6TXFl2ygFQQ4YezfVaGQE= | ||||
| github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b/go.mod h1:/pA7k3zsXKdjjAiUhB5CjuKib9KJGCaLvZwtxGC8U0s= | ||||
| github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= | ||||
| github.com/secure-systems-lab/go-securesystemslib v0.7.0 h1:OwvJ5jQf9LnIAS83waAjPbcMsODrTQUpJ02eNLUoxBg= | ||||
| github.com/secure-systems-lab/go-securesystemslib v0.7.0/go.mod h1:/2gYnlnHVQ6xeGtfIqFy7Do03K4cdCY0A/GlJLDKLHI= | ||||
|   | ||||
| @@ -1,14 +1,15 @@ | ||||
| package discord | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/caarlos0/env/v9" | ||||
| 	"github.com/caarlos0/log" | ||||
| 	"github.com/disgoorg/disgo/discord" | ||||
| 	"github.com/disgoorg/disgo/webhook" | ||||
| 	"github.com/disgoorg/snowflake/v2" | ||||
| 	"github.com/goreleaser/goreleaser/internal/tmpl" | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| ) | ||||
| @@ -59,19 +60,21 @@ func (p Pipe) Announce(ctx *context.Context) error { | ||||
|  | ||||
| 	log.Infof("posting: '%s'", msg) | ||||
|  | ||||
| 	webhookID, err := snowflake.Parse(cfg.WebhookID) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("discord: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	color, err := strconv.Atoi(ctx.Config.Announce.Discord.Color) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("discord: %w", err) | ||||
| 	} | ||||
| 	if _, err = webhook.New(webhookID, cfg.WebhookToken).CreateMessage(discord.WebhookMessageCreate{ | ||||
| 		Embeds: []discord.Embed{ | ||||
|  | ||||
| 	u, err := url.Parse("https://discord.com/api") | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("discord: %w", err) | ||||
| 	} | ||||
| 	u = u.JoinPath("webhooks", cfg.WebhookID, cfg.WebhookToken) | ||||
|  | ||||
| 	bts, err := json.Marshal(WebhookMessageCreate{ | ||||
| 		Embeds: []Embed{ | ||||
| 			{ | ||||
| 				Author: &discord.EmbedAuthor{ | ||||
| 				Author: &EmbedAuthor{ | ||||
| 					Name:    ctx.Config.Announce.Discord.Author, | ||||
| 					IconURL: ctx.Config.Announce.Discord.IconURL, | ||||
| 				}, | ||||
| @@ -79,8 +82,34 @@ func (p Pipe) Announce(ctx *context.Context) error { | ||||
| 				Color:       color, | ||||
| 			}, | ||||
| 		}, | ||||
| 	}); err != nil { | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("discord: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	resp, err := http.Post(u.String(), "application/json", bytes.NewReader(bts)) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("discord: %w", err) | ||||
| 	} | ||||
|  | ||||
| 	if resp.StatusCode != 204 && resp.StatusCode != 200 { | ||||
| 		return fmt.Errorf("discord: %s", resp.Status) | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| type WebhookMessageCreate struct { | ||||
| 	Embeds []Embed `json:"embeds,omitempty"` | ||||
| } | ||||
|  | ||||
| type Embed struct { | ||||
| 	Description string       `json:"description,omitempty"` | ||||
| 	Color       int          `json:"color,omitempty"` | ||||
| 	Author      *EmbedAuthor `json:"author,omitempty"` | ||||
| } | ||||
|  | ||||
| type EmbedAuthor struct { | ||||
| 	Name    string `json:"name,omitempty"` | ||||
| 	IconURL string `json:"icon_url,omitempty"` | ||||
| } | ||||
|   | ||||
| @@ -56,3 +56,21 @@ func TestSkip(t *testing.T) { | ||||
| 		require.False(t, Pipe{}.Skip(ctx)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func TestLive(t *testing.T) { | ||||
| 	t.SkipNow() | ||||
| 	t.Setenv("DISCORD_WEBHOOK_ID", "TODO") | ||||
| 	t.Setenv("DISCORD_WEBHOOK_TOKEN", "TODO") | ||||
|  | ||||
| 	ctx := testctx.NewWithCfg(config.Project{ | ||||
| 		Announce: config.Announce{ | ||||
| 			Discord: config.Discord{ | ||||
| 				MessageTemplate: "test", | ||||
| 				Enabled:         true, | ||||
| 			}, | ||||
| 		}, | ||||
| 	}) | ||||
|  | ||||
| 	require.NoError(t, Pipe{}.Default(ctx)) | ||||
| 	require.NoError(t, Pipe{}.Announce(ctx)) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user