# Publica una versión al subir una etiqueta semántica (v1.2.3, v1.3.0-rc.1...): # # git tag v1.1.0 && git push origin v1.1.0 # # También puede ejecutarse a mano desde la pestaña Actions ("Run workflow"): en # ese caso prueba y compila, deja los ejecutables y el asistente de instalación # como artefactos del workflow, prueba install.ps1 con la última versión # publicada y NO publica nada. name: Release on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+*" workflow_dispatch: permissions: contents: read concurrency: group: release-${{ github.ref }} cancel-in-progress: false jobs: # Formato, go vet y pruebas: los mismos pasos que en cada push (ci.yml). test: name: Pruebas uses: ./.github/workflows/ci.yml build: name: Compilar ejecutables needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7 with: go-version: stable - name: Compilar para Windows (amd64 y arm64) env: CGO_ENABLED: "0" run: | if [ "$GITHUB_REF_TYPE" = "tag" ]; then version="${GITHUB_REF_NAME#v}" else version="0.0.0-dev.${GITHUB_SHA::7}" fi echo "Versión: $version" # Nombre del producto y versión que Windows muestra en Propiedades → # Detalles (SignPath los exige en los ejecutables firmados). go build # incluye automáticamente los rsrc_windows_.syso generados. # GOOS solo se define al compilar: go-winres debe ejecutarse en Linux. go run github.com/tc-hib/go-winres@v0.3.3 simply \ --arch amd64,arm64 \ --manifest none \ --product-name fast-folder-cli \ --product-version "$version" \ --file-version "$version" \ --file-description "Búsqueda ultrarrápida de carpetas para Windows" \ --copyright "Copyright (c) 2026 Anthony" \ --original-filename fast-folder-cli.exe mkdir -p dist for arch in amd64 arm64; do GOOS=windows GOARCH=$arch go build -trimpath -ldflags "-s -w -X main.version=$version" \ -o "dist/fast-folder-cli-windows-$arch.exe" . done # Scripts del comando fcd: se publican junto a los ejecutables para # que install.ps1 los descargue y verifique. cp shell/fcd.ps1 shell/fcd.cmd dist/ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: binaries path: dist/ if-no-files-found: error installer: name: Crear asistente de instalación needs: build runs-on: windows-latest env: # Versión fija de Inno Setup y su SHA-256, para compilaciones reproducibles # que no dependan de lo que traiga preinstalado el runner. INNO_VERSION: 7.1.0 INNO_SHA256: 0362a383ed217d4c4239b5933866dd96d3eb2102737da92f80f6057a4b40df2f steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: name: binaries path: dist - name: Instalar Inno Setup run: | $tag = 'is-' + $env:INNO_VERSION.Replace('.', '_') $exe = "$env:RUNNER_TEMP\innosetup.exe" Invoke-WebRequest "https://github.com/jrsoftware/issrc/releases/download/$tag/innosetup-$env:INNO_VERSION-x64.exe" -OutFile $exe $hash = (Get-FileHash $exe -Algorithm SHA256).Hash if ($hash -ne $env:INNO_SHA256) { throw "SHA-256 inesperado para Inno Setup: $hash" } Start-Process $exe -Wait -ArgumentList "/VERYSILENT /SUPPRESSMSGBOXES /CURRENTUSER /PORTABLE=1 /NOICONS /DIR=`"$env:RUNNER_TEMP\inno`"" if (-not (Test-Path "$env:RUNNER_TEMP\inno\ISCC.exe")) { throw 'No se pudo instalar Inno Setup' } - name: Calcular la version run: | if ($env:GITHUB_REF_TYPE -eq 'tag') { $version = $env:GITHUB_REF_NAME.TrimStart('v') } else { $version = "0.0.0-dev.$($env:GITHUB_SHA.Substring(0, 7))" } "APP_VERSION=$version" >> $env:GITHUB_ENV - name: Comprobar los metadatos de los ejecutables run: | foreach ($exe in Get-ChildItem dist\*.exe) { $info = $exe.VersionInfo Write-Host "$($exe.Name): $($info.ProductName) $($info.ProductVersion) ($($info.FileVersionRaw))" if ($info.ProductName -ne 'fast-folder-cli' -or $info.ProductVersion -ne $env:APP_VERSION) { throw "Metadatos incorrectos en $($exe.Name)" } } - name: Compilar el asistente run: | & "$env:RUNNER_TEMP\inno\ISCC.exe" "/DAppVersion=$env:APP_VERSION" installer\fast-folder-cli.iss if ($LASTEXITCODE -ne 0) { throw "ISCC termino con codigo $LASTEXITCODE" } # Inno Setup rellena con espacios los textos de la version. $info = (Get-Item dist\fast-folder-cli-setup.exe).VersionInfo $name = $info.ProductName.Trim() $productVersion = $info.ProductVersion.Trim() Write-Host "fast-folder-cli-setup.exe: $name $productVersion" if ($name -ne 'fast-folder-cli' -or $productVersion -ne $env:APP_VERSION) { throw 'Metadatos incorrectos en fast-folder-cli-setup.exe' } - name: Probar instalación y desinstalación silenciosas run: | $dir = "$env:LOCALAPPDATA\Programs\fast-folder-cli" $p = Start-Process dist\fast-folder-cli-setup.exe -Wait -PassThru -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /LOG=setup.log' if ($p.ExitCode -ne 0) { Get-Content setup.log; throw "El asistente termino con codigo $($p.ExitCode)" } & "$dir\fast-folder-cli.exe" --version if ($LASTEXITCODE -ne 0) { throw 'El ejecutable instalado no funciona' } & "$dir\fast.exe" --version if ($LASTEXITCODE -ne 0) { throw 'El atajo fast no funciona' } if (((Get-ItemProperty HKCU:\Environment).Path -split ';') -notcontains $dir) { throw 'La carpeta no se agrego al PATH del usuario' } foreach ($f in 'fcd.ps1', 'fcd.cmd') { if (-not (Test-Path "$dir\$f")) { throw "El asistente no instalo $f" } } $menu = 'HKCU:\Software\Classes\Directory\Background\shell\fast-folder-cli' $command = (Get-ItemProperty "$menu\command").'(default)' if ($command -ne "`"$dir\fast-folder-cli.exe`" --path `"%V`"") { throw "Comando inesperado en el menu contextual: $command" } # El desinstalador se copia a %TEMP% y continua en segundo plano. Start-Process "$dir\unins000.exe" -Wait -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART' for ($i = 0; $i -lt 60 -and (Test-Path $dir); $i++) { Start-Sleep -Milliseconds 500 } if (Test-Path $dir) { throw 'La desinstalacion no elimino la carpeta' } if (((Get-ItemProperty HKCU:\Environment).Path -split ';') -contains $dir) { throw 'La carpeta sigue en el PATH tras desinstalar' } if (Test-Path $menu) { throw 'El menu contextual sigue tras desinstalar' } Write-Host 'Instalacion y desinstalacion correctas.' - name: Probar install.ps1 con esta compilacion run: | # Como en la publicacion: las sumas SHA-256 junto a los archivos. Get-ChildItem dist\*.exe, dist\*.ps1, dist\*.cmd | ForEach-Object { "$((Get-FileHash $_ -Algorithm SHA256).Hash.ToLower()) $($_.Name)" } | Set-Content -Encoding ascii dist\checksums.txt $installer = [scriptblock]::Create((Get-Content -Raw -Encoding UTF8 ./install.ps1)) & $installer -SourceDir dist $dir = "$env:LOCALAPPDATA\Programs\fast-folder-cli" foreach ($f in 'fast-folder-cli.exe', 'fast.exe', 'fcd.ps1', 'fcd.cmd') { if (-not (Test-Path "$dir\$f")) { throw "install.ps1 no instalo $f" } } $menu = 'HKCU:\Software\Classes\Directory\shell\fast-folder-cli' $command = (Get-ItemProperty "$menu\command").'(default)' if ($command -ne "`"$dir\fast-folder-cli.exe`" --path `"%V`"") { throw "Comando inesperado en el menu contextual: $command" } & $installer -Uninstall if (Test-Path $dir) { throw 'La desinstalacion no elimino la carpeta' } if (Test-Path $menu) { throw 'El menu contextual sigue tras desinstalar' } Write-Host 'install.ps1 correcto.' - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: name: installer path: dist/fast-folder-cli-setup.exe if-no-files-found: error release: name: Publicar release needs: [build, installer] if: github.ref_type == 'tag' runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: fetch-depth: 0 # historial y etiquetas completos para el changelog - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: path: dist merge-multiple: true # ejecutables y asistente en la misma carpeta - name: Generar sumas SHA-256 working-directory: dist run: | sha256sum *.exe *.ps1 *.cmd > checksums.txt cat checksums.txt - name: Generar notas de la versión run: | bash .github/scripts/release-notes.sh "$GITHUB_REF_NAME" \ "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" > notes.md cat notes.md - name: Crear release en GitHub env: GH_TOKEN: ${{ github.token }} run: | # Las etiquetas con sufijo (v1.2.0-rc.1) se publican como prerelease. if [[ "$GITHUB_REF_NAME" == *-* ]]; then kind=--prerelease else kind=--latest fi gh release create "$GITHUB_REF_NAME" dist/* \ --verify-tag "$kind" \ --title "fast-folder-cli $GITHUB_REF_NAME" \ --notes-file notes.md install-test: name: Probar instalador (${{ matrix.shell }}) needs: release # Tras publicar, instala la versión recién publicada. En las ejecuciones # manuales (sin release) prueba el instalador con la última versión. if: ${{ !cancelled() && (needs.release.result == 'success' || github.event_name == 'workflow_dispatch') }} runs-on: windows-latest strategy: matrix: shell: [powershell, pwsh] # Windows PowerShell 5.1 y PowerShell 7 defaults: run: shell: ${{ matrix.shell }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 - name: Instalar, usar y desinstalar run: | # Igual que "irm ... | iex": el script se lee como texto UTF-8 y se # ejecuta como scriptblock. (Solo ASCII en este bloque: Windows # PowerShell 5.1 puede leer el script temporal del runner como ANSI.) $installer = [scriptblock]::Create((Get-Content -Raw -Encoding UTF8 ./install.ps1)) $version = 'latest' if ($env:GITHUB_REF_TYPE -eq 'tag') { $version = $env:GITHUB_REF_NAME } & $installer -Version $version $installed = fast-folder-cli --version if ($env:GITHUB_REF_TYPE -eq 'tag' -and $installed -ne "fast-folder-cli $($version.TrimStart('v'))") { throw "Version inesperada: $installed" } $viaAlias = fast --version if ($viaAlias -ne $installed) { throw "El atajo fast no funciona: $viaAlias" } fast-folder-cli -n search -p . if ($LASTEXITCODE -ne 0) { throw "La busqueda de prueba fallo (codigo $LASTEXITCODE)" } # fcd y el menu contextual llegaron en la 1.2.0: se comprueban al # publicar (las ejecuciones manuales instalan la ultima version, que # puede ser anterior). $menu = 'HKCU:\Software\Classes\Directory\Background\shell\fast-folder-cli' if ($env:GITHUB_REF_TYPE -eq 'tag') { if (-not (Get-Command fcd -ErrorAction SilentlyContinue)) { throw 'El comando fcd no esta disponible' } if (-not (Test-Path $menu)) { throw 'No se agrego el menu contextual' } } & $installer -Uninstall if (Get-Command fast-folder-cli, fast, fcd -ErrorAction SilentlyContinue) { throw 'fast-folder-cli sigue disponible tras desinstalar' } if (Test-Path $menu) { throw 'El menu contextual sigue tras desinstalar' }