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: Generate Chocolatey packages #2594

Closed
wants to merge 3 commits into from
Closed

feat: Generate Chocolatey packages #2594

wants to merge 3 commits into from

Conversation

twpayne
Copy link
Owner

@twpayne twpayne commented Nov 22, 2022

WIP, not ready for review.

@twpayne twpayne added work in progress Work in progress do not merge Do not merge windows only This only affects Windows labels Nov 24, 2022
@bradenhilton
Copy link
Collaborator

bradenhilton commented Jun 26, 2023

If/when this progresses more, you should be able to use {{ .Now.Format "2006" }} in the copyright year, per https://goreleaser.com/customization/templates/#common-fields :)

@twpayne twpayne force-pushed the chocolatey branch 2 times, most recently from fc1bba6 to 5698c7c Compare June 27, 2023 14:33
@twpayne twpayne added won't implement/fix This will not be worked on in dependency In a dependency, not in chezmoi and removed work in progress Work in progress labels Jul 14, 2023
@twpayne
Copy link
Owner Author

twpayne commented Jul 14, 2023

Unfortunately, this requires a choco.exe binary, which AFAICT is only available on Windows, and so it's not possible to run this on chezmoi's release automation, which runs on Linux.

I'll close this for now. Maybe something will change in the future.

@twpayne twpayne closed this Jul 14, 2023
@bradenhilton
Copy link
Collaborator

Is it possible that this installation method would work?

@bradenhilton
Copy link
Collaborator

The above requires mono. Not sure if it is pre-installed for workflows.

@twpayne twpayne reopened this Jul 16, 2023
@bradenhilton
Copy link
Collaborator

I'm not entirely sure how to interpret the error(s) on the job. It's complaining that there's no such directory as /opt/chocolatey/lib, but it's also complaining about a lack of a description in the Goreleaser config.

The latter makes it look like it did actually try to create the package, implying that the choco installation was at least partially successful, but the former makes it look like it probably shouldn't have gotten that far because (critical?) files were missing.

@bradenhilton
Copy link
Collaborator

I was incorrect in #2594 (comment). The copyright field does not support templates:

# Your app's copyright details.
    copyright: 2022 Drummer Roll Inc

