You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	feat: store which action is being taken in the context (#4508)
refs #4504 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							48f036b5d6
						
					
				
				
					commit
					12469c4251
				
			| @@ -167,6 +167,7 @@ func setupPipeline(ctx *context.Context, options buildOpts) []pipeline.Piper { | ||||
| } | ||||
|  | ||||
| func setupBuildContext(ctx *context.Context, options buildOpts) error { | ||||
| 	ctx.Action = context.ActionBuild | ||||
| 	ctx.Deprecated = options.deprecated // test only | ||||
| 	ctx.Parallelism = runtime.GOMAXPROCS(0) | ||||
| 	if options.parallelism > 0 { | ||||
|   | ||||
| @@ -137,6 +137,11 @@ func TestBuildFlags(t *testing.T) { | ||||
| 		return ctx | ||||
| 	} | ||||
|  | ||||
| 	t.Run("action", func(t *testing.T) { | ||||
| 		ctx := setup(buildOpts{}) | ||||
| 		require.Equal(t, context.ActionBuild, ctx.Action) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("snapshot", func(t *testing.T) { | ||||
| 		ctx := setup(buildOpts{ | ||||
| 			snapshot: true, | ||||
|   | ||||
| @@ -171,6 +171,7 @@ func releaseProject(options releaseOpts) (*context.Context, error) { | ||||
| } | ||||
|  | ||||
| func setupReleaseContext(ctx *context.Context, options releaseOpts) error { | ||||
| 	ctx.Action = context.ActionRelease | ||||
| 	ctx.Deprecated = options.deprecated // test only | ||||
| 	ctx.Parallelism = runtime.GOMAXPROCS(0) | ||||
| 	if options.parallelism > 0 { | ||||
|   | ||||
| @@ -62,6 +62,11 @@ func TestReleaseFlags(t *testing.T) { | ||||
| 		return ctx | ||||
| 	} | ||||
|  | ||||
| 	t.Run("action", func(t *testing.T) { | ||||
| 		ctx := setup(t, releaseOpts{}) | ||||
| 		require.Equal(t, context.ActionRelease, ctx.Action) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("snapshot", func(t *testing.T) { | ||||
| 		ctx := setup(t, releaseOpts{ | ||||
| 			snapshot: true, | ||||
|   | ||||
| @@ -69,9 +69,18 @@ const ( | ||||
| 	TokenTypeGitea TokenType = "gitea" | ||||
| ) | ||||
|  | ||||
| type Action uint8 | ||||
|  | ||||
| const ( | ||||
| 	ActionNone Action = iota | ||||
| 	ActionBuild | ||||
| 	ActionRelease | ||||
| ) | ||||
|  | ||||
| // Context carries along some data through the pipes. | ||||
| type Context struct { | ||||
| 	stdctx.Context | ||||
| 	Action            Action | ||||
| 	Config            config.Project | ||||
| 	Env               Env | ||||
| 	Token             string | ||||
|   | ||||
		Reference in New Issue
	
	Block a user