Skip to content

Commit 710a6ff

Browse files
committed
feat(release): add chocolatey packaging
1 parent 25fc134 commit 710a6ff

10 files changed

Lines changed: 216 additions & 2 deletions

File tree

‎.mise.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ run = "mise run install && bun scripts/build-release.ts"
1818

1919
[tasks.render-homebrew-formula]
2020
run = "mise run install && bun scripts/render-homebrew-formula.ts"
21+
22+
[tasks.render-chocolatey-package]
23+
run = "mise run install && bun scripts/render-chocolatey-package.ts"

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Skillet installs, discovers, and updates `SKILL.md`-based skills across supporte
1010
| --- | --- | --- |
1111
| Binary release | Download from GitHub Releases | Planned |
1212
| Homebrew | `brew install skillet` | Configured |
13-
| Chocolatey | `choco install skillet` | Planned |
13+
| Chocolatey | `choco install skillet` | Configured |
1414
| winget | `winget install skillet` | Planned |
1515
| npm / npx | `npx skillet ...` | Planned |
1616
| Docker | `docker run ... skillet ...` | Planned |
@@ -142,3 +142,4 @@ AGENTS instructions live in `AGENTS.md`.
142142
Distribution docs:
143143

144144
- Homebrew: `docs/distribution/homebrew.md`
145+
- Chocolatey: `docs/distribution/chocolatey.md`

