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

feat: chocolatey support #3509

Merged
merged 3 commits into from Nov 12, 2022
Merged

feat: chocolatey support #3509

merged 3 commits into from Nov 12, 2022

Conversation

faabiosr
Copy link
Contributor

@faabiosr faabiosr commented Oct 29, 2022

This PR adds support for generating the structure used to pack and push Chocolatey Packages. And will solve the #3154

Is not ready for merge yet, but has the main structure, and ready for comments.

Accordingly to Chocolatey, in order to build a package, it's necessary a .nuspec and chocolateyinstall.ps1 files at least, having these ones, we could pack and distribute without adding the binary inside the final package and that was implemented here.

To complete, will be necessary to define the package build and distribute, however will be required to have Chocolatey installed (Windows Only). One of alternatives that I thought was, publish the files like Scoop and Brew in a separate repository, and there we could use chocolatey through crazy-max/ghaction-chocolatey.

Chocolatey has a lot of good examples of repositories:
https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/curl

A final compilation of the missing parts:

  • How to pack and push (chocolatey)
  • Documentation

Sorry for the long description😄

All feedback very welcome!

@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 29, 2022
@faabiosr
Copy link
Contributor Author

Looking into Snapcraft feature, and after some tests, I realized that we could follow the same approach, by calling chocolatey to pack the generated script, although it's required to install chocolatey on Linux.

Also I wrote this simple step in a workflow for testing.

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: install chocolatey
        run: |
          mkdir -p /opt/chocolatey
          wget -q -O - "https://github.com/chocolatey/choco/releases/download/${CHOCOLATEY_VERSION}/chocolatey.v${CHOCOLATEY_VERSION}.tar.gz" | tar -xz -C "/opt/chocolatey"
          echo '#!/bin/bash' >> /usr/local/bin/choco.exe
          echo 'mono /opt/chocolatey/choco.exe $@' >> /usr/local/bin/choco.exe
          chmod +x /usr/local/bin/choco.exe
        env:
          CHOCOLATEY_VERSION: 1.2.0

After that it's just a matter of using goreleaser.

@faabiosr
Copy link
Contributor Author

I made a repository with an example: https://github.com/faabiosr/rand-beer

@caarlos0
Copy link
Member

This is looking VERY good so far!

For the push part, I think we can check if chocolatey is installed and run it, or return a pipe.Skip otherwise.

amazing work, thank you!

@faabiosr faabiosr force-pushed the chocolatey branch 2 times, most recently from c0c32b0 to d378e3c Compare October 31, 2022 16:15
@faabiosr
Copy link
Contributor Author

faabiosr commented Nov 2, 2022

@caarlos0 During this week I will finish all the implementation of this functionality, thanks for the support.

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.

looking good!

we should also add docs, and I think we can release goreleaser to chocolatey as well

@codecov
Copy link

codecov bot commented Nov 2, 2022

Codecov Report

Merging #3509 (6d020e5) into main (25522b5) will decrease coverage by 0.27%.
The diff coverage is 74.20%.

❗ Current head 6d020e5 differs from pull request most recent head 94613c6. Consider uploading reports for the commit 94613c6 to get more accurate results

@@            Coverage Diff             @@
##             main    #3509      +/-   ##
==========================================
- Coverage   84.27%   83.99%   -0.28%     
==========================================
  Files         114      116       +2     
  Lines        9338     9581     +243     
==========================================
+ Hits         7870     8048     +178     
- Misses       1191     1239      +48     
- Partials      277      294      +17     
Impacted Files Coverage Δ
internal/artifact/artifact.go 87.36% <0.00%> (-0.64%) ⬇️
internal/pipe/publish/publish.go 78.57% <ø> (ø)
pkg/config/config.go 95.21% <ø> (ø)
internal/pipe/chocolatey/chocolatey.go 74.13% <74.13%> (ø)
internal/pipe/chocolatey/nuspec.go 83.33% <83.33%> (ø)
internal/pipe/changelog/changelog.go 91.45% <0.00%> (-0.27%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@caarlos0 caarlos0 changed the title Chocolatey Support feat: chocolatey support Nov 2, 2022
@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 4, 2022
@faabiosr
Copy link
Contributor Author

faabiosr commented Nov 4, 2022

All changes made, if you want to take a look in https://github.com/faabiosr/rand-beer/actions/runs/3395654844/jobs/5645812260, you will see the full integration

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.

looking very good! Thank you so much!

Made a bunch of comments, let me know what you think!

www/docs/customization/chocolatey.md Outdated Show resolved Hide resolved
www/docs/customization/chocolatey.md Outdated Show resolved Hide resolved
www/docs/customization/chocolatey.md Outdated Show resolved Hide resolved
www/docs/customization/chocolatey.md Show resolved Hide resolved
internal/pipe/publish/publish.go Show resolved Hide resolved
internal/pipe/chocolatey/chocolatey.go Outdated Show resolved Hide resolved
The Nuspec follows the Nuget/Chocolatey package specification in order
to generate the nupkg file.
Generates the chocolatey package structure in order to pack and push to
chocolatey repository.
@faabiosr
Copy link
Contributor Author

faabiosr commented Nov 8, 2022

Please let me know if anything else needs to be done. Thanks a lot for the help. 😉

@caarlos0 caarlos0 merged commit f2281e8 into goreleaser:main Nov 12, 2022
@github-actions github-actions bot added this to the v1.13.0 milestone Nov 12, 2022
@caarlos0
Copy link
Member

Thank you so much @faabiosr ! Merged!

@caarlos0 caarlos0 added the enhancement New feature or request label Nov 12, 2022
@rfay
Copy link
Contributor

rfay commented Nov 13, 2022

Yippee, thanks @faabiosr!

gal-legit pushed a commit to gal-legit/goreleaser that referenced this pull request Nov 13, 2022
This PR adds support for generating the structure used to pack and push
Chocolatey Packages. And will solve the goreleaser#3154

Is not ready for merge yet, but has the main structure, and ready for
comments.

Accordingly to Chocolatey, in order to build a package, it's necessary a
`.nuspec` and `chocolateyinstall.ps1` files at least, having these ones,
we could pack and distribute without adding the binary inside the final
package and that was implemented here.

To complete, will be necessary to define the package build and
distribute, however will be required to have Chocolatey installed
(Windows Only). One of alternatives that I thought was, publish the
files like Scoop and Brew in a separate repository, and there we could
use `chocolatey` through
[crazy-max/ghaction-chocolatey](https://github.com/crazy-max/ghaction-chocolatey).

Chocolatey has a lot of good examples of repositories:

https://github.com/chocolatey-community/chocolatey-packages/tree/master/automatic/curl

A final compilation of the missing parts:
- [x] How to pack and push (chocolatey)
- [x] Documentation

Sorry for the long description😄 

All feedback very welcome!

Co-authored-by: Carlos Alexandro 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
enhancement New feature or request size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants