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

different behavior for extra file trees included in archives and nfpms. #3655

Closed
3 tasks done
ioga opened this issue Dec 21, 2022 · 1 comment · Fixed by #3656
Closed
3 tasks done

different behavior for extra file trees included in archives and nfpms. #3655

ioga opened this issue Dec 21, 2022 · 1 comment · Fixed by #3656
Assignees
Labels
bug Something isn't working

Comments

@ioga
Copy link

ioga commented Dec 21, 2022

What happened?

  1. archives config works differently from npmfs when including subtrees.
  2. there's no way to replicate the same behavior.

This was also discussed on discord: https://discord.com/channels/890434333251362866/1035159881210146916/threads/1054929081990381588

How can we reproduce this?

Let's say we have a file structure:

build/webui/react/robots.txt
build/webui/docs/index.html
build/webui/docs/deploy/index.html
build/webui/docs/deploy/deploy.html
...

Case 1: I'd like to include it as is, stripping the build/ prefix, i.e. include:

webui/react/robots.txt
webui/docs/index.html
webui/docs/deploy/index.html
webui/docs/deploy/deploy.html
...

With npmfs I can do:

npmfs:
    contents:
      - src: "build/**/*"

When I try the same with archives:

  • - "build/webui/**/*" will output build/webui/react/robots.txt
  • adding - dst: webui will output webui/build/webui/react/robots.txt
  • using strip_parent option with dst will output flattened webui/robots.txt, webui/index.html, webui/deploy.html (and incidentally cause a filename collision with index.html in this example)

i.e. archives behaves differently, and there's no way to do what npmfs can do.

Case 2: If I want to strip build/ prefix and include these files under a different path /usr/share/derp, e.g.

/usr/share/derp/webui/react/robots.txt
/usr/share/derp/webui/docs/index.html
/usr/share/derp/webui/docs/deploy/index.html
...

with npmfs I can do:

npmfs:
    contents:
      - src: "build/**/*"
         dst: "/usr/share/derp"

Similarly to case 1, I could not find any way to do that.

goreleaser version

Tried this both on 1.1.0 and 1.13.1

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

No response

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

is #3656 what you are looking for?

caarlos0 added a commit that referenced this issue Dec 27, 2022
with this patch, a config like:

```yaml
archives:
  - format: tar.gz
    # this name template makes the OS and Arch compatible with the results of uname.
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}
    rlcp: true
    files:
      - src: "build/**/*"
        dst: .

nfpms:
  - package_name: foo
    contents:
      - src: "build/**/*"
        dst: usr/share/foo
    formats:
      - apk

```

will eval this:

<img width="1384" alt="CleanShot 2022-12-21 at 22 21 00@2x"
src="https://user-images.githubusercontent.com/245435/209034244-7c31b5f7-cfcd-4825-bb2f-7dd463c5286a.png">

as much as I would like to make this the default, it would be a breaking
change, so we really can't do it.

If `dst` is empty, it'll have the same behavior as before (no rlcp), and
if `strip_parent` is set, it will also still have the same behavior.
Finally, if the format is binary, `rlcp` is ignored too (as it doesn't
make sense).

So, this only changes if:
- your format is not binary; and
- you have files with `src` and `dst` set

Then, goreleaser will warn you to set `rlcp: true`.

## todo

- [x] docs
- [x] more tests probably
- [x] any ideas for a better name for the new config option?

fixes #3655

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
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