@@ -411,44 +411,115 @@ jobs:
411411 GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
412412
413413 publish-to-store :
414- needs : [extract-version, build-msix ]
414+ needs : [extract-version, create-release ]
415415 runs-on : windows-latest
416416 steps :
417- - name : Download MSIX package
418- uses : actions/download-artifact@v4
419- with :
420- name : msix-package-v${{ needs.extract-version.outputs.version }}
421- path : downloaded
422-
423- - name : Find MSIX bundle
424- id : package
417+ - name : Download MSIX bundle from Release
425418 shell : pwsh
419+ env :
420+ VERSION : ${{ needs.extract-version.outputs.version }}
421+ REPO : ${{ github.repository }}
422+ GH_TOKEN : ${{ secrets.GH_TOKEN }}
426423 run : |
427- $file = Get-ChildItem downloaded -Recurse | Where-Object { $_.Extension -eq '.msixbundle' } | Select-Object -First 1
428- if (-not $file) {
429- Write-Error "No .msixbundle found in downloaded folder"
430- Get-ChildItem downloaded -Recurse | ForEach-Object { Write-Host $_.FullName }
424+ $version = $env:VERSION
425+ $repo = $env:REPO
426+ $url = "https://github.com/$repo/releases/download/v$version/DevTools_${version}_bundle.msixbundle"
427+ $output = "DevTools_${version}_bundle.msixbundle"
428+
429+ Write-Host "Downloading: $url"
430+ if ($env:GH_TOKEN) {
431+ $headers = @{ Authorization = "token $env:GH_TOKEN" }
432+ Invoke-WebRequest -Uri $url -OutFile $output -Headers $headers -UseBasicParsing
433+ } else {
434+ Invoke-WebRequest -Uri $url -OutFile $output -UseBasicParsing
435+ }
436+
437+ if (Test-Path $output) {
438+ $size = [math]::Round((Get-Item $output).Length / 1MB, 2)
439+ Write-Host "Downloaded: $output ($size MB)"
440+ } else {
441+ Write-Error "Download failed!"
431442 exit 1
432443 }
433- Write-Host "Found bundle: $($file.FullName)"
434- "PACKAGE=$($file.FullName)" >> $env:GITHUB_OUTPUT
435444
436- - name : Verify package
445+ - name : Submit MSIX to Microsoft Store
437446 shell : pwsh
447+ env :
448+ TENANT_ID : ${{ secrets.AZURE_TENANT_ID }}
449+ CLIENT_ID : ${{ secrets.AZURE_CLIENT_ID }}
450+ CLIENT_SECRET : ${{ secrets.AZURE_CLIENT_SECRET }}
451+ PRODUCT_ID : ${{ secrets.STORE_PRODUCT_ID }}
452+ VERSION : ${{ needs.extract-version.outputs.version }}
438453 run : |
439- Write-Host "=== Downloaded files ==="
440- Get-ChildItem downloaded -Recurse | ForEach-Object {
441- Write-Host "$($_.FullName) - $([math]::Round($_.Length / 1MB, 2)) MB"
454+ $tenantId = $env:TENANT_ID
455+ $clientId = $env:CLIENT_ID
456+ $clientSecret = $env:CLIENT_SECRET
457+ $productId = $env:PRODUCT_ID
458+ $version = $env:VERSION
459+ $msixPath = "DevTools_${version}_bundle.msixbundle"
460+
461+ $apiBase = "https://manage.devcenter.microsoft.com/v1.0/my/applications/$productId/submissions"
462+
463+ Write-Host "=== Getting access token ==="
464+ $tokenBody = @{
465+ grant_type = "client_credentials"
466+ client_id = $clientId
467+ client_secret = $clientSecret
468+ scope = "https://manage.devcenter.microsoft.com/.default"
442469 }
470+ $tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" -Method POST -Body $tokenBody
471+ $accessToken = $tokenResponse.access_token
472+ Write-Host "Got access token"
443473
444- - name : Publish To Store
445- uses : microsoft/store-submission@v1
446- with :
447- tenant-id : ${{ secrets.AZURE_TENANT_ID }}
448- client-id : ${{ secrets.AZURE_CLIENT_ID }}
449- client-secret : ${{ secrets.AZURE_CLIENT_SECRET }}
450- app-id : ${{ secrets.STORE_PRODUCT_ID }}
451- package-path : ${{ steps.package.outputs.PACKAGE }}
474+ $headers = @{
475+ Authorization = "Bearer $accessToken"
476+ "Content-Type" = "application/json"
477+ }
478+
479+ Write-Host "`n=== Creating new submission (clones last published) ==="
480+ $createResponse = Invoke-RestMethod -Uri $apiBase -Headers $headers -Method POST
481+ $submissionId = $createResponse.id
482+ $uploadUrl = $createResponse.fileUploadUrl
483+ Write-Host "Submission ID: $submissionId"
484+ Write-Host "Upload URL obtained"
485+
486+ Write-Host "`n=== Updating submission with new package reference ==="
487+ $submissionData = $createResponse
488+ $fileName = Split-Path $msixPath -Leaf
489+ if ($submissionData.psobject.properties.match('packages').Count -gt 0 -and $submissionData.packages) {
490+ $submissionData.packages[0].fileName = $fileName
491+ $submissionData | ConvertTo-Json -Depth 10 | Out-File -FilePath "submission_update.json" -Encoding UTF8
492+ $updateBody = Get-Content "submission_update.json" -Raw
493+ Invoke-RestMethod -Uri "$apiBase/$submissionId" -Headers $headers -Method PUT -Body $updateBody
494+ Write-Host "Submission data updated"
495+ } else {
496+ Write-Host "No packages field to update (using cloned data as-is)"
497+ }
498+
499+ Write-Host "`n=== Packaging MSIX bundle into ZIP ==="
500+ $zipPath = "submission.zip"
501+ Compress-Archive -Path $msixPath -DestinationPath $zipPath
502+ $zipSize = [math]::Round((Get-Item $zipPath).Length / 1MB, 2)
503+ Write-Host "Created: $zipPath ($zipSize MB)"
504+
505+ Write-Host "`n=== Uploading ZIP to Azure Blob Storage ==="
506+ $fileBytes = [System.IO.File]::ReadAllBytes($zipPath)
507+ $blobHeaders = @{
508+ "x-ms-blob-type" = "BlockBlob"
509+ "Content-Type" = "application/zip"
510+ }
511+ Invoke-RestMethod -Uri $uploadUrl -Method PUT -Body $fileBytes -Headers $blobHeaders
512+ Write-Host "Upload completed"
513+
514+ Write-Host "`n=== Committing submission ==="
515+ $commitResponse = Invoke-RestMethod -Uri "$apiBase/$submissionId/commit" -Headers $headers -Method POST
516+ Write-Host "Submission committed"
517+ Write-Host "Status: $($commitResponse.status)"
518+
519+ Write-Host "`n=== Submission successful ==="
520+ Write-Host "Version: $version"
521+ Write-Host "Product ID: $productId"
522+ Write-Host "Submission ID: $submissionId"
452523
453524 - name : Display result
454525 if : always()
0 commit comments