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

nfpms overrides and replacements deprecation #3792

Closed
3 tasks done
evanelias opened this issue Feb 21, 2023 · 6 comments · Fixed by #3793
Closed
3 tasks done

nfpms overrides and replacements deprecation #3792

evanelias opened this issue Feb 21, 2023 · 6 comments · Fixed by #3793
Assignees
Labels
bug Something isn't working
Milestone

Comments

@evanelias
Copy link

evanelias commented Feb 21, 2023

What happened?

nfpms.replacements was deprecated in #3589, and the deprecation warning does indeed work properly if you use nfpms.replacements directly. However, the deprecation warning isn't generated if format-specific overrides use the replacements field.

For example, using nfpms.overrides.rpm.replacements doesn't seem to trigger the deprecation warning. But I assume this usage is still deprecated.

On a related topic, is there any non-deprecated way to achieve this functionality? For example, if I want to replace "arm64" with "aarch64" only on rpm and apk, but not deb, is there any way to do this in file_name_template? I couldn't find a template variable that reflects the format or extension for nfpm use-cases.

I understand that the preferred approach now is to use .ConventionalFileName, and that makes sense for new projects. But for an existing project, changing to this will result in different file names than were used previously, which is non-ideal (it will break downstream users whose automation assumes the name format isn't changing)

How can we reproduce this?

This is just a partial snippet to demonstrate the problem (no deprecation warning is generated)

nfpms:
  -
    overrides:
      rpm:
        replacements:
          arm64: aarch64
      apk:
        replacements:
          arm64: aarch64

goreleaser version

$ goreleaser --version
goreleaser version 1.15.2
commit: 90531fc87975e9b7e1dda5f7a108ae2a8064b0f2
built at: 2023-02-07T18:12:36Z
built by: goreleaser
goos: darwin
goarch: amd64
module version: v1.15.2, checksum: h1:VYCFKTzzZFnFfSqfjvOmT8ip7VcZv1Y9JV13hAuDDB8=

https://goreleaser.com

GoReleaser Check

  • goreleaser check shows no errors

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

Thank you for creating GoReleaser and nFPM, it's wonderful software!

@evanelias evanelias added bug Something isn't working triage Issue pending triage by one of the maintainers labels Feb 21, 2023
@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Feb 22, 2023
@caarlos0
Copy link
Member

ah, nice catch!

caarlos0 added a commit that referenced this issue Feb 22, 2023
closes  #3792

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
@evanelias
Copy link
Author

Thank you for the fast response!

Is there any non-deprecated way to achieve this same functionality though? I didn't see any template variables that could be used in nfpms.file_name_template to do conditional logic on deb vs rpm vs apk.

@caarlos0
Copy link
Member

it should work the same as with the archives name templates... are you getting an error? if so, please share the config + output and I'll have a look :)

@caarlos0 caarlos0 added this to the v1.16.0 milestone Feb 22, 2023
@evanelias
Copy link
Author

No error, I just can't find a variable that represents the format ("rpm" vs "deb" vs "apk") in order to do conditional logic in the template for use in nfmps.file_name_template... how do you duplicate the behavior that nfpms.overrides.rpm.replacements used to provide?

For example, if I want to replace "arm64" with "aarch64" only on rpm and apk, but not deb, how do you do this in nfmps.file_name_template?

I attempted something like {{- if eq .ArtifactExt "deb" }}arm64{{ else }}aarch64{{ end }}, but it does not work, since {{ .ArtifactExt }} is an empty string in nfpms:

file_name_template: >-
      {{- .ProjectName }}-
      {{- .Version}}.
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "arm64" }}
        {{- if eq .ArtifactExt "deb" }}arm64{{ else }}aarch64{{ end }}
      {{- end }}

Thanks for the assistance, much appreciated!

@evanelias
Copy link
Author

On second thought -- after tweaking some of my automation pipeline, I was able to successfully switch to {{ .ConventionalFileName }} without breaking third party integrations, and that's cleaner anyway, so no worries!

Not sure if anyone else out there was relying on nfpms.overrides.[format].replacements to do funky naming logic, maybe this is a non-issue anyway :)

@caarlos0
Copy link
Member

yeah, conventional file name is clearer, you're right though, there should be a variable for that.

will add another issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants