endlessm / endless-key-app

Endless Key app for Windows (formerly known as kolibri-app)
https://www.endlessos.org/key
MIT License
2 stars 1 forks source link

Fix MS Store Broker Authentication setting failure #114

Closed starnight closed 1 year ago

starnight commented 1 year ago

The CI Create and push the Application Payload to Package Flight on Microsoft store job uses Microsoft's StoreBroker to submit a package to Microsoft store's Alhpha Test Flight, but it fails at Set-StoreBrokerAuthentication now.

Here is the log:

##[debug]Evaluating: secrets.MSPARTNER_TENANTID
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MSPARTNER_TENANTID'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.MSPARTNER_CLIENTID
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MSPARTNER_CLIENTID'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating: secrets.MSPARTNER_CLIENTPWD
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'MSPARTNER_CLIENTPWD'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Evaluating condition for step: 'Create and push the Application Payload to Package Flight on Microsoft store'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Create and push the Application Payload to Package Flight on Microsoft store
##[debug]Loading inputs
##[debug]Loading env
Run Set-PSRepository PSGallery -InstallationPolicy Trusted
  Set-PSRepository PSGallery -InstallationPolicy Trusted
  Install-Module -Name StoreBroker

  $APP_ID = "9PDLJFW5D4JR"
  $SubmissionRoot = "MSSubmission"

  $PWD = ConvertTo-SecureString $env:MS_CLIENT_PWD -AsPlainText -Force
  $Credentials = New-Object System.Management.Automation.PSCredential ($env:MS_CLIENT_ID, $PWD)
  Set-StoreBrokerAuthentication -TenantId $env:MS_TENANT_ID -Credential $Credentials -Verbose

  New-Item -Path "MSAppPayload" -ItemType Directory

  # Get current config and PDPs from Microsoft store
  New-StoreBrokerConfigFile -Path "MSAppPayload/SBConfig.json" -AppId $APP_ID
  $release_str = Get-Date -Format "yyyyMMdd"
  .\StoreBroker\Extensions\ConvertFrom-ExistingSubmission.ps1 -AppId $APP_ID -Release $release_str -OutPath "MSAppPayload/PDPs"

  # Wipe out the Release string in PDP.xml to avoid the release version folder
  [xml]$xmlDoc = Get-Content "MSAppPayload/PDPs/en-us/PDP.xml"
  $xmlDoc.ProductDescription.Release = ""
  $xmlDoc.Save( "MSAppPayload/PDPs/en-us/PDP.xml" )

  echo "Going to create dummy screenshots for Application Payload creation:"
  $xmlDoc.ProductDescription.ScreenshotCaptions.Caption | ForEach-Object {
    $dummy_screenshot = "MSAppPayload/PDPs/en-us/" + $_.DesktopImage
    echo $dummy_screenshot
    echo NULL > $dummy_screenshot
  }

  New-SubmissionPackage `
    -ConfigPath "MSAppPayload/SBConfig.json" `
    -PDPRootPath "MSAppPayload/PDPs" `
    -ImagesRootPath "MSAppPayload/PDPs" `
    -AppxPath packages/*.appx `
    -MediaFallbackLanguage en-US `
    -OutPath $SubmissionRoot `
    -OutName endlesskey `
    -Verbose

  $FLIGHT_NAME = "Alpha Test Flight"
  $flight = Get-ApplicationFlights -AppId $APP_ID | Where-Object { $_.friendlyName -eq $FLIGHT_NAME }

  Update-ApplicationFlightSubmission `
    -AppId $APP_ID `
    -FlightId $flight.flightId `
    -SubmissionDataPath "$SubmissionRoot/endlesskey.json" `
    -PackagePath "$SubmissionRoot/endlesskey.zip" `
    -ReplacePackages `
    -AutoCommit `
    -Force `
    -Verbose
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    MS_TENANT_ID: ***
    MS_CLIENT_ID: ***
    MS_CLIENT_PWD: ***

##[debug]C:\Program Files\PowerShell\7\pwsh.EXE -command ". 'D:\a\_temp\54358b45-5589-4f63-94e7-cec867[2](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:2)[3](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:3)8[4](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:4)1e.ps1'"
VERBOSE: 2023-0[5](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:5)-23 02:54:4[7](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:7) : runneradmin : [1.21.0] Executing: Set-StoreBrokerAuthentication -TenantId "***" -Credential {"UserName":"***","Password":{"Length":44}} -Verbose:$true
VERBOSE: Performing the operation "Cache tenantId" on target "***".
VERBOSE: Performing the operation "Cache credential" on target "System.Management.Automation.PSCredential".
VERBOSE: Performing the operation "Clear cached access token" on target "".

    Directory: D:\a\endless-key-app\endless-key-app

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----           5/23/2023  2:54 AM                MSAppPayload

|  Elapsed: 0 second(s) [Getting access token]
/  Elapsed: 0 second(s) [Getting access token]
-  Elapsed: 0 second(s) [Getting access token]
\  Elapsed: 0 second(s) [Getting access token]
|  Elapsed: 0 second(s) [Getting access token]
/  Elapsed: 1 second(s) [Getting access token]
-  Elapsed: 1 second(s) [Getting access token]
DONE (FAILED) - Operation took 1 second(s) [Getting access token]
Write-Error: C:\Users\runneradmin\Documents\PowerShell\Modules\StoreBroker\1.21.0\StoreBroker\PackageTool.ps1:373
Line |
 373 |          Write-Log -Message "Encountered problems getting current appl …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | 2023-05-23 02:54:4[9](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:9) : runneradmin : Encountered problems getting current application submission values: 
     | Write-Log: [20](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:20)[23](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:23)-05-23 02:54:49 : runneradmin : Be sure to check that your client id/secret are valid. Response
     | status code does not indicate success: [40](https://github.com/endlessm/endless-key-app/actions/runs/5049617230/jobs/9065651238#step:5:40)1 (Unauthorized).  :

Error: Process completed with exit code 1.
##[debug]Finishing: Create and push the Application Payload to Package Flight on Microsoft store
starnight commented 1 year ago

Visit Automate uploading Endless Key app to Microsoft Store again!

starnight commented 1 year ago

Err, after test on Windows 10 locally, the error comes from New-StoreBrokerConfigFile

starnight commented 1 year ago

Did we change "GitHub Actions"' password on MS store? Or, it has a valid date?

I do not have the special privilege on MS store. @wjt Can you please help check the user "GitHub Actions"'s status on MS store?
In Microsoft Partner Center -> Account settings -> User management -> Azure AD application

Thanks!

wjt commented 1 year ago

Ah! It expired on Saturday, 13 May 2023.

wjt commented 1 year ago

I've generated a new key, updated it in Vault, and am redeploying…

wjt commented 1 year ago

Try again now!

starnight commented 1 year ago

Thanks! The CI is happy now! https://github.com/endlessm/endless-key-app/actions/runs/5049617230

starnight commented 1 year ago

Added maintenance description of "GitHub actions" into Release to Microsoft's Alpha Test Flight.