Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub: Add StoreBroker PowerShell script #497

Merged
merged 18 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading