Skip to content

Commit

Permalink
refactor: migrate from au to chocolatey-au
Browse files Browse the repository at this point in the history
  • Loading branch information
tnc1997 committed May 5, 2024
1 parent b7b5d3c commit ddfbd65
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 2,983 deletions.
36 changes: 28 additions & 8 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# AU template: https://github.com/majkinetor/au-packages-template

version: '{build}'
max_jobs: 1
image: WMF 5
image: Visual Studio 2022
# History plugin requires complete log
clone_depth: 5
branches:
only:
- master
- master
# build:
# verbosity: minimal

Expand Down Expand Up @@ -44,16 +42,32 @@ environment:
secure: U6n1Xfo0lhitmK8PZNHK3q3Dxhz/akc1Im1iotq0JUHgRQ6vao19btvE+lAz3Mmi # https://ci.appveyor.com/tools/encrypt

init:
- git config --global user.email "[email protected]"
- git config --global user.name "tnc1997"
- git config --global user.email "[email protected]"
- git config --global user.name "Chocolatey-AU"
- git config --global core.safecrlf false

install:
- ps: |
$chocoVersion = $Env:choco_version
if (!(Test-Path "$env:nupkg_cache_path")) { mkdir -Force "$env:nupkg_cache_path" }
@{
'chocolatey' = $chocoVersion
# Uncomment and input the version if you are using any of these in AU scripts
# 'wormies-au-helpers' = 'VERSION_HERE'
# 'chocolatey-core.extension' = 'VERSION_HERE'
# 'autohotkey.install' = 'VERSION_HERE'
}.GetEnumerator() | % {
if (!(Test-Path "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg")) { rm "${env:nupkg_cache_path}\$($_.Key).*.nupkg" ; iwr "https://chocolatey.org/api/v2/package/$($_.Key)/$($_.Value)" -OutFile "${env:nupkg_cache_path}\$($_.Key).$($_.Value).nupkg" }
if ($_.Key -eq 'chocolatey') { choco upgrade $_.Key --version $_.Value --source ${env:nupkg_cache_path} --allow-downgrade --pre }
else { choco install $_.Key --version $_.Value --source ${env:nupkg_cache_path} --ignore-dependencies }
}
rm "$env:ChocolateyInstall\logs\*.log"
- ps: 'Get-CimInstance win32_operatingsystem -Property Caption, OSArchitecture, Version | fl Caption, OSArchitecture, Version'
- ps: $PSVersionTable
- git --version
- choco --version
- ps: |
git clone -q https://github.com/majkinetor/au.git $Env:TEMP/au
git clone -q https://github.com/chocolatey-community/chocolatey-au.git $Env:TEMP/au
. "$Env:TEMP/au/scripts/Install-AU.ps1" $Env:au_version
- ps: |
Expand All @@ -80,7 +94,10 @@ build_script:
Write-Host ("{0}`n{1}`n" -f ('-'*60), "PACKAGE: $package")
$package_dir = ls -recurse | ? { $_.Name -eq "$package.nuspec"} | select -First 1 | % Directory
if (!$package_dir) { Write-Warning "Can't find package '$package'"; continue }
pushd $package_dir; choco pack; Push-Package; popd
pushd $package_dir
if (Test-Path update.ps1 -ea 0) { ./update.ps1 }
choco pack; Push-Package;
popd
}
return
}
Expand All @@ -102,5 +119,8 @@ notifications:
on_build_failure: true
on_build_status_changed: true

cache:
- '%nupkg_cache_path% -> .appveyor.yml'

# on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
54 changes: 4 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,83 +7,37 @@

This contains Chocolatey packages, both manually and automatically maintained.

You can choose to use one or both of the different methods currently supported in the Chocolatey community for automatic packaging. They are AU (Automatic Updater) and Ketarin/ChocolateyPackageUpdater.

### Folder Structure

