diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d707ea1..ab03542 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ permissions: jobs: release: - uses: open-cli-collective/.github/.github/workflows/release.yml@v1 + uses: open-cli-collective/.github/.github/workflows/release.yml@6ee65fbc893f13b8876f013ec0661219a3e18269 with: # tag push is live (false); workflow_dispatch honors the checkbox. Compare # against both true and 'true' because a workflow_dispatch boolean input diff --git a/.github/workflows/test-winget.yml b/.github/workflows/test-winget.yml index 2fcb5ab..655270e 100644 --- a/.github/workflows/test-winget.yml +++ b/.github/workflows/test-winget.yml @@ -17,6 +17,23 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install current WinGet validator + shell: pwsh + run: | + $bundle = Join-Path $env:RUNNER_TEMP "Microsoft.DesktopAppInstaller.msixbundle" + Invoke-WebRequest "https://github.com/microsoft/winget-cli/releases/download/v1.29.380/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle" -OutFile $bundle + $expected = "65dea9c01ce08ee7b763366b27c0e651f97db857c11ca9b9c301826c10092f2e" + if ((Get-FileHash $bundle -Algorithm SHA256).Hash -ne $expected) { throw "WinGet bundle checksum mismatch" } + $deps = Join-Path $env:RUNNER_TEMP "winget-dependencies.zip" + Invoke-WebRequest "https://github.com/microsoft/winget-cli/releases/download/v1.29.380/DesktopAppInstaller_Dependencies.zip" -OutFile $deps + $depsHash = "ba875afe9d190f61218985ac0292a99d1db710bf93e13c68944ca9d89f0d82d1" + if ((Get-FileHash $deps -Algorithm SHA256).Hash -ne $depsHash) { throw "WinGet dependencies checksum mismatch" } + $depsDir = Join-Path $env:RUNNER_TEMP "winget-dependencies" + Expand-Archive -Path $deps -DestinationPath $depsDir + $dependencyPaths = @(Get-ChildItem (Join-Path $depsDir "x64") -Filter "*.appx" | ForEach-Object FullName) + Add-AppxPackage -Path $bundle -DependencyPath $dependencyPaths + winget --version + - name: Validate manifest schema shell: pwsh run: | diff --git a/.github/workflows/winget-publish.yml b/.github/workflows/winget-publish.yml index 4f5577d..b58b78a 100644 --- a/.github/workflows/winget-publish.yml +++ b/.github/workflows/winget-publish.yml @@ -8,198 +8,22 @@ on: required: true type: string +permissions: + contents: read + jobs: publish: runs-on: windows-latest steps: - uses: actions/checkout@v4 - - - name: Validate release exists - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - run: | - $release = gh release view "v${{ inputs.version }}" --repo ${{ github.repository }} --json tagName 2>&1 - if ($LASTEXITCODE -ne 0) { - Write-Error "Release v${{ inputs.version }} not found" - exit 1 - } - Write-Host "Found release v${{ inputs.version }}" - - - name: Install wingetcreate - shell: pwsh - run: | - Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe - - - name: Ensure winget-pkgs fork - shell: pwsh - env: - GH_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} - run: | - $owner = gh api user --jq .login - $repo = "$owner/winget-pkgs" - - gh api "repos/$repo" --silent 2>$null - if ($LASTEXITCODE -ne 0) { - Write-Host "Creating fork $repo" - gh api -X POST repos/microsoft/winget-pkgs/forks -F default_branch_only=true --silent - - $forkReady = $false - for ($i = 0; $i -lt 12; $i++) { - gh api "repos/$repo" --silent 2>$null - if ($LASTEXITCODE -eq 0) { - $forkReady = $true - break - } - Start-Sleep -Seconds 5 - } - - if (-not $forkReady) { - Write-Error "Unable to access $repo after creating fork" - exit 1 - } - } else { - $parent = gh api "repos/$repo" --jq '.parent.full_name // ""' - if ($parent -ne "microsoft/winget-pkgs") { - Write-Error "$repo exists but is not a fork of microsoft/winget-pkgs" - exit 1 - } - } - - Write-Host "Using fork $repo" - - - name: Check if manifest exists in winget-pkgs - id: check-manifest - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api repos/microsoft/winget-pkgs/contents/manifests/o/OpenCLICollective/slack-chat-cli --silent 2>$null - if ($LASTEXITCODE -eq 0) { - Write-Host "Manifest exists - will use wingetcreate update" - echo "exists=true" >> $env:GITHUB_OUTPUT - } else { - Write-Host "Manifest does not exist - will create a new manifest" - echo "exists=false" >> $env:GITHUB_OUTPUT - } - - - name: Get checksums from release - shell: pwsh - env: - GH_TOKEN: ${{ github.token }} - run: | - gh release download "v${{ inputs.version }}" --repo ${{ github.repository }} --pattern "checksums.txt" --dir . - - $checksums = Get-Content checksums.txt - $x64Hash = ($checksums | Select-String "windows_amd64.zip").Line.Split()[0] - $arm64Hash = ($checksums | Select-String "windows_arm64.zip").Line.Split()[0] - - Write-Host "x64 SHA256: $x64Hash" - Write-Host "arm64 SHA256: $arm64Hash" - - echo "X64_HASH=$x64Hash" >> $env:GITHUB_ENV - echo "ARM64_HASH=$arm64Hash" >> $env:GITHUB_ENV - - - name: Update manifest (existing package) - if: steps.check-manifest.outputs.exists == 'true' - shell: pwsh - env: - WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} - run: | - $version = "${{ inputs.version }}" - $x64 = "https://github.com/open-cli-collective/slack-chat-api/releases/download/v${version}/slck_v${version}_windows_amd64.zip" - $arm64 = "https://github.com/open-cli-collective/slack-chat-api/releases/download/v${version}/slck_v${version}_windows_arm64.zip" - - Write-Host "Updating existing manifest to version $version" - ./wingetcreate.exe update OpenCLICollective.slack-chat-cli --version $version --urls $x64 $arm64 --out . - - - name: Create manifest (new package) - if: steps.check-manifest.outputs.exists == 'false' - shell: pwsh - env: - WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} - run: | - $version = "${{ inputs.version }}" - $manifestDir = "manifests/o/OpenCLICollective/slack-chat-cli/$version" - New-Item -ItemType Directory -Path $manifestDir -Force | Out-Null - - # Update version manifest - $versionManifest = Get-Content "packaging/winget/OpenCLICollective.slack-chat-cli.yaml" -Raw - $versionManifest = $versionManifest -replace "0\.0\.0", $version - Set-Content "$manifestDir/OpenCLICollective.slack-chat-cli.yaml" $versionManifest - - # Update locale manifest - $localeManifest = Get-Content "packaging/winget/OpenCLICollective.slack-chat-cli.locale.en-US.yaml" -Raw - $localeManifest = $localeManifest -replace "0\.0\.0", $version - Set-Content "$manifestDir/OpenCLICollective.slack-chat-cli.locale.en-US.yaml" $localeManifest - - # Update installer manifest with version and real checksums - $installerManifest = Get-Content "packaging/winget/OpenCLICollective.slack-chat-cli.installer.yaml" -Raw - $installerManifest = $installerManifest -replace "0\.0\.0", $version - $regex = [regex]"0{64}" - $installerManifest = $regex.Replace($installerManifest, $env:X64_HASH, 1) - $installerManifest = $regex.Replace($installerManifest, $env:ARM64_HASH, 1) - Set-Content "$manifestDir/OpenCLICollective.slack-chat-cli.installer.yaml" $installerManifest - - Write-Host "Generated manifests:" - Get-ChildItem $manifestDir | ForEach-Object { Write-Host " $_" } - - Write-Host "`nValidating manifests..." - winget validate --manifest $manifestDir - if ($LASTEXITCODE -ne 0) { - Write-Error "Manifest validation failed" - exit 1 - } - Write-Host "Validation passed!" - - Write-Host "`nManifests are ready for PR submission." - - - name: Submit manifest PR - shell: pwsh - env: - GH_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }} - run: | - $version = "${{ inputs.version }}" - $packageId = "OpenCLICollective.slack-chat-cli" - $manifestPath = "manifests/o/OpenCLICollective/slack-chat-cli/$version" - - if (-not (Test-Path $manifestPath)) { - Write-Error "Expected manifest path not found: $manifestPath" - exit 1 - } - - $owner = gh api user --jq .login - $repo = "$owner/winget-pkgs" - $upstreamBranch = gh api repos/microsoft/winget-pkgs --jq .default_branch - $branch = "open-cli-collective-slack-chat-cli-$version-${{ github.run_id }}-${{ github.run_attempt }}" - $branch = $branch -replace '[^A-Za-z0-9._/-]', '-' - - gh auth setup-git - gh repo clone $repo winget-pkgs-fork -- --filter=blob:none --depth=1 - - Set-Location winget-pkgs-fork - git checkout -b $branch - - $destination = Join-Path (Get-Location) $manifestPath - New-Item -ItemType Directory -Path $destination -Force | Out-Null - Copy-Item -Path (Join-Path $env:GITHUB_WORKSPACE "$manifestPath/*") -Destination $destination -Recurse -Force - - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add ($manifestPath -replace '\\', '/') - - if (-not (git status --porcelain)) { - Write-Error "No manifest changes detected" - exit 1 - } - - git commit -m "$packageId version $version" - git push --force-with-lease origin $branch - - Set-Location $env:GITHUB_WORKSPACE - gh pr create ` - --repo microsoft/winget-pkgs ` - --head "${owner}:$branch" ` - --base $upstreamBranch ` - --title "$packageId version $version" ` - --body "Automated winget manifest update for $packageId version $version." + - name: Submit WinGet package + uses: open-cli-collective/.github/actions/winget-submit@6ee65fbc893f13b8876f013ec0661219a3e18269 + with: + package-id: OpenCLICollective.slack-chat-cli + version: ${{ inputs.version }} + final-tag: v${{ inputs.version }} + repo: ${{ github.repository }} + working-directory: . + bootstrap: "true" + github-token: ${{ github.token }} + winget-token: ${{ secrets.WINGET_GITHUB_TOKEN }} diff --git a/packaging/winget/OpenCLICollective.slack-chat-cli.installer.yaml b/packaging/winget/OpenCLICollective.slack-chat-cli.installer.yaml index 71c16e5..6eb87b8 100644 --- a/packaging/winget/OpenCLICollective.slack-chat-cli.installer.yaml +++ b/packaging/winget/OpenCLICollective.slack-chat-cli.installer.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.10.0.schema.json +# yaml-language-server: $schema=https://aka.ms/winget-manifest.installer.1.28.0.schema.json PackageIdentifier: OpenCLICollective.slack-chat-cli PackageVersion: 0.0.0 @@ -15,4 +15,4 @@ Installers: InstallerUrl: https://github.com/open-cli-collective/slack-chat-api/releases/download/v0.0.0/slck_v0.0.0_windows_arm64.zip InstallerSha256: 0000000000000000000000000000000000000000000000000000000000000000 ManifestType: installer -ManifestVersion: 1.10.0 +ManifestVersion: 1.28.0 diff --git a/packaging/winget/OpenCLICollective.slack-chat-cli.locale.en-US.yaml b/packaging/winget/OpenCLICollective.slack-chat-cli.locale.en-US.yaml index cf440c7..d94360d 100644 --- a/packaging/winget/OpenCLICollective.slack-chat-cli.locale.en-US.yaml +++ b/packaging/winget/OpenCLICollective.slack-chat-cli.locale.en-US.yaml @@ -1,4 +1,4 @@ -# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.10.0.schema.json +# yaml-language-server: $schema=https://aka.ms/winget-manifest.defaultLocale.1.28.0.schema.json PackageIdentifier: OpenCLICollective.slack-chat-cli PackageVersion: 0.0.0 @@ -23,4 +23,4 @@ Tags: - chat ReleaseNotesUrl: https://github.com/open-cli-collective/slack-chat-api/releases ManifestType: defaultLocale -ManifestVersion: 1.10.0 +ManifestVersion: 1.28.0 diff --git a/packaging/winget/OpenCLICollective.slack-chat-cli.yaml b/packaging/winget/OpenCLICollective.slack-chat-cli.yaml index d0f37b2..1bb1361 100644 --- a/packaging/winget/OpenCLICollective.slack-chat-cli.yaml +++ b/packaging/winget/OpenCLICollective.slack-chat-cli.yaml @@ -1,7 +1,7 @@ -# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.10.0.schema.json +# yaml-language-server: $schema=https://aka.ms/winget-manifest.version.1.28.0.schema.json PackageIdentifier: OpenCLICollective.slack-chat-cli PackageVersion: 0.0.0 DefaultLocale: en-US ManifestType: version -ManifestVersion: 1.10.0 +ManifestVersion: 1.28.0