Create choco.yml
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
name: Choco
|
||||
|
||||
on:
|
||||
# release:
|
||||
# types: [published]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Version to publish (e.g. 2.6.0). If empty, use the release tag."
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
choco:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
PACKAGE_ID: rclone-ui
|
||||
CHOCO_DIR: choco
|
||||
INSTALL_SCRIPT: choco/tools/chocolateyinstall.ps1
|
||||
OUTDIR: choco/out
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Show choco version
|
||||
shell: pwsh
|
||||
run: choco --version
|
||||
|
||||
- name: Determine version (from tag or input)
|
||||
id: ver
|
||||
shell: pwsh
|
||||
run: |
|
||||
$v = if ("${{ github.event.release.tag_name }}") { "${{ github.event.release.tag_name }}" }
|
||||
elseif ("${{ inputs.version }}") { "${{ inputs.version }}" }
|
||||
else { throw "No version provided. Use a release tag (vX.Y.Z) or pass inputs.version." }
|
||||
$v = $v.TrimStart('v')
|
||||
"version=$v" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: Download release assets (Rclone.UI_* .exe)
|
||||
uses: robinraju/release-downloader@v1
|
||||
with:
|
||||
repository: ${{ github.repository }}
|
||||
tag: v${{ steps.ver.outputs.version }}
|
||||
fileName: "Rclone.UI_*.exe"
|
||||
out-file-path: dist
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Compute SHA256 and build canonical URLs
|
||||
id: assets
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$v = '${{ steps.ver.outputs.version }}'
|
||||
$repo = '${{ github.repository }}'
|
||||
$base = "https://github.com/$repo/releases/download/v$v"
|
||||
$x64 = Get-ChildItem "dist\*x64*.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
$arm = Get-ChildItem "dist\*arm64*.exe" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if (-not $x64) { throw "x64 EXE not found under dist/ (expected Rclone.UI_x64.exe)" }
|
||||
$x64sha = (Get-FileHash $x64.FullName -Algorithm SHA256).Hash
|
||||
"x64_url=$base/$($x64.Name)" >> $env:GITHUB_OUTPUT
|
||||
"x64_sha=$x64sha" >> $env:GITHUB_OUTPUT
|
||||
if ($arm) {
|
||||
$armsha = (Get-FileHash $arm.FullName -Algorithm SHA256).Hash
|
||||
"arm64_url=$base/$($arm.Name)" >> $env:GITHUB_OUTPUT
|
||||
"arm64_sha=$armsha" >> $env:GITHUB_OUTPUT
|
||||
} else {
|
||||
# If you ever skip arm64, just mirror x64 to keep placeholders filled.
|
||||
"arm64_url=$base/$($x64.Name)" >> $env:GITHUB_OUTPUT
|
||||
"arm64_sha=$x64sha" >> $env:GITHUB_OUTPUT
|
||||
}
|
||||
|
||||
- name: Locate .nuspec under choco/
|
||||
id: nuspec
|
||||
shell: pwsh
|
||||
run: |
|
||||
$n = Get-ChildItem '${{ env.CHOCO_DIR }}' -Filter *.nuspec | Select-Object -First 1 -ExpandProperty FullName
|
||||
if (-not $n) { throw "No .nuspec found under $env:CHOCO_DIR" }
|
||||
"path=$n" >> $env:GITHUB_OUTPUT
|
||||
|
||||
- name: Set nuspec version
|
||||
shell: pwsh
|
||||
run: |
|
||||
$nuspec = "${{ steps.nuspec.outputs.path }}"
|
||||
$xml = [xml](Get-Content $nuspec)
|
||||
$xml.package.metadata.version = '${{ steps.ver.outputs.version }}'
|
||||
$xml.Save((Resolve-Path $nuspec))
|
||||
|
||||
- name: Inject URLs + SHA256 into choco/tools/chocolateyinstall.ps1
|
||||
shell: pwsh
|
||||
run: |
|
||||
$f = "${{ env.INSTALL_SCRIPT }}"
|
||||
if (-not (Test-Path $f)) { throw "Install script not found at $f" }
|
||||
(Get-Content $f) `
|
||||
-replace "(?m)(^\s*\$url_x64\s*=\s*)'.*?'", "`$1'${{ steps.assets.outputs.x64_url }}'" `
|
||||
-replace "(?m)(^\s*\$sha_x64\s*=\s*)'.*?'", "`$1'${{ steps.assets.outputs.x64_sha }}'" `
|
||||
-replace "(?m)(^\s*\$url_arm64\s*=\s*)'.*?'", "`$1'${{ steps.assets.outputs.arm64_url }}'" `
|
||||
-replace "(?m)(^\s*\$sha_arm64\s*=\s*)'.*?'", "`$1'${{ steps.assets.outputs.arm64_sha }}'" `
|
||||
| Set-Content $f -Encoding UTF8
|
||||
|
||||
- name: Pack Chocolatey package
|
||||
shell: pwsh
|
||||
run: |
|
||||
New-Item -ItemType Directory -Force -Path "${{ env.OUTDIR }}" | Out-Null
|
||||
choco pack "${{ steps.nuspec.outputs.path }}" --out "${{ env.OUTDIR }}" --no-progress
|
||||
|
||||
- name: Local install/uninstall
|
||||
shell: pwsh
|
||||
run: |
|
||||
$pkg = Join-Path '${{ env.OUTDIR }}' "${{ env.PACKAGE_ID }}.${{ steps.ver.outputs.version }}.nupkg"
|
||||
choco install ${{ env.PACKAGE_ID }} --source "'${{ env.OUTDIR }}'" -y --no-progress
|
||||
choco uninstall ${{ env.PACKAGE_ID }} -y --no-progress
|
||||
|
||||
# - name: Push to Chocolatey Community Repository
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
# env:
|
||||
# CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
|
||||
# shell: pwsh
|
||||
# run: |
|
||||
# $pkg = Join-Path '${{ env.OUTDIR }}' "${{ env.PACKAGE_ID }}.${{ steps.ver.outputs.version }}.nupkg"
|
||||
# choco apikey --source https://push.chocolatey.org/ --key $env:CHOCO_API_KEY
|
||||
# choco push $pkg --source https://push.chocolatey.org/ --no-progress
|
||||
Reference in New Issue
Block a user