Microsoft Store: submit builds, release notes and screenshots from GitHub Actions

scripts/msstore_submission.py drives the Partner Center submission API
(copy of the last published submission, new MSIX / release notes /
screenshots, commit for certification; --dry-run reads only). The
Windows build job runs it after the Store MSIX (input msstore_submit,
on by default), with release notes from get_latest_changelog.sh
--windows (entries about other platforms left out). Store Metadata
gains platform "windows" for screenshot uploads. Replaces the disabled
msstore CLI steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jonas Acker
2026-11-25 17:28:41 +01:00
parent bb3e5d5ce8
commit 7b4b46a9c9
6 changed files with 386 additions and 21 deletions

View File

@@ -33,6 +33,11 @@ on:
required: false
default: true
type: boolean
msstore_submit:
description: 'Windows: submit the MSIX + release notes to the Microsoft Store for certification'
required: false
default: true
type: boolean
env:
SHOREBIRD_TOKEN: ${{ secrets.SHOREBIRD_TOKEN }}
@@ -276,14 +281,6 @@ jobs:
submodules: recursive
token: ${{ secrets.PAT_TOKEN }}
- name: Configure Microsoft Store CLI
if: false
uses: microsoft/microsoft-store-apppublisher@v1.1
- name: Reconfigure store credentials
if: false
run: msstore reconfigure --tenantId ${{ secrets.AZURE_AD_TENANT_ID }} --sellerId ${{ secrets.SELLER_ID }} --clientId ${{ secrets.AZURE_AD_APPLICATION_CLIENT_ID }} --clientSecret ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
- name: Rename pubspec_overrides_ci.yaml to pubspec_overrides.yaml
uses: ./.github/actions/rename-pubspec-overrides
@@ -354,9 +351,27 @@ jobs:
name: BikeControl Store
path: build/windows/x64/runner/Release/bike_control.store.msix
- name: Publish App package
if: false
run: msstore publish 'build/windows/x64/runner/Release/bike_control.store.msix' -id 9NP42GS03Z26
# Partner Center submission API (scripts/msstore_submission.py): a copy of
# the last published submission with the new MSIX and the Windows release
# notes (entries about other platforms left out, 1500-char Store limit),
# committed for certification. Credentials: Entra app "uploadmsix" in the
# openbikecontrol.onmicrosoft.com tenant, Manager role in Partner Center.
- name: Submit to Microsoft Store
if: inputs.msstore_submit
shell: bash
env:
MSSTORE_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
MSSTORE_CLIENT_ID: ${{ secrets.AZURE_AD_APPLICATION_CLIENT_ID }}
MSSTORE_CLIENT_SECRET: ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
run: |
# get_latest_changelog.sh runs python3; the Windows image only has python.
command -v python3 >/dev/null || cp "$(command -v python)" "$(dirname "$(command -v python)")/python3.exe"
mkdir -p store_notes
./scripts/get_latest_changelog.sh en --windows | ./scripts/truncate_release_notes.sh 1500 > store_notes/msstore.txt
cat store_notes/msstore.txt
python scripts/msstore_submission.py \
--msix build/windows/x64/runner/Release/bike_control.store.msix \
--release-notes store_notes/msstore.txt
- name: Upload Windows artifact
uses: actions/upload-artifact@v4

View File

@@ -8,6 +8,11 @@ name: "Store Metadata"
# submodule pointer is not auto-bumped; do that separately.
# - "upload": push the txt files from prop/store_metadata to the stores
# (texts only, never the binary, screenshots or release notes).
# - platform "windows" + "upload": replace the Microsoft Store listing's
# screenshots with screenshots/store/en/androidTablet10 through
# the Partner Center submission API (scripts/msstore_submission.py),
# committed for certification. The listing is English only; its
# texts stay in Partner Center. "download" does nothing for it.
on:
workflow_dispatch:
inputs:
@@ -16,7 +21,7 @@ on:
required: true
default: both
type: choice
options: [both, android, ios]
options: [both, android, ios, windows]
action:
description: "download (store -> repo) or upload (repo -> store)"
required: true
@@ -181,3 +186,27 @@ jobs:
echo "prop push contended; retry $i"; sleep 4
done
echo "prop push failed after retries"; exit 1
windows:
if: ${{ inputs.platform == 'windows' && inputs.action == 'upload' }}
name: Windows (Microsoft Store screenshots)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Submit screenshots to Microsoft Store
env:
MSSTORE_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
MSSTORE_CLIENT_ID: ${{ secrets.AZURE_AD_APPLICATION_CLIENT_ID }}
MSSTORE_CLIENT_SECRET: ${{ secrets.AZURE_AD_APPLICATION_SECRET }}
run: |
pip install --quiet pillow
python scripts/msstore_submission.py --screenshots screenshots/store/en/androidTablet10

