Skip to content

Commit f0f40dc

Browse files
committed
fix: simplify and enable direct Chocolatey publishing via workflow
1 parent d54c1d8 commit f0f40dc

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -243,42 +243,20 @@ jobs:
243243
update-chocolatey:
244244
needs: [release, publish-pypi]
245245
runs-on: windows-latest
246+
if: vars.CHOCOLATEY_PUBLISH_ENABLED == 'true' # Only run if publishing to Chocolatey is enabled
246247
steps:
247-
- uses: actions/checkout@v4
248-
with:
249-
repository: ${{ github.repository_owner }}/chocolatey-packages
250-
token: ${{ secrets.CHOCOLATEY_REPO_TOKEN }}
251-
path: chocolatey-packages
252-
253-
- name: Get version
254-
id: get_version
255-
shell: bash
256-
run: |
257-
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
258-
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
259-
else
260-
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
261-
fi
262-
263-
- name: Update Chocolatey package
264-
shell: powershell
248+
- name: Find built nupkg
249+
id: find_nupkg
265250
run: |
266-
$version = "${{ steps.get_version.outputs.version }}"
267-
$packagePath = "chocolatey-packages/mdbub"
268-
269-
# Update nuspec file
270-
$nuspecPath = "$packagePath/mdbub.nuspec"
271-
(Get-Content $nuspecPath) -replace '<version>.*</version>', "<version>$version</version>" | Set-Content $nuspecPath
251+
$pkg = Get-ChildItem -Path . -Recurse -Filter "mdbub.*.nupkg" | Select-Object -First 1
252+
if ($null -eq $pkg) { Write-Error "No .nupkg file found!"; exit 1 }
253+
echo "::set-output name=path::$($pkg.FullName)"
254+
shell: pwsh
272255

273-
# Update install script
274-
$installPath = "$packagePath/tools/chocolateyinstall.ps1"
275-
$downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v$version/mdbub-windows.exe"
276-
(Get-Content $installPath) -replace '\$url\s*=\s*"[^"]*"', "`$url = `"$downloadUrl`"" | Set-Content $installPath
256+
- name: Push to Chocolatey
257+
run: choco push ${{ steps.find_nupkg.outputs.path }} --api-key ${{ secrets.CHOCOLATEY_REPO_TOKEN }} --source https://push.chocolatey.org/
258+
shell: pwsh
277259

278-
- name: Commit and push changes
279-
shell: bash
280-
working-directory: chocolatey-packages
281-
run: |
282260
git config --local user.email "action@github.com"
283261
git config --local user.name "GitHub Action"
284262
git add .

0 commit comments

Comments
 (0)