‎docs/distribution/chocolatey.md‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Chocolatey Distribution
2+
3+
Skillet ships a Chocolatey package for Windows CLI installs.
4+
5+
## Release Flow
6+
7+
1. Build release artifacts and checksums.
8+
2. Render `packaging/chocolatey/` from `SHA256SUMS`.
9+
3. Build and push the `.nupkg` with `choco pack` and `choco push`.
10+
11+
## Commands
12+
13+
```bash
14+
mise run build -- --targets=windows-x64
15+
bun scripts/write-checksums.ts
16+
mise run render-chocolatey-package -- --version <version>
17+
```
18+
19+
Generate package and publish:
20+
21+
```powershell
22+
cd packaging/chocolatey
23+
choco pack
24+
choco push skillet.<version>.nupkg --source https://push.chocolatey.org/
25+
```
26+
27+
User install command:
28+
29+
```powershell
30+
choco install skillet
31+
```

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"dev": "bun src/cli.ts",
1111
"test": "vitest run",
1212
"build": "bun scripts/build-release.ts",
13-
"render:homebrew": "bun scripts/render-homebrew-formula.ts"
13+
"render:homebrew": "bun scripts/render-homebrew-formula.ts",
14+
"render:choco": "bun scripts/render-chocolatey-package.ts"
1415
},
1516
"dependencies": {
1617
"cac": "^6.7.14",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
3+
<metadata>
4+
<id>skillet</id>
5+
<version>0.0.0</version>
6+
<title>skillet</title>
7+
<authors>echohello-dev</authors>
8+
<projectUrl>https://github.com/echohello-dev/skillet</projectUrl>
9+
<packageSourceUrl>https://github.com/echohello-dev/skillet</packageSourceUrl>
10+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
11+
<description>Portable CLI for managing agent skills.</description>
12+
<tags>cli skills agent</tags>
13+
</metadata>
14+
<files>
15+
<file src="tools\**" target="tools" />
16+
</files>
17+
</package>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$ErrorActionPreference = 'Stop'
2+
3+
$packageName = 'skillet'
4+
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
5+
$binaryPath = Join-Path $toolsDir 'skillet.exe'
6+
$url64 = 'https://github.com/echohello-dev/skillet/releases/download/v0.0.0/skillet-windows-x64.exe'
7+
$checksum64 = '51cddefde243f0f27e501ca420d5e1d1b9cad548dc9884ea4052d2915afef179'
8+
9+
Get-ChocolateyWebFile -PackageName $packageName -FileFullPath $binaryPath -Url64bit $url64 -Checksum64 $checksum64 -ChecksumType64 'sha256'
10+
Install-BinFile -Name 'skillet' -Path $binaryPath
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ErrorActionPreference = 'Stop'
2+
Uninstall-BinFile -Name 'skillet'
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
import { parseSha256Sums } from "../src/distribution/checksums";
4+
import { renderChocolateyPackageFiles } from "../src/distribution/chocolatey";
5+
6+
function main(): void {
7+
const args = process.argv.slice(2);
8+
const version = readArg(args, "--version") ?? readVersionFromPackageJson();
9+
const checksumsPath = path.resolve(readArg(args, "--checksums") ?? "dist/SHA256SUMS");
10+
const outputDir = path.resolve(readArg(args, "--output-dir") ?? "packaging/chocolatey");
11+
const releaseUrlBase =
12+
readArg(args, "--release-url-base") ??
13+
`https://github.com/echohello-dev/skillet/releases/download/v${version}`;
14+
15+
if (!fs.existsSync(checksumsPath)) {
16+
throw new Error(`Checksums file not found: ${checksumsPath}`);
17+
}
18+
19+
const checksums = parseSha256Sums(fs.readFileSync(checksumsPath, "utf8"));
20+
const files = renderChocolateyPackageFiles({ version, releaseUrlBase, checksumsByArtifact: checksums });
21+
22+
fs.mkdirSync(path.join(outputDir, "tools"), { recursive: true });
23+
fs.writeFileSync(path.join(outputDir, "skillet.nuspec"), files.nuspec);
24+
fs.writeFileSync(path.join(outputDir, "tools", "chocolateyinstall.ps1"), files.installScript);
25+
fs.writeFileSync(path.join(outputDir, "tools", "chocolateyuninstall.ps1"), files.uninstallScript);
26+
console.log(`Wrote Chocolatey package files to ${outputDir}`);
27+
}
28+
29+
function readArg(args: string[], name: string): string | undefined {
30+
for (let i = 0; i < args.length; i += 1) {
31+
const token = args[i];
32+
if (token === name) {
33+
const next = args[i + 1];
34+
if (!next || next.startsWith("--")) {
35+
throw new Error(`Missing value for ${name}`);
36+
}
37+
return next;
38+
}
39+
40+
const prefix = `${name}=`;
41+
if (token.startsWith(prefix)) {
42+
const value = token.slice(prefix.length);
43+
if (value.length === 0) {
44+
throw new Error(`Missing value for ${name}`);
45+
}
46+
return value;
47+
}
48+
}
49+
50+
return undefined;
51+
}
52+
53+
function readVersionFromPackageJson(): string {
54+
const packageJsonPath = path.resolve("package.json");
55+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")) as { version?: string };
56+
if (!packageJson.version || packageJson.version.length === 0) {
57+
throw new Error("package.json version is missing");
58+
}
59+
60+
return packageJson.version;
61+
}
62+
63+
main();

‎src/distribution/chocolatey.ts‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
const WINDOWS_X64_ARTIFACT = "skillet-windows-x64.exe";
2+
3+
export type ChocolateyPackageOptions = {
4+
version: string;
5+
releaseUrlBase: string;
6+
checksumsByArtifact: Map<string, string>;
7+
};
8+
9+
export type ChocolateyPackageFiles = {
10+
nuspec: string;
11+
installScript: string;
12+
uninstallScript: string;
13+
};
14+
15+
export function renderChocolateyPackageFiles(options: ChocolateyPackageOptions): ChocolateyPackageFiles {
16+
const releaseUrlBase = options.releaseUrlBase.replace(/\/+$/, "");
17+
const downloadUrl = `${releaseUrlBase}/${WINDOWS_X64_ARTIFACT}`;
18+
const checksum = requireChecksum(options.checksumsByArtifact, WINDOWS_X64_ARTIFACT);
19+
20+
return {
21+
nuspec: `<?xml version="1.0" encoding="utf-8"?>
22+
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
23+
<metadata>
24+
<id>skillet</id>
25+
<version>${options.version}</version>
26+
<title>skillet</title>
27+
<authors>echohello-dev</authors>
28+
<projectUrl>https://github.com/echohello-dev/skillet</projectUrl>
29+
<packageSourceUrl>https://github.com/echohello-dev/skillet</packageSourceUrl>
30+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
31+
<description>Portable CLI for managing agent skills.</description>
32+
<tags>cli skills agent</tags>
33+
</metadata>
34+
<files>
35+
<file src="tools\\**" target="tools" />
36+
</files>
37+
</package>
38+
`,
39+
installScript: `$ErrorActionPreference = 'Stop'
40+
41+
$packageName = 'skillet'
42+
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
43+
$binaryPath = Join-Path $toolsDir 'skillet.exe'
44+
$url64 = '${downloadUrl}'
45+
$checksum64 = '${checksum}'
46+
47+
Get-ChocolateyWebFile -PackageName $packageName -FileFullPath $binaryPath -Url64bit $url64 -Checksum64 $checksum64 -ChecksumType64 'sha256'
48+
Install-BinFile -Name 'skillet' -Path $binaryPath
49+
`,
50+
uninstallScript: `$ErrorActionPreference = 'Stop'
51+
Uninstall-BinFile -Name 'skillet'
52+
`,
53+
};
54+
}
55+
56+
function requireChecksum(checksumsByArtifact: Map<string, string>, artifactName: string): string {
57+
const checksum = checksumsByArtifact.get(artifactName);
58+
if (!checksum) {
59+
throw new Error(`Missing checksum for artifact: ${artifactName}`);
60+
}
61+
62+
return checksum;
63+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, expect, it } from "vitest";
2+
import { renderChocolateyPackageFiles } from "../../src/distribution/chocolatey";
3+
4+
describe("renderChocolateyPackageFiles", () => {
5+
it("renders nuspec and install scripts from checksum data", () => {
6+
const files = renderChocolateyPackageFiles({
7+
version: "1.2.3",
8+
releaseUrlBase: "https://github.com/echohello-dev/skillet/releases/download/v1.2.3",
9+
checksumsByArtifact: new Map([
10+
["skillet-windows-x64.exe", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
11+
]),
12+
});
13+
14+
expect(files.nuspec).toContain("<version>1.2.3</version>");
15+
expect(files.installScript).toContain(
16+
"$url64 = 'https://github.com/echohello-dev/skillet/releases/download/v1.2.3/skillet-windows-x64.exe'",
17+
);
18+
expect(files.installScript).toContain(
19+
"$checksum64 = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'",
20+
);
21+
expect(files.uninstallScript).toContain("Uninstall-BinFile -Name 'skillet'");
22+
});
23+
});

0 commit comments

Comments
 (0)