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

Archives arbitrary project files without binaries #3085

Closed
2 tasks done
56KBs opened this issue May 6, 2022 · 8 comments · Fixed by #3093
Closed
2 tasks done

Archives arbitrary project files without binaries #3085

56KBs opened this issue May 6, 2022 · 8 comments · Fixed by #3093
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@56KBs
Copy link
Contributor

56KBs commented May 6, 2022

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

We'd like to be able to publish the terraform module to our GitLab terraform registry for our Go project as part of GoReleaser. This requires archiving our terraform module directory and uploading it to GitLab.

Describe the solution you'd like

I'd like to be able to create an archive from arbitrary files within the repository, without requiring a binary to be bundled with the archive. For example:

archives:
  -
    id: terraform
    name_template: "{{ .ProjectName }}_{{ .Version }}_terraform"
    files:
      - terraform/*

Describe alternatives you've considered

I've considered using a custom publisher which contains a script to archive + push to the terraform registry however this would become quite cumbersome to use as it'd require copying the script across numerous repositories with the same code.

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

@56KBs 56KBs added enhancement New feature or request triage Issue pending triage by one of the maintainers labels May 6, 2022
@56KBs 56KBs changed the title Create Archives without build binaries Create Archives without built binaries May 6, 2022
@56KBs 56KBs changed the title Create Archives without built binaries Archives arbitrary project files without binaries May 6, 2022
@caarlos0
Copy link
Member

caarlos0 commented May 8, 2022

this seems like a good idea...

what do you think the API should look like?

@56KBs
Copy link
Contributor Author

56KBs commented May 9, 2022

this seems like a good idea...

what do you think the API should look like?

Is it possible to make it so that the existing archive configuration can allow for an empty builds: list so you end up with something like:

archives:
  -
    id: terraform
    builds: 
    name_template: "{{ .ProjectName }}_{{ .Version }}_terraform"
    files:
      - terraform/*
    allow_different_binary_count: true

I'm not sure if that'd cause any issues for existing users, but it seems like logical configuration to create an archive, without any builds within it.

@caarlos0
Copy link
Member

caarlos0 commented May 9, 2022

it is not, when empty it defaults to all builds

it might work with builds: ['this id does not exist'], not sure

@56KBs
Copy link
Contributor Author

56KBs commented May 9, 2022

Sadly it doesn't work as at least one artifact is required in order for the archives to be generated:

for i, archive := range ctx.Config.Archives {
archive := archive
filter := []artifact.Filter{artifact.Or(
artifact.ByType(artifact.Binary),
artifact.ByType(artifact.UniversalBinary),
)}
if len(archive.Builds) > 0 {
filter = append(filter, artifact.ByIDs(archive.Builds...))
}
artifacts := ctx.Artifacts.Filter(artifact.And(filter...)).GroupByPlatform()
if err := checkArtifacts(artifacts); err != nil && !archive.AllowDifferentBinaryCount {
return fmt.Errorf("invalid archive: %d: %w", i, ErrArchiveDifferentBinaryCount)
}
for group, artifacts := range artifacts {
log.Debugf("group %s has %d binaries", group, len(artifacts))
artifacts := artifacts
g.Go(func() error {
if packageFormat(archive, artifacts[0].Goos) == "binary" {
return skip(ctx, archive, artifacts)
}
return create(ctx, archive, artifacts)
})
}
}

@caarlos0
Copy link
Member

caarlos0 commented May 9, 2022

ah, so maybe we can add an option like meta: true, similar to what we have in nfpm

@caarlos0 caarlos0 added this to the v1.9.0 milestone May 10, 2022
@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label May 10, 2022
caarlos0 added a commit that referenced this issue May 10, 2022
adds support for creating meta archives

closes #3085

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
caarlos0 added a commit that referenced this issue May 10, 2022
adds support for creating meta archives

closes #3085

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
@caarlos0
Copy link
Member

please see #3093

@56KBs
Copy link
Contributor Author

56KBs commented May 10, 2022

please see #3093

I've checked out that branch and tested it - It looks like it does exactly what I want - Thanks!

caarlos0 added a commit that referenced this issue May 10, 2022
adds support for creating meta archives

closes #3085

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

2 participants