(notice how it does not say # Templates: allowed).

I trimmed .goreleaser.yaml to this:

project_name: chezmoi

before:
  hooks:
  - go mod download all

builds:
- id: chezmoi-nocgo
  env:
  - CGO_ENABLED=0
  goos:
  - windows
  goarch:
  - amd64
  goarm:
  - ''
  ldflags:
  - -s
  - -w
  - -X main.version={{ .Version }}
  - -X main.commit={{ .Commit }}
  - -X main.date={{ .Date }}
  - -X main.builtBy=goreleaser

chocolateys:
- authors: Tom Payne <[email protected]>
  project_url: https://chezmoi.io
  copyright: 'Copyright © Tom Payne, 2018-{{ .Now.Format "2006" }}'
  license_url: https://github.com/twpayne/chezmoi/blob/master/LICENSE
  project_source_url: https://github.com/twpayne/chezmoi
  docs_url: https://chezmoi.io
  bug_tracker_url: https://github.com/twpayne/chezmoi/issues
  summary: Manage your dotfiles across multiple diverse machines, securely.
  description: Manage your dotfiles across multiple diverse machines, securely.
  release_notes: 'https://github.com/twpayne/chezmoi/releases/tag/v{{ .Version }}'

and ran goreleaser locally with:

goreleaser release --clean --config=".goreleaser.yaml" --skip-announce --skip-publish --skip-validate --snapshot --auto-snapshot --timeout="1h"

(I know the flags are excessive)

and here are the relevant chocolatey files:

chezmoi.choco/tools/chocolateyInstall.ps1

# This file was generated by GoReleaser. DO NOT EDIT.
$ErrorActionPreference = 'Stop';

$version = $env:chocolateyPackageVersion
$packageName = $env:chocolateyPackageName
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"

$packageArgs = @{
    packageName    = $packageName
    unzipLocation  = $toolsDir
    fileType       = 'exe'
    url64bit       = 'https://github.com/twpayne/chezmoi/releases/download/v2.35.0/chezmoi_2.35.0-SNAPSHOT-4af84793_windows_amd64.tar.gz'
    checksum64     = '251a47249bd09a4c0c132b0325bf548c407fd82927b9280e3e398e5884289176'
    checksumType64 = 'sha256'
}

Install-ChocolateyZipPackage @packageArgs

chezmoi.choco/chezmoi.nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <id>chezmoi</id>
    <version>2.35.0-SNAPSHOT-4af84793</version>
    <title>chezmoi</title>
    <authors>Tom Payne &lt;[email protected]&gt;</authors>
    <projectUrl>https://chezmoi.io</projectUrl>
    <copyright>Copyright © Tom Payne, 2018-{{ .Now.Format &#34;2006&#34; }}</copyright>
    <licenseUrl>https://github.com/twpayne/chezmoi/blob/master/LICENSE</licenseUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <projectSourceUrl>https://github.com/twpayne/chezmoi</projectSourceUrl>
    <docsUrl>https://chezmoi.io</docsUrl>
    <bugTrackerUrl>https://github.com/twpayne/chezmoi/issues</bugTrackerUrl>
    <summary>Manage your dotfiles across multiple diverse machines, securely.</summary>
    <description>Manage your dotfiles across multiple diverse machines, securely.</description>
    <releaseNotes>https://github.com/twpayne/chezmoi/releases/tag/v2.35.0-SNAPSHOT-4af84793</releaseNotes>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>

@bradenhilton
Copy link
Collaborator

bradenhilton commented Aug 22, 2023

I've been working on this and checking the output with Chocolatey .nuspec Checker, though I did have to set it up manually because I don't feel like re-installing Chocolatey at the moment.

As is, I get this output:

WARNING:   ** The recommended XML comment to test UTF-8 encoding was not found.
           ** Suggestion: Consider running CNC -UpdateXMLComment to add a UTF-8 encoding test XML comment.
WARNING:   ** <authors> - contains an e-mail address. This will trigger a message from the verifier:
           ** Requirements: Email address should not be used in the Author and Copyright fields of the nuspec file.
WARNING:   ** <copyright> - contains an e-mail address. This will trigger a message from the verifier:
           ** Requirements: Email address should not be used in the Author and Copyright fields of the nuspec file.
FYI:       ** <dependencies> - element is empty.
           ** Suggestion: Consider adding a header and help propagate (unofficial) choco:// Protocol support
           ** Suggestion: Consider adding PACKAGE NOTES to inform users of any special information about the package.
WARNING:   ** <iconUrl> - element is empty. This will trigger a message from the verifier:
           ** Guideline: The iconUrl should be added if there is one. Please correct this in the nuspec, if applicable.
WARNING:   ** <mailingListUrl> - element is empty. This will trigger a message from the verifier:
           ** Suggestion: mailingListUrl - points to the forum or email list group for the software
WARNING:   ** <owners> element is empty, this element is a requirement.
WARNING:   ** <packageSourceUrl> - element is empty. This will trigger a message from the verifier:
           ** Guideline: The nuspec has been enhanced to allow packageSourceUrl, pointing to the url where the package
              source resides. This is a strong guideline because it simplifies collaboration.
              Please add it to the nuspec.
WARNING:   ** <tags> - element is empty.
WARNING:   ** <title> and <id> are the same which will trigger a message from the verifier:
           ** Guideline: Title (title) matches id exactly. Please consider using something slightly more descriptive
              for the title in the nuspec.
WARNING:   ** CHOCOLATEYINSTALL.PS1 - is encoded using ASCII or UTF-8 w/o BOM.
           ** PowerShell scripts need to be saved in UTF–8 with BOM.
           ** Suggestion: Consider running CNC -UpdateScripts to re-write CHOCOLATEYINSTALL.PS1 to UTF-8 w/ BOM.
WARNING:   ** CHOCOLATEYINSTALL.PS1 - the URL:

https://github.com/twpayne/chezmoi/releases/download/v2.35.0/chezmoi_2.35.0-SNAPSHOT-4af84793_windows_amd64.tar.gz
              site might be OK, status code: 404.
CNC found 4 REQUIRED changes, 3 GUIDELINE changes, 6 SUGGESTED changes, 0 NOTES, 1 FYIs, and made 0 changes.

I've satisfied the required changes in my working copy, though some of the suggestions are impossible to implement without goreleaser changes as far as I can tell.

I'll try to rebase and push a new commit and see what happens. On second thought, this would require a force push, which would mess with any local changes anyone might have, so I'm not going to do it.

@bradenhilton
Copy link
Collaborator

@twpayne I believe I have this mostly solved. Should I close this and open a new PR, or would you prefer if I instead linked my branch here and you can update it at your convenience?

@twpayne
Copy link
Owner Author

twpayne commented Aug 24, 2023

Please close this PR and open a new one. There are very few open PRs at the moment, so assume that no one has any pending changes. You own this :)

@twpayne twpayne removed the won't implement/fix This will not be worked on label Aug 24, 2023
@twpayne twpayne deleted the chocolatey branch August 24, 2023 20:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
do not merge Do not merge in dependency In a dependency, not in chezmoi windows only This only affects Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants