Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nfpm for ios #3436

Merged
merged 3 commits into from Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions internal/pipe/nfpm/nfpm.go
Expand Up @@ -82,7 +82,10 @@ func (Pipe) Run(ctx *context.Context) error {
func doRun(ctx *context.Context, fpm config.NFPM) error {
filters := []artifact.Filter{
artifact.ByType(artifact.Binary),
artifact.ByGoos("linux"),
artifact.Or(
artifact.ByGoos("linux"),
artifact.ByGoos("ios"),
),
}
if len(fpm.Builds) > 0 {
filters = append(filters, artifact.ByIDs(fpm.Builds...))
Expand Down Expand Up @@ -136,6 +139,10 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar
// TODO: improve mips handling on nfpm
infoArch := binaries[0].Goarch + binaries[0].Goarm + binaries[0].Gomips // key used for the ConventionalFileName et al
arch := infoArch + binaries[0].Goamd64 // unique arch key
infoPlatform := binaries[0].Goos
if infoPlatform == "ios" {
infoPlatform = "iphoneos-arm64"
}

bindDir := fpm.Bindir
if format == termuxFormat {
Expand Down Expand Up @@ -266,7 +273,7 @@ func create(ctx *context.Context, fpm config.NFPM, format string, binaries []*ar

info := &nfpm.Info{
Arch: infoArch,
Platform: "linux",
Platform: infoPlatform,
Name: fpm.PackageName,
Version: ctx.Version,
Section: fpm.Section,
Expand Down
13 changes: 10 additions & 3 deletions internal/pipe/nfpm/nfpm_test.go
Expand Up @@ -159,8 +159,11 @@ func TestRunPipe(t *testing.T) {
})
ctx.Version = "1.0.0"
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
for _, goos := range []string{"linux", "darwin"} {
for _, goos := range []string{"linux", "darwin", "ios"} {
for _, goarch := range []string{"amd64", "386", "arm64", "arm", "mips"} {
if goos == "ios" && goarch != "arm64" {
continue
}
switch goarch {
case "arm":
for _, goarm := range []string{"6", "7"} {
Expand Down Expand Up @@ -220,7 +223,7 @@ func TestRunPipe(t *testing.T) {
}
require.NoError(t, Pipe{}.Run(ctx))
packages := ctx.Artifacts.Filter(artifact.ByType(artifact.LinuxPackage)).List()
require.Len(t, packages, 36)
require.Len(t, packages, 40)
for _, pkg := range packages {
format := pkg.Format()
require.NotEmpty(t, format)
Expand All @@ -234,7 +237,11 @@ func TestRunPipe(t *testing.T) {
if pkg.Gomips != "" {
arch += "_" + pkg.Gomips
}
require.Equal(t, "foo_1.0.0_Tux_"+arch+"-10-20."+format, pkg.Name)
if pkg.Goos == "linux" {
require.Equal(t, "foo_1.0.0_Tux_"+arch+"-10-20."+format, pkg.Name)
} else {
require.Equal(t, "foo_1.0.0_ios_arm64-10-20."+format, pkg.Name)
}
require.Equal(t, "someid", pkg.ID())
require.ElementsMatch(t, []string{
"./testdata/testfile.txt",
Expand Down