Skip to content

Update chocolatey.yml #2

Update chocolatey.yml

Update chocolatey.yml #2

Workflow file for this run

name: Update Chocolatey Package
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., v2.0.1)'
required: true
type: string
release:
types: [published, created]
push:
tags:
- 'v*'
jobs:
update-chocolatey:
runs-on: windows-latest
# Prevent duplicate runs
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Calculate SHA256
id: sha256
run: |
# Handle different trigger types
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$VERSION = "${{ github.event.inputs.version }}"
} elseif ("${{ github.event_name }}" -eq "release") {
$VERSION = "${{ github.event.release.tag_name }}"
} else {
$VERSION = $env:GITHUB_REF -replace 'refs/tags/', ''
}
Write-Host "Using version: $VERSION"
$URL = "https://github.com/Phara0h/WaspsWithBazookas/releases/download/$VERSION/waspswithbazookas-windows-x86_64.tar.gz"
# Download and calculate SHA256
Invoke-WebRequest -Uri $URL -OutFile "waspswithbazookas.tar.gz"
$hash = Get-FileHash -Algorithm SHA256 "waspswithbazookas.tar.gz"
echo "sha256=$($hash.Hash.ToLower())" >> $env:GITHUB_OUTPUT
echo "version=$VERSION" >> $env:GITHUB_OUTPUT
- name: Checkout Chocolatey Packages Repository
uses: actions/checkout@v4
with:
repository: chocolatey-community/chocolatey-packages
token: ${{ secrets.CHOCOLATEY_API_KEY }}
path: chocolatey-packages
- name: Update Chocolatey Package
run: |
cd chocolatey-packages
# Download the package template or create one
if (!(Test-Path "automatic/waspswithbazookas/waspswithbazookas.nuspec")) {
New-Item -ItemType Directory -Path "automatic/waspswithbazookas" -Force | Out-Null
@"
<?xml version="1.0" encoding="utf-8"?>

Check failure on line 61 in .github/workflows/chocolatey.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/chocolatey.yml

Invalid workflow file

You have an error in your yaml syntax on line 61
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>waspswithbazookas</id>
<version>${{ github.event.release.tag_name }}</version>
<title>WaspsWithBazookas</title>
<authors>Phara0h</authors>
<projectUrl>https://github.com/Phara0h/WaspsWithBazookas</projectUrl>
<licenseUrl>https://github.com/Phara0h/WaspsWithBazookas/blob/main/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/Phara0h/WaspsWithBazookas</projectSourceUrl>
<docsUrl>https://github.com/Phara0h/WaspsWithBazookas</docsUrl>
<bugTrackerUrl>https://github.com/Phara0h/WaspsWithBazookas/issues</bugTrackerUrl>
<tags>waspswithbazookas load-testing http-testing distributed-testing rust</tags>
<summary>Distributed HTTP/S load testing tool with cluster-based architecture</summary>
<description>
WaspsWithBazookas is your ultimate distributed load testing weapon.
Think of it as having an army of angry wasps, each armed with rocket launchers,
ready to absolutely obliterate your servers with HTTP requests.
</description>
<releaseNotes>https://github.com/Phara0h/WaspsWithBazookas/releases</releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
"@ | Out-File -FilePath "automatic/waspswithbazookas/waspswithbazookas.nuspec" -Encoding UTF8
}
# Update the version in the nuspec file
(Get-Content "automatic/waspswithbazookas/waspswithbazookas.nuspec") -replace '<version>.*</version>', "<version>${{ github.event.release.tag_name }}</version>" | Set-Content "automatic/waspswithbazookas/waspswithbazookas.nuspec"
# Create the tools directory and chocolateyInstall.ps1
New-Item -ItemType Directory -Path "automatic/waspswithbazookas/tools" -Force | Out-Null
@"
$ErrorActionPreference = 'Stop'
$packageName = 'waspswithbazookas'
$url = 'https://github.com/Phara0h/WaspsWithBazookas/releases/download/${{ github.event.release.tag_name }}/waspswithbazookas-windows-x86_64.tar.gz'
$checksum = '${{ steps.sha256.outputs.sha256 }}'
$checksumType = 'sha256'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
# Download and extract
$tempDir = Join-Path $env:TEMP $packageName
if (!(Test-Path $tempDir)) { New-Item -ItemType Directory -Path $tempDir | Out-Null }
$zipFile = Join-Path $tempDir "$packageName.zip"
Invoke-WebRequest -Uri $url -OutFile $zipFile -UseBasicParsing
# Verify checksum
$hash = Get-FileHash -Path $zipFile -Algorithm $checksumType
if ($hash.Hash -ne $checksum) {
throw "Checksum verification failed. Expected: $checksum, Got: $($hash.Hash)"
}
# Extract
Expand-Archive -Path $zipFile -DestinationPath $tempDir -Force
# Install binaries
$binDir = Join-Path $toolsDir "bin"
if (!(Test-Path $binDir)) { New-Item -ItemType Directory -Path $binDir | Out-Null }
Copy-Item -Path "$tempDir\hive.exe" -Destination $binDir -Force
Copy-Item -Path "$tempDir\wasp.exe" -Destination $binDir -Force
Copy-Item -Path "$tempDir\test-dummy.exe" -Destination $binDir -Force
# Create shims
Install-ChocolateyPath -PathToInstall $binDir -PathType Machine
"@ | Out-File -FilePath "automatic/waspswithbazookas/tools/chocolateyInstall.ps1" -Encoding UTF8
# Create chocolateyUninstall.ps1
@"
$ErrorActionPreference = 'Stop'
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$binDir = Join-Path $toolsDir "bin"
# Remove binaries
if (Test-Path $binDir) {
Remove-Item -Path $binDir -Recurse -Force
}
# Remove from PATH (Chocolatey handles this automatically)
"@ | Out-File -FilePath "automatic/waspswithbazookas/tools/chocolateyUninstall.ps1" -Encoding UTF8
# Create .nuspec file for the package
@"
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>waspswithbazookas</id>
<version>${{ github.event.release.tag_name }}</version>
<title>WaspsWithBazookas</title>
<authors>Phara0h</authors>
<projectUrl>https://github.com/Phara0h/WaspsWithBazookas</projectUrl>
<licenseUrl>https://github.com/Phara0h/WaspsWithBazookas/blob/main/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectSourceUrl>https://github.com/Phara0h/WaspsWithBazookas</projectSourceUrl>
<docsUrl>https://github.com/Phara0h/WaspsWithBazookas</docsUrl>
<bugTrackerUrl>https://github.com/Phara0h/WaspsWithBazookas/issues</bugTrackerUrl>
<tags>waspswithbazookas load-testing http-testing distributed-testing rust</tags>
<summary>Distributed HTTP/S load testing tool with cluster-based architecture</summary>
<description>
WaspsWithBazookas is your ultimate distributed load testing weapon.
Think of it as having an army of angry wasps, each armed with rocket launchers,
ready to absolutely obliterate your servers with HTTP requests.
</description>
<releaseNotes>https://github.com/Phara0h/WaspsWithBazookas/releases</releaseNotes>
</metadata>
<files>
<file src="tools\**" target="tools" />
</files>
</package>
"@ | Out-File -FilePath "automatic/waspswithbazookas/waspswithbazookas.nuspec" -Encoding UTF8
# Update version in nuspec
(Get-Content "automatic/waspswithbazookas/waspswithbazookas.nuspec") -replace '<version>.*</version>', "<version>$VERSION</version>" | Set-Content "automatic/waspswithbazookas/waspswithbazookas.nuspec"
# Update checksum in chocolateyInstall.ps1
(Get-Content "automatic/waspswithbazookas/tools/chocolateyInstall.ps1") -replace '\$checksum = ''.*''', "`$checksum = '${{ steps.sha256.outputs.sha256 }}'" | Set-Content "automatic/waspswithbazookas/tools/chocolateyInstall.ps1"
# Update URL in chocolateyInstall.ps1
(Get-Content "automatic/waspswithbazookas/tools/chocolateyInstall.ps1") -replace 'https://github.com/Phara0h/WaspsWithBazookas/releases/download/.*/waspswithbazookas-windows-x86_64.tar.gz', "https://github.com/Phara0h/WaspsWithBazookas/releases/download/$VERSION/waspswithbazookas-windows-x86_64.tar.gz" | Set-Content "automatic/waspswithbazookas/tools/chocolateyInstall.ps1"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
repository: chocolatey-community/chocolatey-packages
token: ${{ secrets.CHOCOLATEY_API_KEY }}
path: chocolatey-packages
commit-message: "Update waspswithbazookas to ${{ steps.sha256.outputs.version || github.event.release.tag_name || github.ref_name }}"
title: "Update waspswithbazookas to ${{ steps.sha256.outputs.version || github.event.release.tag_name || github.ref_name }}"
body: |
Updates waspswithbazookas to version ${{ steps.sha256.outputs.version || github.event.release.tag_name || github.ref_name }}
- Updated version number
- Updated download URL
- Updated SHA256 checksum
- Added proper Chocolatey package structure
Created by GitHub Actions workflow
branch: update-waspswithbazookas-${{ steps.sha256.outputs.version || github.event.release.tag_name || github.ref_name }}
delete-branch: true