Skip to content

The swiss army knife of lossless video/audio editing

Add Store release workflow with daily MS Store rollout

Mikael Finstad018c65167326
diff --git a/.github/workflows/store-release.yml b/.github/workflows/store-release.yml
new file mode 100644
index 00000000..53cccc29
--- /dev/null
+++ b/.github/workflows/store-release.yml
@@ -0,0 +1,51 @@
+# Runs script/storeRelease.ts, see CONTRIBUTING.md → "Release in Stores"
+name: Store release
+
+on:
+ workflow_dispatch:
+ inputs:
+ command:
+ type: choice
+ description: Command
+ options: [mas, msstore, msstore-rollout]
+ version:
+ type: string
+ description: Version (e.g. 3.71.0), or for msstore-rollout a percentage or "next"
+ required: true
+ submit:
+ type: boolean
+ description: Apply and submit (otherwise a dry run)
+ default: false
+ schedule:
+ # Increase the Microsoft Store gradual rollout one step each day (does nothing when no rollout is in progress)
+ - cron: '0 8 * * *'
+
+concurrency: store-release
+
+jobs:
+ store-release:
+ if: github.repository == 'mifi/lossless-cut'
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+ steps:
+ - uses: actions/checkout@v6
+
+ - uses: actions/setup-node@v6
+ with:
+ node-version: 22
+ cache: 'yarn'
+
+ - run: yarn install --immutable --network-timeout 1000000
+
+ - name: Run
+ env:
+ ASC_KEY: ${{ secrets.api_key }}
+ ASC_KEY_ID: ${{ secrets.api_key_id }}
+ ASC_ISSUER_ID: ${{ secrets.api_key_issuer_id }}
+ MSSTORE_TENANT_ID: ${{ secrets.MSSTORE_TENANT_ID }}
+ MSSTORE_CLIENT_ID: ${{ secrets.MSSTORE_CLIENT_ID }}
+ MSSTORE_CLIENT_SECRET: ${{ secrets.MSSTORE_CLIENT_SECRET }}
+ COMMAND: ${{ github.event_name == 'schedule' && 'msstore-rollout' || inputs.command }}
+ VERSION: ${{ github.event_name == 'schedule' && 'next' || inputs.version }}
+ SUBMIT: ${{ (github.event_name == 'schedule' || inputs.submit) && '--submit' || '' }}
+ run: node script/storeRelease.ts "$COMMAND" "$VERSION" $SUBMIT
diff --git a/AGENTS.md b/AGENTS.md
index 8a8b4ca2..96c84361 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -26,4 +26,4 @@ The stores lag behind GitHub releases, so their "What's new" text must cover eve
- Plain text, no Markdown, code formatting, issue references or links. Use plain-language feature names instead of internal action/variable names.
- Leave out what doesn't apply to that store's build: items for other platforms (App Review rejects mentions of other platforms), GitHub-only builds, custom FFmpeg path (not in the Mac App Store build), update checks.
- Microsoft Store: max 1500 characters. Mac App Store: max 4000 characters.
-- Write them to `notes/mas-whats-new-<version>.txt` and `notes/msstore-whats-new-<version>.txt` (gitignored), where `script/storeRelease.ts` reads them, and ask the user to review them. Only run the script with `--prepare` or `--submit` after the user approves the text and the dry-run output.
+- Write them to `store-release-notes/mas-<version>.txt` and `store-release-notes/msstore-<version>.txt`, where `script/storeRelease.ts` reads them, and ask the user to review them before committing. Only run the script with `--prepare` or `--submit` (or the Store release workflow with "submit") after the user approves the text and the dry-run output.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 85bf7fe0..b10226be 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -122,7 +122,25 @@ Before releasing, consider [Maintenance chores](#maintenance-chores) first.
Usually some time after the GitHub release, once no serious regressions have been reported.
-First write the "What's new" text for each store (see [Store release notes](./AGENTS.md#store-release-notes)) to `notes/mas-whats-new-x.y.z.txt` and `notes/msstore-whats-new-x.y.z.txt` (or pass `--notes <file>`). Then:
+This is automated with [`script/storeRelease.ts`](./script/storeRelease.ts), run by the [Store release](https://github.com/mifi/lossless-cut/actions/workflows/store-release.yml) workflow (or locally, see below):
+
+1. Write the "What's new" text for each store (see [Store release notes](./AGENTS.md#store-release-notes)) to `store-release-notes/mas-x.y.z.txt` and `store-release-notes/msstore-x.y.z.txt`, review it, commit and push.
+2. Actions → Store release → Run workflow, with command `mas` or `msstore`, version `x.y.z` and "submit" unticked. The log shows the current state and what it would change.
+3. If that looks right, run it again with "submit" ticked.
+4. Once approved/certified (you'll get an email):
+ - **Mac App Store**: click "Release this version" in [App Store Connect](https://appstoreconnect.apple.com/apps/1505323402/distribution). The 7-day phased release then runs by itself.
+ - **Microsoft Store**: click "Publish now" in [Partner Center](https://partner.microsoft.com/en-us/dashboard/products/9P30LSR4705L/overview). The rollout starts at 0%, and the workflow's daily schedule increases it to 1, 2, 5, 10, 20, 50 and 100% (finalized). To pause it, halt the rollout in Partner Center (the schedule then leaves it alone), or set a percentage yourself with the `msstore-rollout` command.
+
+What the script does:
+
+- **Mac App Store**: App Store versions have their own numbering (1.x, e.g. 1.14), separate from the GitHub/build version (`package.json`, e.g. 3.70.1), which is the build attached to it. The script takes the build version, and creates the next App Store version (1.14 → 1.15) or reuses the editable one. It waits for the build to finish processing and attaches it, sets en-US "What's New", manual release, 7-day phased release, and submits for review.
+- **Microsoft Store**: creates a submission, replaces the packages with both `.appx` files from the GitHub release (renamed without `-DONT-USE-THIS-FILE`), sets en-US "What's new", gradual rollout at 0%, "Don't publish until I select Publish now", and submits for certification. Don't edit a submission in Partner Center that the script created, or the API can no longer change it.
+- If the version is already submitted or released, it says so and does nothing.
+- Description, keywords and screenshots are not touched; update them by hand if needed.
+
+If it fails, use the manual steps below.
+
+#### Running locally
```bash
node script/storeRelease.ts mas x.y.z # dry run: shows the current state and what it would change
@@ -130,24 +148,21 @@ node script/storeRelease.ts mas x.y.z --prepare # optional: apply the changes w
node script/storeRelease.ts mas x.y.z --submit # apply and submit for review
node script/storeRelease.ts msstore x.y.z # dry run
node script/storeRelease.ts msstore x.y.z --submit
+node script/storeRelease.ts msstore-rollout 20 --submit # or "next"
```
-- **Mac App Store**: App Store versions have their own numbering (1.x, e.g. 1.14), separate from the GitHub/build version (`package.json`, e.g. 3.70.1), which is the build attached to it. The script takes the build version, and creates the next App Store version (1.14 → 1.15) or reuses the editable one. It waits for the build to finish processing and attaches it, sets en-US "What's New", manual release, 7-day phased release, and submits for review. Once approved, release it manually in App Store Connect.
-- **Microsoft Store**: creates a submission, adds both `.appx` packages from the GitHub release (renamed without `-DONT-USE-THIS-FILE`), sets en-US "What's new", gradual rollout at 0%, "Don't publish until I select Publish now", and submits for certification. Once certified, click "Publish now" in Partner Center, then increase the rollout with `node script/storeRelease.ts msstore-rollout <percent> --submit` (dry run without `--submit`; `100` finalizes it). Don't edit a submission in Partner Center that the script created, or the API can no longer change it.
-- Description, keywords and screenshots are not touched; update them by hand if needed.
-
-If the script fails, use the manual steps below.
+with the credentials below as environment variables (never commit them).
#### Credentials
-Set these in your shell (never commit them). Secrets can be kept in the macOS keychain, e.g. `security add-generic-password -a "$USER" -s MSSTORE_CLIENT_SECRET -w` once, then `export MSSTORE_CLIENT_SECRET=$(security find-generic-password -s MSSTORE_CLIENT_SECRET -w)`.
+GitHub repository secrets, used by the workflow:
-- **Mac App Store**: `ASC_KEY_ID`, `ASC_ISSUER_ID` and the key in `~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8` (or `ASC_KEY_PATH`). The key needs the **App Manager** (or Admin) role. Create one in [App Store Connect → Users and Access → Integrations → App Store Connect API](https://appstoreconnect.apple.com/access/integrations/api) → Team Keys; the Issuer ID is shown at the top of that page.
-- **Microsoft Store**: `MSSTORE_TENANT_ID`, `MSSTORE_CLIENT_ID`, `MSSTORE_CLIENT_SECRET`. One-time setup:
+- **Mac App Store**: `api_key` (the `.p8` file's contents), `api_key_id`, `api_key_issuer_id`, also used by the build workflow. Locally: `ASC_KEY_ID`, `ASC_ISSUER_ID` and the key in `~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8` (or `ASC_KEY_PATH`). The key needs the **App Manager** (or Admin) role. Create one in [App Store Connect → Users and Access → Integrations → App Store Connect API](https://appstoreconnect.apple.com/access/integrations/api) → Team Keys; the Issuer ID is shown at the top of that page.
+- **Microsoft Store**: `MSSTORE_TENANT_ID`, `MSSTORE_CLIENT_ID`, `MSSTORE_CLIENT_SECRET` (same names locally). One-time setup:
1. Partner Center → ⚙ Account settings → **Tenants**: associate a Microsoft Entra ID tenant, or create a new one there ([docs](https://learn.microsoft.com/en-us/windows/apps/publish/partner-center/associate-azure-ad-with-partner-center)). You need to be Global administrator of the tenant.
- 2. Account settings → **User management** → **Microsoft Entra applications** tab → **Add Microsoft Entra application** → **Create Microsoft Entra application**. Any name (e.g. `losslesscut-store-release`) and any unique Reply URL (e.g. `https://example.com/store-release`, it's not used). Role: **Manager**. Click **Create**.
- 3. Click the application and copy the **Tenant ID** and **Client ID**.
- 4. Click **Add new key** and copy the **Key** (the client secret, shown only once). The page shows when the key expires; add a new one before that.
+ 2. Account settings → **User management** (signed in with the tenant's account) → **Microsoft Entra applications** tab → **Add Microsoft Entra application** → **Create Microsoft Entra application**. Any name (e.g. `losslesscut-store-release`) and any unique Reply URL (e.g. `https://example.com/store-release`, it's not used). Role: **Manager**. Click **Create**.
+ 3. The Client ID is shown in the list of applications, and the Tenant ID under Account settings → Tenants.
+ 4. Click the application → **Add new key** and copy the **Key** (the client secret, shown only once). The page shows when the key expires; add a new one before that, and update the `MSSTORE_CLIENT_SECRET` secret.
#### Microsoft Store (manual)
diff --git a/script/storeRelease.ts b/script/storeRelease.ts
index 3cd5dec7..4e5df0f0 100644
--- a/script/storeRelease.ts
+++ b/script/storeRelease.ts
@@ -3,15 +3,15 @@
//
// node script/storeRelease.ts mas <version> [--notes file] [--prepare | --submit]
// node script/storeRelease.ts msstore <version> [--notes file] [--submit]
-// node script/storeRelease.ts msstore-rollout <percent> [--submit]
+// node script/storeRelease.ts msstore-rollout <percent|next> [--submit]
//
// Credentials come from the environment:
-// Mac App Store: ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_PATH (default ~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8)
+// Mac App Store: ASC_KEY_ID, ASC_ISSUER_ID, and ASC_KEY (the .p8 key's contents) or ASC_KEY_PATH (default ~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8)
// Microsoft Store: MSSTORE_TENANT_ID, MSSTORE_CLIENT_ID, MSSTORE_CLIENT_SECRET
import assert from 'node:assert';
import { createPrivateKey, sign } from 'node:crypto';
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
-import { openAsBlob } from 'node:fs';
+import { existsSync, openAsBlob } from 'node:fs';
import { homedir, tmpdir } from 'node:os';
import { join } from 'node:path';
import { setTimeout as sleep } from 'node:timers/promises';
@@ -24,14 +24,16 @@ const masAppId = '1505323402';
const msStoreAppId = '9P30LSR4705L';
const githubRepo = 'mifi/lossless-cut';
const msStoreArchs = ['x64', 'arm64'];
+// Same steps as Apple's 7-day phased release
+const msStoreRolloutSteps = [1, 2, 5, 10, 20, 50, 100];
const args = yargs(hideBin(process.argv))
.command('mas <version>', 'Mac App Store')
.command('msstore <version>', 'Microsoft Store')
- .command('msstore-rollout <percent>', 'Change the Microsoft Store gradual rollout percentage of the last published submission (100 finalizes it)')
+ .command('msstore-rollout <percent>', `Change the Microsoft Store gradual rollout percentage of the last published submission (100 finalizes it). "next" goes to the next of ${msStoreRolloutSteps.join(', ')}%, and does nothing if no rollout is in progress`)
.demandCommand(1)
.version(false)
- .option('notes', { type: 'string', describe: 'What\'s New text file (default: notes/<store>-whats-new-<version>.txt)' })
+ .option('notes', { type: 'string', describe: 'What\'s New text file (default: store-release-notes/<store>-<version>.txt)' })
.option('prepare', { type: 'boolean', default: false, describe: 'Mac App Store: write the changes, but don\'t submit for review' })
.option('submit', { type: 'boolean', default: false, describe: 'Write the changes and submit for review' })
.strict()
@@ -61,7 +63,11 @@ async function fetchJson(url: string, init: RequestInit & { hint?: string } = {}
}
async function readNotes(version: string, maxLength: number) {
- const path = args.notes ?? `notes/${store}-whats-new-${version}.txt`;
+ const path = args.notes ?? `store-release-notes/${store}-${version}.txt`;
+ if (!write && !existsSync(path)) {
+ log(`What's New: ${path} doesn't exist yet\n`);
+ return '';
+ }
const notes = (await readFile(path, 'utf8')).trim();
assert(notes.length > 0, `${path} is empty`);
assert(notes.length <= maxLength, `${path} is ${notes.length} characters, the max is ${maxLength}`);
@@ -81,7 +87,7 @@ let ascKey: ReturnType<typeof createPrivateKey> | undefined;
async function ascToken() {
const keyId = requireEnv('ASC_KEY_ID');
- ascKey ??= createPrivateKey(await readFile(process.env['ASC_KEY_PATH'] ?? join(homedir(), '.appstoreconnect/private_keys', `AuthKey_${keyId}.p8`)));
+ ascKey ??= createPrivateKey(process.env['ASC_KEY'] ?? await readFile(process.env['ASC_KEY_PATH'] ?? join(homedir(), '.appstoreconnect/private_keys', `AuthKey_${keyId}.p8`)));
const base64url = (obj: object) => Buffer.from(JSON.stringify(obj)).toString('base64url');
const now = Math.floor(Date.now() / 1000);
const unsigned = `${base64url({ alg: 'ES256', kid: keyId, typ: 'JWT' })}.${base64url({ iss: requireEnv('ASC_ISSUER_ID'), iat: now, exp: now + 15 * 60, aud: 'appstoreconnect-v1' })}`;
@@ -325,10 +331,16 @@ async function msstore(version: string) {
}
}
-async function msstoreRollout(percent: number) {
- assert(percent > 0 && percent <= 100, 'Percent must be in (0, 100]');
+async function msstoreRollout(percentArg: string) {
const { published } = await getMsApp();
- assert(published.packageDeliveryOptions.packageRollout.packageRolloutStatus === 'PackageRolloutInProgress', 'The last published submission has no gradual rollout in progress (did you click "Publish now"?)');
+ const { packageRolloutStatus, packageRolloutPercentage } = published.packageDeliveryOptions.packageRollout;
+ if (packageRolloutStatus !== 'PackageRolloutInProgress') {
+ assert(percentArg === 'next', 'The last published submission has no gradual rollout in progress (did you click "Publish now"?)');
+ log('No rollout in progress, nothing to do');
+ return;
+ }
+ const percent = percentArg === 'next' ? (msStoreRolloutSteps.find((step) => step > packageRolloutPercentage) ?? 100) : Number(percentArg);
+ assert(percent > 0 && percent <= 100, 'Percent must be in (0, 100]');
const action = percent === 100 ? 'finalizepackagerollout' : `updatepackagerolloutpercentage?percentage=${percent}`;
plan(percent === 100 ? 'finalize the rollout (100%)' : `set rollout to ${percent}%`);
if (!args.submit) return;
@@ -339,7 +351,7 @@ async function msstoreRollout(percent: number) {
switch (store) {
case 'mas': { await mas(String(args['version'])); break; }
case 'msstore': { await msstore(String(args['version'])); break; }
- case 'msstore-rollout': { await msstoreRollout(Number(args['percent'])); break; }
+ case 'msstore-rollout': { await msstoreRollout(String(args['percent'])); break; }
default: { throw new Error(`Unknown command ${store}`); }
}
if (!write) log('\nDry run, nothing was changed. Use --submit to apply.');