* automatic - where automatic packaging and packages are kept. These are packages that are automatically maintained using either [AU](https://chocolatey.org/packages/au) or [Ketarin](https://chocolatey.org/packages/ketarin)/[ChocolateyPackageUpdater](https://chocolatey.org/packages/chocolateypackageupdater) combo.
* automatic - where automatic packaging and packages are kept. These are packages that are automatically maintained using [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au).
* icons - Where you keep icon files for the packages. This is done to reduce issues when packages themselves move around.
* ketarin - where ketarin jobs (aka applications or searches) exported as XML are kept. This is done to allow ease of contribution.
* manual - where packages that are not automatic are kept.
* ops - scripts, jobs, and other items for ensuring automatic packaging.
* setup - items for prepping the system to ensure for auto packaging.

For setting up your own automatic package repository, please see [Automatic Packaging](https://chocolatey.org/docs/automatic-packages)

### Requirements

* Chocolatey (choco.exe)

#### Ketarin / ChocolateyPackageUpdater

* PowerShell v2+
* [Ketarin](https://chocolatey.org/packages/ketarin)
* [Chocolatey Package Updater](https://chocolatey.org/packages/chocolateypackageupdater)
* A Windows box somewhere - to run the updater on - appveyor can't work until the import of the settings can be automated

#### AU

* PowerShell v5+.
* The [AU module](https://chocolatey.org/packages/au).

For daily operations check out the AU packages [template README](https://github.com/majkinetor/au-packages-template/blob/master/README.md).
* The [chocolatey-au module](https://github.com/chocolatey-community/chocolatey-au).

### Getting started

1. Fork this repository and rename it to `chocolatey-packages` (on GitHub - go into Settings, Repository name and rename).
1. Click "Use this template" then "Create a new repository". Name it `chocolatey-packages`
1. Clone the repository locally.
1. Head into the `setup` folder and perform the proper steps for your choice of setup (or both if you plan to use both methods).
1. Head into the `setup` folder and perform the steps in the README there.
1. Edit this README. Update the badges at the top.


### Recommendation on Auto Packaging

AU provides more in the process of being completely automated, sending emails when things go wrong, and providing a nice report at the end. It doesn't have a bolt-on feeling to it that you see with Ketarin / ChocolateyPackageUdater, however the one thing it does lack in comparison is no visual feedback to seeing how searches for installers may be found. Other than that, it provides errors when things go wrong, where Ketarin doesn't consider anything that happens during "before run"/"post run updates" (where chocopkgup and checksumming occur) to be an error, even if those scripts error.

So for best visibility, enjoying the ease of using AppVeyor, and for a nice report of results, we recommend AU over Ketarin. You also don't need to deal with templates as AU works directly with the xml/ps1 files to do replacement.

### Adapting your current source repository to this source repository template

You want to bring in all of your packages into the proper folders. We suggest using some sort of diffing tool to look at the differences between your current solution and this solution and then making adjustments to it. Pay special attention to the setup folder.

1. Bring over the following files to your package source repository:
* `automatic\README.md`
* `icons\README.md`
* `ketarin\README.md`
* `ketarin\_KetarinChocolateyTemplate.xml`
* `manual\README.md`
* `ops\*.*`
* `setup\*.*`
* `.appveyor.yml`
1. Inspect the following file and add the differences:
* `.gitignore`

### Use Both Methodologies

The way this source repository is designed, you can use both AU and Ketarin/ChocolateyPackageUpdater together. This is especially helpful when migrating existing packages from one methodology to the other.

### Migrating existing Ketarin packages to AU

1. Add an update.ps1 to the package folder and determine how to update the package using [AU's instructions](https://github.com/majkinetor/au#creating-the-package-updater-script).
1. Remove the ketarin.xml file from the ketarin folder.
1. Ensure you also remove the package job from Ketarin itself as it doesn't automatically remove.

### Special Notes

#### Ketarin

* In `Settings -> Global variables` the variable `autoPackagesFolder` is used to determine where your automatic packages are. It doesn't matter what `chocopkgup` is using, this folder is passed through. Ensure this is set appropriately.
* In `Settings -> Global variables` the variable `saveDir` is used to determine where to save the downloaded files from Ketarin. Please ensure the folder exists.
* In `Settings -> Global variables` the variable `nopush` is set to `--nopush`, which allows checksum calculations to occur and then a custom script will push the files.
* In `Settings -> Global variables` the variable `cscript` is set to `2`, which means calculate checksums, rebuild, and push the packages. If you set this to `1` it will do everything except push the packages. Setting this to `1` is how you disable package pushing.
* In `Settings -> Global variables` the variable `checksum` is set to `{checksum}`. Do not change this, this is how the post update script replaces the literal value `{checksum}`. The same goes for `checksumx64`, `packageGuid`, and `url64`.
26 changes: 5 additions & 21 deletions automatic/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
## Automatic Folder

This is where you put your Chocolatey packages that are automatically packaged up by either [AU](https://chocolatey.org/packages/au) or [Ketarin](https://chocolatey.org/packages/ketarin)/[ChocolateyPackageUpdater](https://chocolatey.org/packages/chocolateypackageupdater).
This is where you put your Chocolatey packages that are automatically packaged up by [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au).

### Ketarin / ChocolateyPackageUpdater (chocopkgup)
Execute `update_all.ps1` in the repository root to run [chocolatey-au](https://github.com/chocolatey-community/chocolatey-au) updater with default options.

You want to drop the actual Ketarin files (job file exports) in the top-level ketarin folder to keep them separate from the packages themselves.
To fully setup all the features ensure you perform the steps in the [setup/README.md](https://github.com/chocolatey/chocolatey-packages-template/blob/master/setup/README.md)

The following packages implement this strategy of auto updates:

* 1password
* git.install

There is also an _output folder where the automatic packaging files with tokens to do token replacment and output package files with actual values in this folder. This folder is necessary for chocopkgup to do its work. You can decide whether to commit this set of folders or not. We recommend committing it as it makes it easier to do one off fixes and contributors to submit fixes for a package.

### Automatic Updater (AU)

AU works with packages without automatic package tokens necessary. So you can treat the packages as normal.

Execute `update_all.ps1` in the repository root to run [AU](https://chocolatey.org/packages/au) updater with default options.

To fully setup all the features ensure you perform the steps in the [setup/README.md](https://github.com/chocolatey/chocolatey-packages-template/blob/master/setup/README.md#automatic-updater-au)

To get the packages that implement AU updater run `Get-AUPackages` or `lsau` in this directory.

**NOTE:** Ensure when you are creating packages for AU, you don't use `--auto` as the packaging files should be normal packages. AU doesn't need the tokens to do replacement.
To get the packages that implement chocolatey-au updater run `Get-AUPackages` or `lsau` in this directory.

**NOTE:** Ensure when you are creating packages for chocolatey-au, you don't use `--auto` as the packaging files should be normal packages. chocolatey-au doesn't need the tokens to do replacement.
7 changes: 0 additions & 7 deletions automatic/_output/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions ketarin/README.md

This file was deleted.

108 changes: 0 additions & 108 deletions ketarin/_KetarinChocolateyTemplate.xml

This file was deleted.

9 changes: 0 additions & 9 deletions ops/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions ops/ketarinupdate.cmd

This file was deleted.

Loading

0 comments on commit ddfbd65

Please sign in to comment.