View File

@@ -1,10 +1,13 @@
#!/bin/bash
# Prints the newest changelog entry as plain store "What's New" text.
# Usage: ./scripts/get_latest_changelog.sh [language] [--apple]
# Usage: ./scripts/get_latest_changelog.sh [language] [--apple | --windows]
#
# --apple: for the App Store, which rejects notes that mention other platforms.
# Entries naming Windows, Android, Linux or Google Play are left out (and a
# heading whose entries are all gone with them).
# --windows: for the Microsoft Store. Entries about other platforms only
# (iPhone, iPad, Mac, Android, Linux) are left out; entries naming Windows or
# no platform stay.
#
# With a language (de, es, fr, it, pl, ...), the entry comes from
# changelog/<language>.md, with its "Features:"/"Fixes:" headings translated.
@@ -24,6 +27,7 @@ APPLE=0
for arg in "$@"; do
case "$arg" in
--apple) APPLE=1 ;;
--windows) APPLE=windows ;;
*) LANG_ARG="$arg" ;;
esac
done
@@ -33,7 +37,10 @@ import os, re, sys
root, lang = sys.argv[1], sys.argv[2].split("-")[0].split("_")[0].lower()
apple = sys.argv[3] == "1"
windows = sys.argv[3] == "windows"
OTHER_PLATFORMS = re.compile(r"\b(windows|android|linux|google play)\b", re.IGNORECASE)
NOT_WINDOWS = re.compile(r"\b(iphone|ipad|ios|mac|macos|android|linux|google play|app store)\b", re.IGNORECASE)
WINDOWS = re.compile(r"\bwindows\b", re.IGNORECASE)
HEADINGS = {
"de": {"features": "Neu", "improvements": "Verbessert", "fixes": "Behoben"},
@@ -70,13 +77,13 @@ if lang != "en":
print(f"warning: no {lang} translation of {en_version} in changelog/{lang}.md, using English",
file=sys.stderr)
def drop_other_platforms(lines):
"""Leave out list entries (with their run-on lines) that name another
platform, then headings left without entries."""
def drop_other_platforms(lines, is_other=lambda line: bool(OTHER_PLATFORMS.search(line))):
"""Leave out list entries (with their run-on lines) that [is_other] flags,
then headings left without entries."""
kept, skipping = [], False
for line in lines:
if line.startswith("- "):
skipping = bool(OTHER_PLATFORMS.search(line))
skipping = is_other(line)
elif not line.strip() or line.startswith("**") or line.rstrip().endswith(":"):
skipping = False
if skipping:
@@ -94,6 +101,8 @@ def drop_other_platforms(lines):
if apple:
body = drop_other_platforms(body)
if windows:
body = drop_other_platforms(body, lambda line: bool(NOT_WINDOWS.search(line)) and not WINDOWS.search(line))
out = []
for line in body:

235
scripts/msstore_submission.py Executable file
View File

@@ -0,0 +1,235 @@
#!/usr/bin/env python3
"""Microsoft Store submission through the Partner Center submission API.
Creates a submission for BikeControl (a copy of the last published one),
replaces what was passed, uploads the files and commits it for certification:
python3 scripts/msstore_submission.py \
[--msix build/.../bike_control.store.msix] \
[--release-notes notes.txt] \
[--screenshots screenshots/store/en/androidTablet10] \
[--dry-run]
--msix replaces the app package (the old one is removed).
--release-notes plain text for every listing language (the Store takes
1500 characters; see scripts/get_latest_changelog.sh --windows).
--screenshots replaces the listing's screenshots with the directory's
images, in file-name order. JPEGs are converted to PNG
(needs Pillow), since the Store takes PNG only.
--dry-run reads the last published submission and prints what would
change; creates nothing.
Credentials (an Entra ID app with the Manager role in Partner Center, here
"uploadmsix" in the openbikecontrol.onmicrosoft.com tenant) come from
MSSTORE_TENANT_ID, MSSTORE_CLIENT_ID and MSSTORE_CLIENT_SECRET.
API: https://learn.microsoft.com/windows/uwp/monetize/manage-app-submissions
"""
from __future__ import annotations
import argparse
import io
import json
import os
import sys
import time
import urllib.error
import urllib.parse
import urllib.request
import zipfile
from pathlib import Path
APP_ID = "9NP42GS03Z26"
API = f"https://manage.devcenter.microsoft.com/v1.0/my/applications/{APP_ID}"
RELEASE_NOTES_LIMIT = 1500
SCREENSHOT_SUFFIXES = {".png", ".jpg", ".jpeg"}
# Commit is done once the status leaves these; CommitFailed is the only failure.
COMMIT_PENDING = {"CommitStarted"}
# ---------------------------------------------------------------- pure parts
def replace_package(submission: dict, file_name: str) -> None:
"""Marks the current packages for removal and adds [file_name]."""
for package in submission.get("applicationPackages", []):
package["fileStatus"] = "PendingDelete"
submission.setdefault("applicationPackages", []).append({
"fileName": file_name,
"fileStatus": "PendingUpload",
"minimumDirectXVersion": "None",
"minimumSystemRam": "None",
})
def set_release_notes(submission: dict, notes: str) -> None:
if len(notes) > RELEASE_NOTES_LIMIT:
raise ValueError(f"release notes are {len(notes)} characters, the Store takes {RELEASE_NOTES_LIMIT}")
for listing in submission.get("listings", {}).values():
listing.setdefault("baseListing", {})["releaseNotes"] = notes
def replace_screenshots(submission: dict, file_names: list[str]) -> None:
"""Marks every listing's screenshots for removal and adds [file_names] in
order. Other images (icons, logos) stay."""
for listing in submission.get("listings", {}).values():
images = listing.setdefault("baseListing", {}).setdefault("images", [])
for image in images:
if image.get("imageType") == "Screenshot":
image["fileStatus"] = "PendingDelete"
for name in file_names:
images.append({"fileName": name, "fileStatus": "PendingUpload", "imageType": "Screenshot", "description": ""})
def screenshot_files(directory: Path) -> list[Path]:
files = sorted(p for p in directory.iterdir() if p.suffix.lower() in SCREENSHOT_SUFFIXES)
if not files:
raise ValueError(f"no screenshots in {directory}")
if len(files) > 10:
raise ValueError(f"{len(files)} screenshots in {directory}, the Store takes 10")
return files
def summary(submission: dict) -> list[str]:
"""What the submission adds and removes, for logs and --dry-run."""
lines = []
for p in submission.get("applicationPackages", []):
if p.get("fileStatus") in ("PendingDelete", "PendingUpload"):
lines.append(f"package {p['fileStatus']}: {p.get('fileName')} {p.get('version', '')}".rstrip())
for locale, listing in submission.get("listings", {}).items():
base = listing.get("baseListing", {})
for image in base.get("images", []):
if image.get("fileStatus") in ("PendingDelete", "PendingUpload"):
lines.append(f"{locale} {image['imageType']} {image['fileStatus']}: {image.get('fileName')}")
lines.append(f"{locale} release notes: {len(base.get('releaseNotes', ''))} characters")
return lines
# ---------------------------------------------------------------- API
class Store:
def __init__(self, tenant: str, client_id: str, secret: str):
body = urllib.parse.urlencode({
"grant_type": "client_credentials",
"client_id": client_id,
"client_secret": secret,
"resource": "https://manage.devcenter.microsoft.com",
}).encode()
with urllib.request.urlopen(f"https://login.microsoftonline.com/{tenant}/oauth2/token", body) as r:
self._token = json.load(r)["access_token"]
def call(self, method: str, path: str = "", body: dict | None = None) -> dict:
request = urllib.request.Request(
API + path,
method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {self._token}", "Content-Type": "application/json"},
)
try:
with urllib.request.urlopen(request) as r:
text = r.read().decode()
except urllib.error.HTTPError as e:
raise RuntimeError(f"{method} {path or '/'} -> HTTP {e.code}: {e.read().decode()[:2000]}") from None
return json.loads(text) if text else {}
def upload_zip(url: str, payload: bytes) -> None:
# The SAS URL can contain '+', which the blob service reads as a space.
request = urllib.request.Request(
url.replace("+", "%2B"), method="PUT", data=payload, headers={"x-ms-blob-type": "BlockBlob"}
)
with urllib.request.urlopen(request) as r:
if r.status not in (200, 201):
raise RuntimeError(f"upload -> HTTP {r.status}")
def png_bytes(path: Path) -> bytes:
if path.suffix.lower() == ".png":
return path.read_bytes()
from PIL import Image # only needed for JPEG sources
out = io.BytesIO()
Image.open(path).convert("RGB").save(out, "PNG", optimize=True)
return out.getvalue()
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--msix", type=Path)
parser.add_argument("--release-notes", type=Path)
parser.add_argument("--screenshots", type=Path)
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("--wait-minutes", type=int, default=30, help="how long to wait for the commit to finish")
args = parser.parse_args(argv)
if not (args.msix or args.release_notes or args.screenshots):
parser.error("nothing to submit: pass --msix, --release-notes and/or --screenshots")
store = Store(os.environ["MSSTORE_TENANT_ID"], os.environ["MSSTORE_CLIENT_ID"], os.environ["MSSTORE_CLIENT_SECRET"])
app = store.call("GET")
pending = app.get("pendingApplicationSubmission")
files: dict[str, bytes] = {}
shots = screenshot_files(args.screenshots) if args.screenshots else []
if args.dry_run:
submission = store.call("GET", f"/submissions/{app['lastPublishedApplicationSubmission']['id']}")
else:
if pending:
print(f"error: submission {pending['id']} is already in progress in Partner Center; "
"finish or delete it first", file=sys.stderr)
return 1
submission = store.call("POST", "/submissions")
print(f"created submission {submission['id']}")
if args.msix:
replace_package(submission, args.msix.name)
files[args.msix.name] = args.msix.read_bytes() if not args.dry_run else b""
if args.release_notes:
set_release_notes(submission, args.release_notes.read_text(encoding="utf-8").strip())
if shots:
names = [f"screenshots/{p.stem}.png" for p in shots]
replace_screenshots(submission, names)
if not args.dry_run:
files.update({name: png_bytes(p) for name, p in zip(names, shots)})
for line in summary(submission):
print(line)
if args.dry_run:
print(f"dry run: nothing created (pending submission: {pending['id'] if pending else 'none'})")
return 0
submission_id = submission["id"]
try:
if files:
buffer = io.BytesIO()
with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as z:
for name, data in files.items():
z.writestr(name, data)
upload_zip(submission["fileUploadUrl"], buffer.getvalue())
print(f"uploaded {len(files)} file(s), {buffer.tell() // 1024} KB")
store.call("PUT", f"/submissions/{submission_id}", submission)
store.call("POST", f"/submissions/{submission_id}/commit")
except Exception:
print(f"failed; deleting submission {submission_id} so the next run can start clean", file=sys.stderr)
try:
store.call("DELETE", f"/submissions/{submission_id}")
except Exception as e: # keep the original error
print(f"could not delete it: {e}", file=sys.stderr)
raise
deadline = time.time() + args.wait_minutes * 60
while True:
status = store.call("GET", f"/submissions/{submission_id}/status")
state = status.get("status")
if state not in COMMIT_PENDING or time.time() > deadline:
break
time.sleep(30)
print(f"submission {submission_id}: {state}")
if state == "CommitFailed":
print(json.dumps(status.get("statusDetails"), indent=2), file=sys.stderr)
return 1
return 0
if __name__ == "__main__":
sys.exit(main())

View File

@@ -0,0 +1,75 @@
"""Tests for scripts/msstore_submission.py (no network).
python3 -m unittest scripts/test_msstore_submission.py
"""
import importlib.util
import tempfile
import unittest
from pathlib import Path
spec = importlib.util.spec_from_file_location("msstore_submission", Path(__file__).with_name("msstore_submission.py"))
ms = importlib.util.module_from_spec(spec)
spec.loader.exec_module(ms)
def submission():
return {
"applicationPackages": [{"fileName": "old.msix", "fileStatus": "Uploaded", "version": "7.6.2.0"}],
"listings": {
"en-us": {
"baseListing": {
"releaseNotes": "old",
"images": [
{"fileName": "icon.png", "fileStatus": "Uploaded", "imageType": "Icon"},
{"fileName": "a.png", "fileStatus": "Uploaded", "imageType": "Screenshot"},
],
}
}
},
}
class MsStoreSubmissionTest(unittest.TestCase):
def test_package_replaces_the_old_one(self):
s = submission()
ms.replace_package(s, "bike_control.store.msix")
self.assertEqual([(p["fileName"], p["fileStatus"]) for p in s["applicationPackages"]],
[("old.msix", "PendingDelete"), ("bike_control.store.msix", "PendingUpload")])
def test_release_notes_go_to_every_listing_and_respect_the_limit(self):
s = submission()
ms.set_release_notes(s, "Fixes:\n• one")
self.assertEqual(s["listings"]["en-us"]["baseListing"]["releaseNotes"], "Fixes:\n• one")
with self.assertRaises(ValueError):
ms.set_release_notes(s, "x" * 1501)
def test_screenshots_replace_only_screenshots_in_order(self):
s = submission()
ms.replace_screenshots(s, ["screenshots/01.png", "screenshots/02.png"])
images = s["listings"]["en-us"]["baseListing"]["images"]
self.assertEqual([(i["fileName"], i["fileStatus"]) for i in images], [
("icon.png", "Uploaded"),
("a.png", "PendingDelete"),
("screenshots/01.png", "PendingUpload"),
("screenshots/02.png", "PendingUpload"),
])
def test_screenshot_files_are_sorted_images_only(self):
with tempfile.TemporaryDirectory() as d:
for name in ["02-b.jpg", "01-a.png", "notes.txt"]:
Path(d, name).write_bytes(b"x")
self.assertEqual([p.name for p in ms.screenshot_files(Path(d))], ["01-a.png", "02-b.jpg"])
with self.assertRaises(ValueError):
ms.screenshot_files(Path(tempfile.mkdtemp()))
def test_summary_names_the_changes(self):
s = submission()
ms.replace_package(s, "new.msix")
lines = ms.summary(s)
self.assertIn("package PendingUpload: new.msix", lines)
self.assertIn("package PendingDelete: old.msix 7.6.2.0", lines)
if __name__ == "__main__":
unittest.main()

View File

@@ -23,10 +23,12 @@ cd store_screenshots && bun dev # http://localhost:3000
`screenshots/store/<locale>/<slot>/`, which `scripts/prepare_store_screenshots.sh`
stages for fastlane. Screenshots-only uploads: `fastlane ios upload_screenshots`,
`fastlane ios upload_screenshots_macos`, `fastlane android upload_screenshots`.
The Microsoft Store listing (en-US only) takes the 10" deck's PNGs through
Partner Center: `node scripts/msstore-upload.mjs --dry-run`, then
`node scripts/msstore-upload.mjs --submit` (Playwright on the logged-in
Partner Center Chrome profile; see the script's header).
The Microsoft Store listing (en-US only) takes the 10" deck through the
Partner Center submission API: GitHub Actions → "Store Metadata", platform
`windows`, action `upload` (or locally `python3 ../scripts/msstore_submission.py
--screenshots ../screenshots/store/en/androidTablet10 [--dry-run]` with the
`MSSTORE_*` variables set). The old Playwright route
(`scripts/msstore-upload.mjs`) still works as a fallback.
- Design follows `prop/design/DESIGN.md`: Barlow Condensed 800 headlines,
`#F2F2F7` / `#121212` grounds, brand blue as the only accent; the two
inverted slides use the dark-mode captures.