Skip to content

Commit

Permalink
GitHub: Added StoreBroker PowerShell script (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5bfa authored Aug 6, 2024
1 parent d137c63 commit aae3e20
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
40 changes: 29 additions & 11 deletions .github/workflows/cd-store.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ jobs:
configuration: [Release] # Consider to use Store
platform: [x64]
env:
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
CONFIGURATION: '${{ matrix.configuration }}'
PLATFORM: '${{ matrix.platform }}'
WORKING_DIR: '${{ github.workspace }}' # Default: 'D:\a\FluentHub\FluentHub'
SOLUTION_PATH: '${{ github.workspace }}\FluentHub.sln'
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\FluentHub.Package'
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\FluentHub.Package\FluentHub.Package.wapproj'
APP_CREDENTIALS_PATH: '${{ github.workspace }}\src\FluentHub.App\AppCredentials.config'
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
APPX_BUNDLE_PLATFORMS: 'x64|arm64'
CONFIGURATION: '${{ matrix.configuration }}'
PLATFORM: '${{ matrix.platform }}'
WORKING_DIR: '${{ github.workspace }}' # Default: 'D:\a\FluentHub\FluentHub'
SOLUTION_PATH: '${{ github.workspace }}\FluentHub.sln'
PACKAGE_PROJECT_DIR: '${{ github.workspace }}\src\FluentHub.Package'
PACKAGE_PROJECT_PATH: '${{ github.workspace }}\src\FluentHub.Package\FluentHub.Package.wapproj'
APP_CREDENTIALS_PATH: '${{ github.workspace }}\src\FluentHub.App\AppCredentials.config'
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
APPX_PACKAGE_DIR: '${{ github.workspace }}\artifacts\AppxPackages'
STORE_BROKER_STAGING_DIR: '${{ github.workspace }}\.github\configurations\MicrosoftStore\submission'
STORE_BROKER_CONFIG_PATH: '${{ github.workspace }}\.github\configurations\MicrosoftStore\config.json'

steps:

Expand Down Expand Up @@ -83,4 +85,20 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: 'Appx Packages (${{ env.CONFIGURATION }}, ${{ env.PLATFORM }})'
path: ${{ env.ARTIFACTS_STAGING_DIR }}
path: ${{ env.ARTIFACTS_STAGING_DIR }}

- name: Publish to Microsoft Store
shell: pwsh
run: |
. './scripts/SubmitTo-MicrosoftStore.ps1' `
-SubmissionDirPath=$env:STORE_BROKER_STAGING_DIR `
-BrokerConfigPath=$env:STORE_BROKER_CONFIG_PATH `
-AppxPackagePath=$env:ARTIFACTS_STAGING_DIR `
-PartnerCenterClientId=$env:PARTNER_CENTER_CLIENT_ID `
-PartnerCenterClientSecret=$env:PARTNER_CENTER_CLIENT_SECRET `
-PartnerCenterStoreId=9NKB9HX8RJZ3 `
-PartnerCenterTenantId=$env:PARTNER_CENTER_TENANT_ID
env:
PARTNER_CENTER_CLIENT_ID: ${{ secrets.PARTNER_CENTER_CLIENT_ID }}
PARTNER_CENTER_CLIENT_SECRET: ${{ secrets.PARTNER_CENTER_CLIENT_SECRET }}
PARTNER_CENTER_TENANT_ID: ${{ secrets.PARTNER_CENTER_TENANT_ID }}
31 changes: 31 additions & 0 deletions scripts/SubmitTo-MicrosoftStore.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) 2024 0x5BFA
# Licensed under the MIT License. See the LICENSE.

param(
[string]$SubmissionDirPath = "",
[string]$StoreBrokerConfigPath = "",
[string]$AppxPackagePath = "",
[string]$PartnerCenterClientId = "",
[string]$PartnerCenterClientSecret = "",
[string]$PartnerCenterStoreId = "",
[string]$PartnerCenterTenantId = ""
)

# Setup
Set-ExecutionPolicy RemoteSigned -Force
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-Module -Name StoreBroker

# Authenticate StoreBroker
$UserName = $PartnerCenterClientId
$Password = ConvertTo-SecureString $PartnerCenterClientSecret
$Credential = New-Object System.Management.Automation.PSCredential ($UserName, $Password)
Set-StoreBrokerAuthentication -TenantId $PartnerCenterTenantId -Credential $Credential

# Prepare the submission package
New-SubmissionPackage -ConfigPath $StoreBrokerConfigPath -AppxPath $AppxPackagePath -OutPath $SubmissionDirPath -OutName 'submission'
$SubmissionDataPath = Join-Path -Path $SubmissionDirPath -ChildPath 'submission.json'
$SubmissionPackagePath = Join-Path -Path $SubmissionDirPath -ChildPath 'submission.zip'

# Upload the package
Update-ApplicationSubmission -Verbose -ReplacePackages -AppId $PartnerCenterStoreId -SubmissionDataPath $SubmissionDataPath -PackagePath $SubmissionPackagePath -AutoCommit -Force -NoStatus

0 comments on commit aae3e20

Please sign in to comment.