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

Add packager-specific nfpm config (#1829) #1849

Merged
merged 13 commits into from Nov 5, 2020

Conversation

jonathanlloyd
Copy link
Contributor

Add new nfpm config options to goreleaser

So that all the options offered by nfpm are available in goreleaser!

Closes: #1829

@vercel
Copy link

vercel bot commented Oct 10, 2020

@jonathanlloyd is attempting to deploy a commit to the Goreleaser Team on Vercel.

A member of the Team first needs to authorize it.

@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 10, 2020
@jonathanlloyd jonathanlloyd changed the title feat: Add deb packager-specific nfpm config (#1829) feat: Add packager-specific nfpm config (#1829) Oct 10, 2020
@jonathanlloyd jonathanlloyd changed the title feat: Add packager-specific nfpm config (#1829) WIP feat: Add packager-specific nfpm config (#1829) Oct 10, 2020
@codecov
Copy link

codecov bot commented Oct 10, 2020

Codecov Report

Merging #1849 into master will increase coverage by 0.24%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1849      +/-   ##
==========================================
+ Coverage   81.44%   81.68%   +0.24%     
==========================================
  Files          73       73              
  Lines        3729     3779      +50     
==========================================
+ Hits         3037     3087      +50     
  Misses        570      570              
  Partials      122      122              
Impacted Files Coverage Δ
pkg/config/config.go 93.75% <ø> (ø)
internal/pipe/nfpm/nfpm.go 94.28% <100.00%> (+2.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 452e97d...d4712e5. Read the comment docs.

@jonathanlloyd
Copy link
Contributor Author

@caarlos0 wyt? Is this what you had in mine in #1829?
If so I'll add apk and rpm

@caarlos0
Copy link
Member

Overall it looks good, but we need to think how'll we handle the secrets... not sure if we can assume NFPM_DEB_PASSPHRASE because the user might have multiple nfpm targets with different signing for some reason (although its a weird use case and sure if its a real one)...

@jonathanlloyd
Copy link
Contributor Author

jonathanlloyd commented Oct 13, 2020

Overall it looks good, but we need to think how'll we handle the secrets... not sure if we can assume NFPM_DEB_PASSPHRASE because the user might have multiple nfpm targets with different signing for some reason (although its a weird use case and sure if its a real one)...

What about a .goreleaser-secrets.yaml you can put in your .gitignore?
Then you could reference secrets by name:

.goreleaser-secrets.yaml

deb_passphrase_1: "my-super-secret-passphrase"
deb_passphrase_2: "another-one"

.goreleaser.yaml

nfpms:
 - id: nfpm1
   # other config
   deb:
     key_file: key.gpg
     key_passphrase_secret: deb_passphrase_1
 - id: nfpm2
   # other config
   deb:
     key_file: key.gpg
     key_passphrase_secret: deb_passphrase_2

Thoughts?

@caarlos0
Copy link
Member

I would say to do something similar to what we have on the http pipe: https://goreleaser.com/customization/upload/

Just maybe use id instead of name... I think that at the time the concept of id wasn't implemented yet...

@@ -156,6 +156,39 @@ nfpms:
"tmp/app_generated.conf": "/etc/app-rpm.conf"
scripts:
preinstall: "scripts/preinstall-rpm.sh"

# Custon configuration applied only to the Deb packager.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom not Custon

@caarlos0
Copy link
Member

@jonathanlloyd hey, do you plan on continue working on this? Otherwise I can take it from here :)

@jonathanlloyd
Copy link
Contributor Author

@jonathanlloyd hey, do you plan on continue working on this? Otherwise I can take it from here :)

Sorry, been super busy. I can take a look at it today 😄

@jonathanlloyd
Copy link
Contributor Author

@caarlos0 I've updated the env var logic and added some tests
If you're happy I'll do the other packagers 🙂

Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far looks good to me, thanks 🙏🚀

@jonathanlloyd jonathanlloyd changed the title WIP feat: Add packager-specific nfpm config (#1829) Add packager-specific nfpm config (#1829) Oct 27, 2020
@vandot
Copy link
Contributor

vandot commented Nov 3, 2020

After this is merged I will create PR to add deb templates, or if my PR to nfpm is merged before we can include it here?

Copy link
Contributor

@vandot vandot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My PR to nfpm got merged, if you would like to include templates file as well great and thanks :) If not I would create separate PR after this one is merged.
On top of all proposed changes you have to update deps go mod edit -require=github.com/goreleaser/nfpm@v1.9.0

@@ -173,6 +174,42 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
PreRemove: overridden.Scripts.PreRemove,
PostRemove: overridden.Scripts.PostRemove,
},
Deb: nfpm.Deb{
Scripts: nfpm.DebScripts{
Rules: overridden.Deb.Scripts.Rules,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

Templates: overridden.Deb.Scripts.Templates,


// NFPMDebScripts is scripts only available on deb packages.
type NFPMDebScripts struct {
Rules string `yaml:"rules,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

Templates string `yaml:"templates,omitempty"`

deb:
# Custom deb rules script.
scripts:
rules: foo.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to this

  # Custom deb special files.
  scripts:
    # Deb rules script.
    rules: foo.sh
    # Deb templates file, when using debconf.
    templates: templates

@ryancurrah
Copy link
Contributor

Nice templates 👍 . Super stoked for this.

@caarlos0
Copy link
Member

caarlos0 commented Nov 3, 2020

updating nfpm already: #1883

@jonathanlloyd
Copy link
Contributor Author

My PR to nfpm got merged, if you would like to include templates file as well great and thanks :) If not I would create separate PR after this one is merged.
On top of all proposed changes you have to update deps go mod edit -require=github.com/goreleaser/nfpm@v1.9.0

Merged in the latest version of nfpm and added these changes :)

@caarlos0 caarlos0 merged commit 17e5674 into goreleaser:master Nov 5, 2020
@caarlos0
Copy link
Member

caarlos0 commented Nov 5, 2020

Great work everyone, many thanks! 🚀

Would be awesome to add some example usages of these advanced options to docs as well (maybe in the how to session), if someone wants to tackle that, please feel free to do so 🙏

@vandot
Copy link
Contributor

vandot commented Nov 6, 2020

@caarlos0 I can for templates 😃
thank you for fast merge and publish in both projects 🙌

@ryancurrah
Copy link
Contributor

When I get to using the new features I can also create a PR for docs.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2020

This pull request 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 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port new nfpm options into goreleaser
5 participants