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

Automate consul build+push with AppVeyor #10

Closed
StefanScherer opened this issue Dec 21, 2016 · 15 comments
Closed

Automate consul build+push with AppVeyor #10

StefanScherer opened this issue Dec 21, 2016 · 15 comments

Comments

@StefanScherer
Copy link

Hey @calvn
It is great to see that you have started with AppVeyor to build the consul choco package.
How about improving it for the last mile to push the choco package with a release build?

Please have a look at eg. https://github.com/ahmetalpbalkan/docker-chocolatey which works very well and now is community driven. We receive pull requests, AppVeyor tests it, the maintainers can merge it and just draft a new GitHub release with the new version number. With that release build AppVeyor also pushes the choco package to chocolatey.org

If you need help, please let me know :-)

@StefanScherer
Copy link
Author

If you proceed with that automation with AppVeyor I suggest to rename the repo to eg. chocolatey-consul to make clear that its purpose is only for building the consul package.

@calvn
Copy link
Owner

calvn commented Dec 21, 2016

Thanks for bringing this up! I'll take a look at it and automate the process for performing releases.

@calvn
Copy link
Owner

calvn commented Dec 27, 2016

@StefanScherer I started the repository using fervencoder's package layout, but I do find automation from docker-chocolatey more appealing. If I were to use releases to trigger pushes I might need to change the repo to a repo-per-package structure (i.e. consul-chocolatey or something of the like).

Technically, I can do releases with the current layout since consul is the only package in here, but it wouldn't make much sense to do so.

@calvn
Copy link
Owner

calvn commented Dec 27, 2016

I completely missed your second comment, but agreed. I should definitely change it to consul-chocolatey.

@calvn
Copy link
Owner

calvn commented Dec 27, 2016

@StefanScherer I see the following line for deploy_script on docker-chocolatey: $version = $env:APPVEYOR_BUILD_VERSION -replace('\.[^.\\/]+$'), which pretty much removes the build number from the version.

What happens when you need to deploy a choco-package fix for the same docker version - does published package get replaced? I would think that packages would be immutable once deployed so that it doesn't alter deployment scripts behavior (for example when using Chef, Puppet, etc. one would expect the same exact deployment if package/dependency versions remain constant). This question actually has been in my mind for anything that gets "wrapped" (docker images, homebrew packages, chocolatey pacakges, etc.).

@StefanScherer
Copy link
Author

@calvn Great! Yes a repo per choco package is the most clean way to automate it with AppVeyor.

Fixing choco packages with the same version of the binary is an edge case, but it happens. I had to fix eg. packer 0.8.6 again as the download links from HashiCorp have changed. OK, they promise that this won't happen again, but you never know.

You can't send a chocolatey package again with the same version number. That's for a good reason as people already have downloaded the same package and that would break all package managers.
Instead Chocolatey suggests to append the current date for such fixes. So I released https://github.com/StefanScherer/choco-packer/releases/tag/0.8.6.20160211

So it is possible to fix a choco package for the same binary version, but you normally don't need it.

@calvn
Copy link
Owner

calvn commented Dec 29, 2016

I created chocolatey-consul to hold the choco package for Consul. The repository might still be a little messy, but the builds are passing. All that is needed is to perform an update and tag the commit to release the next version of the package.

It would be greatly appreciated if you can review it, and let me know if I missed anything. Thanks!

@calvn
Copy link
Owner

calvn commented Dec 29, 2016

@StefanScherer I am not super familiar with PowerShell syntax, and couldn't quite find out how to pass in environment variable to a batch script. I set the variable in line 14, but currently it's not used in line 15.

@StefanScherer
Copy link
Author

@calvn Yes, I will have a close look at it later on. I think you can fix your problem setting an environment variable in line 14 with - ps: $env:CONSUL_VERSION = ....

In PowerShell you have local/global variables that are only visible inside the PowerShell script. To read/write environment variables use $env:VAR=val

@calvn
Copy link
Owner

calvn commented Dec 29, 2016

Yep, my question was how to do the following on PS:

$ TEST=world ./test.sh
hello world
$ cat test.sh
echo "Hello $TEST"

@StefanScherer
Copy link
Author

The other problem might be switching the shells, so even the environment variable is only set inside the powershell script line. So it might be better to put it into a multi line powershell script.

build_script:
  - ps: >-
      $env:CONSUL_VERSION = $env:APPVEYOR_BUILD_VERSION -replace('\.[^.\\/]+$');
      download.bat
      choco pack consul.nuspec

This still should work as batch files can be called from powershell - a cmd.exe will be started automatically.

@calvn
Copy link
Owner

calvn commented Dec 29, 2016

I think I need to explicitly use cmd.exe. Getting this error:

download.bat : The term 'download.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try 
again.
At line:1 char:76
+ ... :APPVEYOR_BUILD_VERSION -replace('\.[^.\\/]+$'); download.bat choco p ...
+                                                      ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (download.bat:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
Command executed with exception: The term 'download.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

@StefanScherer
Copy link
Author

Oh, yes there is also another detail to add a semicolon. I think that's also needed.

cmd /c download.bat;

@calvn
Copy link
Owner

calvn commented Dec 30, 2016

I pushed consul v0.7.1 via the new repository and will push v0.7.2 once that's approved. I am closing this thread for now, but thanks for your help!

@calvn calvn closed this as completed Dec 30, 2016
@StefanScherer
Copy link
Author

Awesome 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants