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

Optionally run go mod vendor for source archives? #2911

Closed
2 tasks done
francislavoie opened this issue Feb 15, 2022 · 19 comments · Fixed by #3102
Closed
2 tasks done

Optionally run go mod vendor for source archives? #2911

francislavoie opened this issue Feb 15, 2022 · 19 comments · Fixed by #3102
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@francislavoie
Copy link

francislavoie commented Feb 15, 2022

Is your feature request related to a problem? Please describe.

We were asked on the Caddy project caddyserver/caddy#4573 to provide a source bundle including vendored dependencies, so that builds can be produced without additional downloads.

Describe the solution you'd like

An optional flag like vendor: true in https://goreleaser.com/customization/source/ would be great. It should run go mod vendor to produce the vendor/ dir in the project before zipping up the source.

Describe alternatives you've considered

It would let us avoid having to write some custom shell script after the release to produce the extra tarball.

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

@francislavoie francislavoie added enhancement New feature or request triage Issue pending triage by one of the maintainers labels Feb 15, 2022
@caarlos0
Copy link
Member

not sure if its possible... we use git archive to create the source archive... so, if vendor is gitignored, it won't get picked - AFAIK

not sure if there's a way around this...

@francislavoie
Copy link
Author

Hmm. We could remove vendor/ from .gitignore on the Caddy repo, I don't think there's any reason for it to be there. But we definitely don't want to commit the vendor to the repo anymore (we did for Caddy v1 and it was a total mess).

https://stackoverflow.com/a/54036395/846934 suggests maybe we can just throw vendor in afterwards?

@caarlos0
Copy link
Member

That's assuming tar, but it could be a myriad of formats.

You could, in theory, remove vendor from the gitignore, and run go mod vendor in a global before hook.

The vendor folder will be used to build - which shouldn't be a big deal, and will also be included in the source archive

@mohammed90
Copy link
Contributor

The git archive command only packs tracked and committed files. So unignoring the vendor directory won't help, neither will running go mod vendor to create the directory. It can pack extra/untracked files with the flag --add-file, but that'll need to be repeated for as many files in the vendor dir.

@caarlos0
Copy link
Member

The git archive command only packs tracked and committed files. So unignoring the vendor directory won't help, neither will running go mod vendor to create the directory. It can pack extra/untracked files with the flag --add-file, but that'll need to be repeated for as many files in the vendor dir.

ah, indeed

@caarlos0
Copy link
Member

then, if we do this, we might need to implement the archiving ourselves instead of relying on git-archive...

@mohammed90
Copy link
Contributor

then, if we do this, we might need to implement the archiving ourselves instead of relying on git-archive...

I think you could still piggy back on git archive by performing subsequent operations to append/remove file/dirs using github.com/mholt/archiver/v4, no?

@caarlos0
Copy link
Member

seems to be in alpha, and at least on readme there is no example on how to add files with specific permissions, correct?

I need to test, but maybe our internal archiving library already works :P

@caarlos0
Copy link
Member

I need to test, but maybe our internal archiving library already works :P

I did test, it did not work

@caarlos0
Copy link
Member

I think the easiest way would probably be to do the whole git-archive thing on goreleaser itself (using git ls-files et al).

Will try to work on this for next release.

@caarlos0 caarlos0 added this to the v1.9.0 milestone Apr 22, 2022
@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Apr 22, 2022
caarlos0 added a commit that referenced this issue May 12, 2022
would be used in #2911

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
caarlos0 added a commit that referenced this issue May 12, 2022
* refactor: evaluate archive files in another package

would be used in #2911

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

* test: fixes

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 modified the milestones: v1.9.0, v1.10.0 Jun 23, 2022
@caarlos0 caarlos0 modified the milestones: v1.10.0, 1.12.0 Jul 4, 2022
@caarlos0
Copy link
Member

caarlos0 commented Aug 25, 2022

impl it with --add-file, check #3102

caarlos0 added a commit that referenced this issue Aug 25, 2022
closes #2911

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
caarlos0 added a commit that referenced this issue Aug 25, 2022
refs #3102 #2911

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
caarlos0 added a commit that referenced this issue Aug 25, 2022
`--add-file` adds only the `--prefix` joined with the basename of the added file, so, adding a folder like `vendor` would break havoc.

this basically writes our own source archives (which are more compressed) and allows to add an entire folder easily, as well as other mappings as `archives` already supports. 

refs #3102 #2911

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

Sweet, thanks!

Just so I understand, should we use --add-file vendor or should we use --add-file vendor/*?

@caarlos0
Copy link
Member

Has to do it the first way I was thinking of doing, check #3343

@francislavoie
Copy link
Author

Sorry I'm not sure I follow. Do you mean "yes, use --add-file vendor"?

@mohammed90
Copy link
Contributor

Sorry I'm not sure I follow. Do you mean "yes, use --add-file vendor"?

The flag is a git archive flag. We'll have to add files: the config the .goreleaser.yml

@caarlos0
Copy link
Member

correct @mohammed90 , the docs are already up to date (but the version with this is not released yet)

@francislavoie
Copy link
Author

My question was more about whether we should use vendor or vendor/*, I realize we'll be using yaml to configure. But either way, we'll test it out soon. Thanks!

@caarlos0
Copy link
Member

ah, I believe just vendor is enough, but its worth testing first...

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants