1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-09 13:36:56 +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:
Carlos Alexandro Becker 2023-12-21 14:21:20 -03:00 committed by GitHub
parent c4dafdf55e
commit 2b9e471370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 141 additions and 3 deletions

View File

@ -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{

View File

@ -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)
}
}
}

View 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"
];
};
}

View 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"
];
};
}