You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	fix(nix): include unzip if any artifact is a zip (#4495)
Instead of just the first one. refs #4224
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							c4dafdf55e
						
					
				
				
					commit
					2b9e471370
				
			| @@ -258,9 +258,12 @@ func preparePkg( | ||||
| 	if len(dependencies) > 0 { | ||||
| 		inputs = append(inputs, "makeWrapper") | ||||
| 	} | ||||
| 	if archives[0].Format() == "zip" { | ||||
| 		inputs = append(inputs, "unzip") | ||||
| 		dependencies = append(dependencies, "unzip") | ||||
| 	for _, arch := range archives { | ||||
| 		if arch.Format() == "zip" { | ||||
| 			inputs = append(inputs, "unzip") | ||||
| 			dependencies = append(dependencies, "unzip") | ||||
| 			break | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	data := templateData{ | ||||
|   | ||||
| @@ -205,6 +205,20 @@ func TestRunPipe(t *testing.T) { | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name: "zip-and-tar", | ||||
| 			nix: config.Nix{ | ||||
| 				Name:        "foozip", | ||||
| 				IDs:         []string{"zip-and-tar"}, | ||||
| 				Description: "my test", | ||||
| 				Homepage:    "https://goreleaser.com", | ||||
| 				License:     "mit", | ||||
| 				Repository: config.RepoRef{ | ||||
| 					Owner: "foo", | ||||
| 					Name:  "bar", | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			name:             "unibin", | ||||
| 			expectRunErrorIs: ErrMultipleArchivesSamePlatform, | ||||
| @@ -483,6 +497,11 @@ func TestRunPipe(t *testing.T) { | ||||
| 					} | ||||
| 					createFakeArtifact("wrapped-in-dir", goos, goarch, "", "", "tar.gz", map[string]any{artifact.ExtraWrappedIn: "./foo"}) | ||||
| 					createFakeArtifact("foo-zip", goos, goarch, "v1", "", "zip", nil) | ||||
| 					if goos == "darwin" { | ||||
| 						createFakeArtifact("zip-and-tar", goos, goarch, "v1", "", "zip", nil) | ||||
| 					} else { | ||||
| 						createFakeArtifact("zip-and-tar", goos, goarch, "v1", "", "tar.gz", nil) | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|   | ||||
							
								
								
									
										58
									
								
								internal/pipe/nix/testdata/TestRunPipe/zip-and-tar_build.nix.golden
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								internal/pipe/nix/testdata/TestRunPipe/zip-and-tar_build.nix.golden
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| # This file was generated by GoReleaser. DO NOT EDIT. | ||||
| # vim: set ft=nix ts=2 sw=2 sts=2 et sta | ||||
| { | ||||
| system ? builtins.currentSystem | ||||
| , pkgs | ||||
| , lib | ||||
| , fetchurl | ||||
| , installShellFiles | ||||
| , makeWrapper | ||||
| , stdenv | ||||
| , unzip | ||||
| }: | ||||
| let | ||||
|   shaMap = { | ||||
|     i686-linux = "0000000000000000000000000000000000000000000000000000"; | ||||
|     aarch64-linux = "0000000000000000000000000000000000000000000000000000"; | ||||
|     aarch64-darwin = "0000000000000000000000000000000000000000000000000000"; | ||||
|   }; | ||||
|  | ||||
|   urlMap = { | ||||
|     i686-linux = "https://dummyhost/download/v1.2.1/foo_linux_386.tar.gz"; | ||||
|     aarch64-linux = "https://dummyhost/download/v1.2.1/foo_linux_arm64.tar.gz"; | ||||
|     aarch64-darwin = "https://dummyhost/download/v1.2.1/foo_darwin_arm64.zip"; | ||||
|   }; | ||||
| in | ||||
| pkgs.stdenv.mkDerivation { | ||||
|   pname = "foozip"; | ||||
|   version = "1.2.1"; | ||||
|   src = fetchurl { | ||||
|     url = urlMap.${system}; | ||||
|     sha256 = shaMap.${system}; | ||||
|   }; | ||||
|  | ||||
|   sourceRoot = "."; | ||||
|  | ||||
|   nativeBuildInputs = [ installShellFiles unzip ]; | ||||
|  | ||||
|   installPhase = '' | ||||
|     mkdir -p $out/bin | ||||
|     cp -vr ./foo $out/bin/foo | ||||
|   ''; | ||||
|  | ||||
|   system = system; | ||||
|  | ||||
|   meta = { | ||||
|     description = "my test"; | ||||
|     homepage = "https://goreleaser.com"; | ||||
|     license = lib.licenses.mit; | ||||
|  | ||||
|     sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; | ||||
|  | ||||
|     platforms = [ | ||||
|       "aarch64-darwin" | ||||
|       "aarch64-linux" | ||||
|       "i686-linux" | ||||
|     ]; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										58
									
								
								internal/pipe/nix/testdata/TestRunPipe/zip-and-tar_publish.nix.golden
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								internal/pipe/nix/testdata/TestRunPipe/zip-and-tar_publish.nix.golden
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| # This file was generated by GoReleaser. DO NOT EDIT. | ||||
| # vim: set ft=nix ts=2 sw=2 sts=2 et sta | ||||
| { | ||||
| system ? builtins.currentSystem | ||||
| , pkgs | ||||
| , lib | ||||
| , fetchurl | ||||
| , installShellFiles | ||||
| , makeWrapper | ||||
| , stdenv | ||||
| , unzip | ||||
| }: | ||||
| let | ||||
|   shaMap = { | ||||
|     i686-linux = "sha16"; | ||||
|     aarch64-linux = "sha2"; | ||||
|     aarch64-darwin = "sha11"; | ||||
|   }; | ||||
|  | ||||
|   urlMap = { | ||||
|     i686-linux = "https://dummyhost/download/v1.2.1/foo_linux_386.tar.gz"; | ||||
|     aarch64-linux = "https://dummyhost/download/v1.2.1/foo_linux_arm64.tar.gz"; | ||||
|     aarch64-darwin = "https://dummyhost/download/v1.2.1/foo_darwin_arm64.zip"; | ||||
|   }; | ||||
| in | ||||
| pkgs.stdenv.mkDerivation { | ||||
|   pname = "foozip"; | ||||
|   version = "1.2.1"; | ||||
|   src = fetchurl { | ||||
|     url = urlMap.${system}; | ||||
|     sha256 = shaMap.${system}; | ||||
|   }; | ||||
|  | ||||
|   sourceRoot = "."; | ||||
|  | ||||
|   nativeBuildInputs = [ installShellFiles unzip ]; | ||||
|  | ||||
|   installPhase = '' | ||||
|     mkdir -p $out/bin | ||||
|     cp -vr ./foo $out/bin/foo | ||||
|   ''; | ||||
|  | ||||
|   system = system; | ||||
|  | ||||
|   meta = { | ||||
|     description = "my test"; | ||||
|     homepage = "https://goreleaser.com"; | ||||
|     license = lib.licenses.mit; | ||||
|  | ||||
|     sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; | ||||
|  | ||||
|     platforms = [ | ||||
|       "aarch64-darwin" | ||||
|       "aarch64-linux" | ||||
|       "i686-linux" | ||||
|     ]; | ||||
|   }; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user