@mp-lb/expo-release 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # @mp-lb/expo-release
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared Expo setup, app icons and GitHub Actions release jobs. The app owns its
4
+ bundle and package IDs, Expo owner, store submission profiles, release triggers,
5
+ and any app-specific permissions or integrations.
6
+
7
+ ## Local commands
8
+
9
+ ```sh
10
+ npm exec --yes --package=@mp-lb/expo-release@0.1.0 -- expo-release-setup .
11
+ npm exec --yes --package=@mp-lb/expo-release@0.1.0 -- expo-release-apply-inputs inputs.env .
12
+ npm exec --yes --package=@mp-lb/expo-release@0.1.0 -- expo-release-icons source.png assets/images
13
+ ```
14
+
15
+ Use `--replace-app-json` with setup only when replacing a fresh Expo scaffold's
16
+ example config. Setup preserves other existing files. The icon source should be
17
+ a 1024 × 1024 PNG with a light opaque interior and a dark glyph. If the app's
18
+ `.npmrc` routes `@mp-lb` to GitHub Packages, pass
19
+ `--@mp-lb:registry=https://registry.npmjs.org` to the commands above.
20
+
21
+ ## GitHub Actions
22
+
23
+ The setup command installs example callers for CI, release, and EAS connection
24
+ checks. They install the pinned npm package beside the app checkout, so the
25
+ app's registry settings, dependency lockfile, and EAS build archive stay
26
+ independent of the release tooling. Use `app` as the checkout path for the
27
+ example callers. The action also accepts a different path via `project`.
28
+
29
+ | Mode | Work performed |
30
+ | --- | --- |
31
+ | `ci` | Install app dependencies, lint and typecheck, and run Expo Doctor |
32
+ | `install` | Install app dependencies for a caller-owned step such as Changesets |
33
+ | `connection` | Verify the EAS account and linked project |
34
+ | `sync` | Sync production variables to EAS without building or publishing |
35
+ | `deploy` | Use Expo's native fingerprint action to publish an update and build with auto-submit when a matching binary is missing |
36
+ | `release` | Validate, sync, and deploy in one job |
37
+
38
+ The action exports EAS build IDs when Expo reports them. It uses the app's
39
+ `production` EAS build and submit profiles. Check the target track and App Store
40
+ Connect ID in the app before enabling automatic submissions.
41
+
42
+ For apps using Forum encryption, commit `docs/secrets.json.enc` and pass the
43
+ repository's `SECRETS_KEY` as `secrets-key`. For separately managed apps, pass
44
+ `npm-token` and `expo-token` from GitHub Actions secrets. CI and install modes
45
+ only need the registry token. The default token variable is `NODE_AUTH_TOKEN`.
46
+ Override `npm-token-env` when the app's `.npmrc` expects a different name.
47
+
48
+ The default EAS environment contains the registry token and the standard public
49
+ app environment, API URL, and Clerk publishable key when provided. Add an
50
+ `env-map.yaml` for a project with different keys. Use the `ci`, `release`, and
51
+ `eas` sections to select values from the encrypted payload, direct token inputs,
52
+ and `.env.production`. Use single-line dotenv values for EAS. The sync replaces the
53
+ EAS production environment with the selected values.
54
+
55
+ Run connection mode first to verify Expo access. Existing binaries can be
56
+ submitted separately in the store consoles, and reviewers still need a usable
57
+ build and accurate listing details.
@@ -0,0 +1,105 @@
1
+ name: MAP Lab Expo
2
+ description: Validate, configure, or release an Expo app
3
+ inputs:
4
+ mode:
5
+ description: One of ci, install, connection, sync, deploy, or release
6
+ required: true
7
+ project:
8
+ description: Expo checkout directory relative to the GitHub workspace
9
+ default: app
10
+ secrets-key:
11
+ description: Recipient key for the app's encrypted Forum secrets
12
+ required: false
13
+ npm-token:
14
+ description: Registry token when provided directly by GitHub Actions
15
+ required: false
16
+ npm-token-env:
17
+ description: The registry token variable used by the app's .npmrc
18
+ default: NODE_AUTH_TOKEN
19
+ expo-token:
20
+ description: Expo token when provided directly by GitHub Actions
21
+ required: false
22
+ outputs:
23
+ android-build-id:
24
+ description: EAS Build ID returned by the fingerprint action for Android
25
+ value: ${{ steps.deploy.outputs.android-build-id }}
26
+ ios-build-id:
27
+ description: EAS Build ID returned by the fingerprint action for iOS
28
+ value: ${{ steps.deploy.outputs.ios-build-id }}
29
+ runs:
30
+ using: composite
31
+ steps:
32
+ - uses: actions/setup-node@v4
33
+ with:
34
+ node-version: 22
35
+ cache: npm
36
+ cache-dependency-path: ${{ inputs.project }}/package-lock.json
37
+
38
+ - name: Prepare Expo environment
39
+ shell: bash
40
+ env:
41
+ PROJECT: ${{ inputs.project }}
42
+ RELEASE_MODE: ${{ inputs.mode }}
43
+ NPM_TOKEN_ENV: ${{ inputs.npm-token-env }}
44
+ SECRETS_KEY: ${{ inputs.secrets-key }}
45
+ RELEASE_NPM_TOKEN: ${{ inputs.npm-token }}
46
+ RELEASE_EXPO_TOKEN: ${{ inputs.expo-token }}
47
+ run: |
48
+ node "$GITHUB_ACTION_PATH/../../dist/githubEnvironment.js" \
49
+ "$PROJECT" "$RELEASE_MODE" "$NPM_TOKEN_ENV" "$RUNNER_TEMP/maplab-expo.env"
50
+
51
+ - name: Install Expo app dependencies
52
+ shell: bash
53
+ working-directory: ${{ inputs.project }}
54
+ run: npm ci
55
+
56
+ - name: Lint and typecheck Expo app
57
+ if: inputs.mode == 'ci' || inputs.mode == 'release'
58
+ shell: bash
59
+ working-directory: ${{ inputs.project }}
60
+ run: |
61
+ npm run lint
62
+ npx tsc --noEmit
63
+
64
+ - name: Run Expo Doctor
65
+ if: inputs.mode == 'ci'
66
+ shell: bash
67
+ working-directory: ${{ inputs.project }}
68
+ run: npx expo-doctor
69
+
70
+ - uses: expo/expo-github-action@v9
71
+ if: inputs.mode != 'ci' && inputs.mode != 'install'
72
+ with:
73
+ eas-version: latest
74
+ token: ${{ env.EXPO_TOKEN }}
75
+
76
+ - name: Verify EAS connection
77
+ if: inputs.mode == 'connection'
78
+ shell: bash
79
+ working-directory: ${{ inputs.project }}
80
+ run: |
81
+ eas whoami
82
+ eas project:info
83
+
84
+ - name: Sync EAS production environment
85
+ if: inputs.mode == 'sync' || inputs.mode == 'release'
86
+ shell: bash
87
+ working-directory: ${{ inputs.project }}
88
+ run: eas env:push production --path "$RUNNER_TEMP/maplab-expo.env" --force
89
+
90
+ - name: Deploy with EAS native fingerprints
91
+ if: inputs.mode == 'deploy' || inputs.mode == 'release'
92
+ id: deploy
93
+ uses: expo/expo-github-action/continuous-deploy-fingerprint@v9
94
+ with:
95
+ working-directory: ${{ inputs.project }}
96
+ profile: production
97
+ branch: production
98
+ platform: all
99
+ environment: production
100
+ auto-submit-builds: true
101
+
102
+ - name: Remove the EAS environment file
103
+ if: always() && (inputs.mode == 'sync' || inputs.mode == 'release')
104
+ shell: bash
105
+ run: rm -f "$RUNNER_TEMP/maplab-expo.env"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ // Interpolate REPLACE_WITH_<KEY> tokens from an inputs env file into a repo.
3
+ //
4
+ // expo-release-apply-inputs <inputs.env> [target-dir]
5
+ //
6
+ // Replaces tokens in every text file under target-dir (default: cwd),
7
+ // skipping .git, node_modules, and binary-ish files. Keys with empty values
8
+ // are left as tokens so the script can be re-run after e.g. `eas init`.
9
+ import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
10
+ import { join } from "node:path";
11
+ const [inputsPath, targetDir = process.cwd()] = process.argv.slice(2);
12
+ if (!inputsPath) {
13
+ console.error("Usage: expo-release-apply-inputs <inputs.env> [target-dir]");
14
+ process.exit(1);
15
+ }
16
+ const inputs = Object.fromEntries(readFileSync(inputsPath, "utf8")
17
+ .split("\n")
18
+ .map((line) => line.trim())
19
+ .filter((line) => line && !line.startsWith("#"))
20
+ .map((line) => {
21
+ const eq = line.indexOf("=");
22
+ return [line.slice(0, eq), line.slice(eq + 1).trim()];
23
+ })
24
+ .filter(([, value]) => value !== ""));
25
+ const SKIP_DIRS = new Set([".git", "node_modules", ".expo", "ios", "android"]);
26
+ const TEXT_EXT = /\.(json|json5|js|mjs|cjs|ts|tsx|yml|yaml|md|env|example|txt|xml|plist|gradle|properties|html)$|^\.env(?:\..+)?$|^[^.]+$/;
27
+ let changed = 0;
28
+ const walk = (dir) => {
29
+ for (const name of readdirSync(dir)) {
30
+ const path = join(dir, name);
31
+ if (statSync(path).isDirectory()) {
32
+ if (!SKIP_DIRS.has(name))
33
+ walk(path);
34
+ continue;
35
+ }
36
+ if (!TEXT_EXT.test(name))
37
+ continue;
38
+ const before = readFileSync(path, "utf8");
39
+ let after = before;
40
+ for (const [key, value] of Object.entries(inputs)) {
41
+ after = after.replaceAll(`REPLACE_WITH_${key}`, value);
42
+ }
43
+ if (after !== before) {
44
+ writeFileSync(path, after);
45
+ changed += 1;
46
+ console.log(`updated ${path}`);
47
+ }
48
+ }
49
+ };
50
+ walk(targetDir);
51
+ const leftovers = new Set();
52
+ const scan = (dir) => {
53
+ for (const name of readdirSync(dir)) {
54
+ const path = join(dir, name);
55
+ if (statSync(path).isDirectory()) {
56
+ if (!SKIP_DIRS.has(name))
57
+ scan(path);
58
+ continue;
59
+ }
60
+ if (!TEXT_EXT.test(name))
61
+ continue;
62
+ for (const match of readFileSync(path, "utf8").matchAll(/REPLACE_WITH_[A-Z_]+/g)) {
63
+ leftovers.add(match[0]);
64
+ }
65
+ }
66
+ };
67
+ scan(targetDir);
68
+ console.log(`${changed} file(s) updated`);
69
+ if (leftovers.size) {
70
+ console.log(`unfilled tokens remaining: ${[...leftovers].join(", ")}`);
71
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import { resolve } from "node:path";
3
+ import { generateIconAssets } from "./icons/generateIconAssets.js";
4
+ const [source, output = "assets/images", ...extra] = process.argv.slice(2);
5
+ if (!source || extra.length) {
6
+ console.error("Usage: expo-release-icons <source.png> [output-directory]");
7
+ process.exitCode = 1;
8
+ }
9
+ else {
10
+ const midpoint = await generateIconAssets(resolve(source), resolve(output));
11
+ console.log(`done; gradient midpoint ${midpoint}`);
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { prepareEnvironment } from "./prepareEnvironment.js";
2
+ const [project, mode, npmTokenEnv, easEnv] = process.argv.slice(2);
3
+ const { GITHUB_ENV: githubEnv, SECRETS_KEY: secretsKey, RELEASE_NPM_TOKEN: npmToken, RELEASE_EXPO_TOKEN: expoToken, } = process.env;
4
+ if (!project || !mode || !npmTokenEnv || !easEnv || !githubEnv) {
5
+ throw new Error("The Expo release action must supply project, mode, npm token name and environment paths");
6
+ }
7
+ try {
8
+ await prepareEnvironment({
9
+ project,
10
+ mode,
11
+ npmTokenEnv,
12
+ easEnv,
13
+ githubEnv,
14
+ secretsKey,
15
+ npmToken,
16
+ expoToken,
17
+ });
18
+ }
19
+ catch (error) {
20
+ console.error(error instanceof Error
21
+ ? error.message
22
+ : "Could not prepare the Expo release environment");
23
+ process.exitCode = 1;
24
+ }
@@ -0,0 +1,4 @@
1
+ export declare const centerOnCanvas: (pixels: Buffer, bounds: {
2
+ width: number;
3
+ height: number;
4
+ }, canvasSize: number, contentSize: number, output: string) => Promise<void>;
@@ -0,0 +1,30 @@
1
+ import sharp from "sharp";
2
+ export const centerOnCanvas = async (pixels, bounds, canvasSize, contentSize, output) => {
3
+ const scale = contentSize / Math.max(bounds.width, bounds.height);
4
+ // Match Python's ties-to-even rounding for dimensions.
5
+ const round = (value) => value % 1 === 0.5 ? 2 * Math.round(value / 2) : Math.round(value);
6
+ const width = Math.max(1, round(bounds.width * scale));
7
+ const height = Math.max(1, round(bounds.height * scale));
8
+ const resized = await sharp(pixels, { raw: { ...bounds, channels: 4 } })
9
+ .resize(width, height, { kernel: "lanczos3" })
10
+ .raw()
11
+ .toBuffer();
12
+ const canvas = Buffer.alloc(canvasSize * canvasSize * 4);
13
+ const left = Math.floor((canvasSize - width) / 2);
14
+ const top = Math.floor((canvasSize - height) / 2);
15
+ // Pillow paste(img, position, img) applies the alpha mask to all four
16
+ // channels, including alpha itself. Preserve that feathering behavior.
17
+ for (let y = 0; y < height; y++) {
18
+ for (let x = 0; x < width; x++) {
19
+ const from = (y * width + x) * 4;
20
+ const to = ((y + top) * canvasSize + x + left) * 4;
21
+ for (let channel = 0; channel < 4; channel++)
22
+ canvas[to + channel] = Math.round((resized[from + channel] * resized[from + 3]) / 255);
23
+ }
24
+ }
25
+ await sharp(canvas, {
26
+ raw: { width: canvasSize, height: canvasSize, channels: 4 },
27
+ })
28
+ .png()
29
+ .toFile(output);
30
+ };
@@ -0,0 +1,10 @@
1
+ export declare const extractGlyph: (source: Buffer, size: number) => {
2
+ glyph: Buffer<ArrayBuffer>;
3
+ white: Buffer<ArrayBuffer>;
4
+ bounds: {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ };
10
+ };
@@ -0,0 +1,31 @@
1
+ export const extractGlyph = (source, size) => {
2
+ const glyph = Buffer.alloc(source.length);
3
+ const white = Buffer.alloc(source.length);
4
+ let left = size, top = size, right = -1, bottom = -1;
5
+ for (let y = 0; y < size; y++) {
6
+ for (let x = 0; x < size; x++) {
7
+ const i = (y * size + x) * 4;
8
+ if (source[i + 3] < 200)
9
+ continue;
10
+ const luminance = 0.299 * source[i] + 0.587 * source[i + 1] + 0.114 * source[i + 2];
11
+ const alpha = Math.trunc(Math.max(0, Math.min(1, (170 - luminance) / 60)) * 255);
12
+ if (!alpha)
13
+ continue;
14
+ source.copy(glyph, i, i, i + 3);
15
+ glyph[i + 3] = alpha;
16
+ white.fill(255, i, i + 3);
17
+ white[i + 3] = alpha;
18
+ left = Math.min(left, x);
19
+ top = Math.min(top, y);
20
+ right = Math.max(right, x);
21
+ bottom = Math.max(bottom, y);
22
+ }
23
+ }
24
+ if (right < left)
25
+ throw new Error("Source icon has no dark glyph");
26
+ return {
27
+ glyph,
28
+ white,
29
+ bounds: { left, top, width: right - left + 1, height: bottom - top + 1 },
30
+ };
31
+ };
@@ -0,0 +1 @@
1
+ export declare const generateIconAssets: (source: string, output: string) => Promise<string>;
@@ -0,0 +1,53 @@
1
+ import { mkdir } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import sharp from "sharp";
4
+ import { extractGlyph } from "./extractGlyph.js";
5
+ import { gradientBackground } from "./gradientBackground.js";
6
+ import { centerOnCanvas } from "./centerOnCanvas.js";
7
+ export const generateIconAssets = async (source, output) => {
8
+ const { data, info } = await sharp(source)
9
+ .toColourspace("srgb")
10
+ .ensureAlpha()
11
+ .raw()
12
+ .toBuffer({ resolveWithObject: true });
13
+ const size = 1024;
14
+ if (info.width !== size || info.height !== size)
15
+ throw new Error("Source icon must be 1024×1024 pixels");
16
+ let inset = 0;
17
+ while (inset < size / 2 && data[(inset * size + inset) * 4 + 3] <= 250)
18
+ inset++;
19
+ inset += 4;
20
+ if (inset >= size / 2)
21
+ throw new Error("Source icon has no opaque interior");
22
+ const raw = { width: size, height: size, channels: 4 };
23
+ const { glyph, white, bounds } = extractGlyph(data, size);
24
+ const { background, midpoint } = gradientBackground(data, size, inset + 40);
25
+ await mkdir(output, { recursive: true });
26
+ await sharp(data, { raw })
27
+ .extract({
28
+ left: inset,
29
+ top: inset,
30
+ width: size - inset * 2,
31
+ height: size - inset * 2,
32
+ })
33
+ .resize(size, size, { kernel: "lanczos3" })
34
+ .removeAlpha()
35
+ .png()
36
+ .toFile(join(output, "icon.png"));
37
+ const cropped = await sharp(glyph, { raw }).extract(bounds).raw().toBuffer();
38
+ const monochrome = await sharp(white, { raw })
39
+ .extract(bounds)
40
+ .raw()
41
+ .toBuffer();
42
+ await centerOnCanvas(cropped, bounds, size, Math.trunc(size * 0.6), join(output, "android-icon-foreground.png"));
43
+ await centerOnCanvas(monochrome, bounds, size, Math.trunc(size * 0.6), join(output, "android-icon-monochrome.png"));
44
+ await centerOnCanvas(cropped, bounds, 512, Math.trunc(512 * 0.85), join(output, "splash-icon.png"));
45
+ await sharp(background, { raw: { width: size, height: size, channels: 3 } })
46
+ .png()
47
+ .toFile(join(output, "android-icon-background.png"));
48
+ await sharp(data, { raw })
49
+ .resize(48, 48, { kernel: "lanczos3" })
50
+ .png()
51
+ .toFile(join(output, "favicon.png"));
52
+ return midpoint;
53
+ };
@@ -0,0 +1,4 @@
1
+ export declare const gradientBackground: (source: Buffer, size: number, columnX: number) => {
2
+ background: Buffer<ArrayBuffer>;
3
+ midpoint: string;
4
+ };
@@ -0,0 +1,34 @@
1
+ export const gradientBackground = (source, size, columnX) => {
2
+ if (columnX >= size)
3
+ throw new Error("Source icon has no gradient sample column");
4
+ const column = [];
5
+ let last;
6
+ for (let y = 0; y < size; y++) {
7
+ const i = (y * size + columnX) * 4;
8
+ if (source[i + 3] > 250)
9
+ last = source.subarray(i, i + 3);
10
+ column.push(last);
11
+ }
12
+ let darkest = -1;
13
+ let minimum = Infinity;
14
+ for (let y = 0; y < size / 4; y++) {
15
+ const color = column[y];
16
+ if (color && color[0] + color[1] + color[2] < minimum) {
17
+ minimum = color[0] + color[1] + color[2];
18
+ darkest = y;
19
+ }
20
+ }
21
+ if (darkest < 0)
22
+ throw new Error("Source icon has no opaque gradient in its top quarter");
23
+ column.fill(column[darkest], 0, darkest);
24
+ const background = Buffer.alloc(size * size * 3);
25
+ for (let y = 0; y < size; y++) {
26
+ const color = column[y];
27
+ for (let x = 0; x < size; x++)
28
+ color.copy(background, (y * size + x) * 3);
29
+ }
30
+ return {
31
+ background,
32
+ midpoint: `#${column[Math.floor(size / 2)].toString("hex").toUpperCase()}`,
33
+ };
34
+ };
@@ -0,0 +1,12 @@
1
+ interface EnvironmentOptions {
2
+ project: string;
3
+ mode: string;
4
+ npmTokenEnv: string;
5
+ npmToken?: string;
6
+ expoToken?: string;
7
+ secretsKey?: string;
8
+ githubEnv: string;
9
+ easEnv: string;
10
+ }
11
+ export declare const prepareEnvironment: (options: EnvironmentOptions) => Promise<void>;
12
+ export {};
@@ -0,0 +1,80 @@
1
+ import { appendFile, readFile, writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { mergeEnv, parseDotenv, parseEnvMapYaml, parseSecretsJson, renderGithubEnv, selectServiceEnv, } from "@mp-lb/env-mapper";
4
+ import { decryptForumEncryptedFileText } from "@mp-lb/forum-secrets";
5
+ const readOptional = async (path) => {
6
+ try {
7
+ return await readFile(path, "utf8");
8
+ }
9
+ catch (error) {
10
+ if (error.code !== "ENOENT")
11
+ throw error;
12
+ }
13
+ };
14
+ export const prepareEnvironment = async (options) => {
15
+ const { project, mode, npmTokenEnv, npmToken, expoToken, secretsKey } = options;
16
+ const modes = ["ci", "connection", "install", "sync", "deploy", "release"];
17
+ if (!modes.includes(mode))
18
+ throw new Error(`Unknown Expo release mode: ${mode}`);
19
+ if (!/^[A-Z_][A-Z0-9_]*$/.test(npmTokenEnv)) {
20
+ throw new Error("npm-token-env must be an environment variable name");
21
+ }
22
+ const publicConfig = await readOptional(join(project, ".env.production"));
23
+ const mapping = await readOptional(join(project, "env-map.yaml"));
24
+ const secretValues = {};
25
+ if (secretsKey) {
26
+ const encryptedText = await readOptional(join(project, "docs/secrets.json.enc"));
27
+ if (!encryptedText)
28
+ throw new Error("SECRETS_KEY is set but docs/secrets.json.enc is missing");
29
+ try {
30
+ const plaintext = await decryptForumEncryptedFileText({
31
+ encryptedText,
32
+ recipientSecret: secretsKey,
33
+ });
34
+ Object.assign(secretValues, parseSecretsJson(plaintext).values);
35
+ }
36
+ catch (error) {
37
+ throw new Error("Could not decrypt or parse docs/secrets.json.enc with SECRETS_KEY", {
38
+ cause: error,
39
+ });
40
+ }
41
+ }
42
+ if (npmToken)
43
+ secretValues[npmTokenEnv] = npmToken;
44
+ if (expoToken)
45
+ secretValues.EXPO_TOKEN = expoToken;
46
+ const { values, secretKeys } = mergeEnv(parseDotenv(publicConfig ?? ""), secretValues);
47
+ const ciKeys = [npmTokenEnv];
48
+ const inventory = mapping
49
+ ? parseEnvMapYaml(mapping)
50
+ : {
51
+ ci: ciKeys,
52
+ release: [...ciKeys, "EXPO_TOKEN"],
53
+ eas: [
54
+ ...ciKeys,
55
+ ...[
56
+ "EXPO_PUBLIC_APP_ENV",
57
+ "EXPO_PUBLIC_API_BASE_URL",
58
+ "EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY",
59
+ ].filter((key) => values[key] !== undefined && values[key] !== ""),
60
+ ],
61
+ };
62
+ const service = mode === "ci" || mode === "install" ? "ci" : "release";
63
+ const selected = selectServiceEnv(service, inventory, values);
64
+ const rendered = renderGithubEnv(selected, secretKeys);
65
+ if (mode === "sync" || mode === "release") {
66
+ const easValues = selectServiceEnv("eas", inventory, values);
67
+ const lines = Object.entries(easValues).map(([name, value]) => {
68
+ if (/[\r\n]/.test(value)) {
69
+ throw new Error(`EAS environment value ${name} must be a single line`);
70
+ }
71
+ return `${name}=${value}`;
72
+ });
73
+ await writeFile(options.easEnv, lines.join("\n") + "\n", { mode: 0o600 });
74
+ for (const mask of renderGithubEnv(easValues, secretKeys).masks)
75
+ console.log(mask);
76
+ }
77
+ for (const mask of rendered.masks)
78
+ console.log(mask);
79
+ await appendFile(options.githubEnv, rendered.envFile);
80
+ };
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/setup.js ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ import { constants, copyFileSync, mkdirSync } from "node:fs";
3
+ import { dirname, resolve } from "node:path";
4
+ import { parseArgs } from "node:util";
5
+ const { values, positionals } = parseArgs({
6
+ options: { "replace-app-json": { type: "boolean" } },
7
+ allowPositionals: true,
8
+ });
9
+ const [target = ".", ...extra] = positionals;
10
+ if (extra.length) {
11
+ throw new Error("Usage: expo-release-setup [target-directory] [--replace-app-json]");
12
+ }
13
+ const templates = {
14
+ "app.json": "app.json",
15
+ "app.config.ts.example": "app.config.ts",
16
+ "eas.json": "eas.json",
17
+ "easignore.example": ".easignore",
18
+ "npmrc.example": ".npmrc.example",
19
+ "env.production.example": ".env.production",
20
+ "inputs.example.env": "inputs.example.env",
21
+ "zap.yaml": "zap.yaml",
22
+ "scripts-context.md": "context/scripts.md",
23
+ ".github/workflows/ci.yml": ".github/workflows/ci.yml",
24
+ ".github/workflows/release.yml": ".github/workflows/release.yml",
25
+ ".github/workflows/test-eas-connection.yml": ".github/workflows/test-eas-connection.yml",
26
+ };
27
+ for (const [template, relative] of Object.entries(templates)) {
28
+ const destination = resolve(target, relative);
29
+ mkdirSync(dirname(destination), { recursive: true });
30
+ const replace = relative === "app.json" && values["replace-app-json"];
31
+ try {
32
+ copyFileSync(new URL(`../templates/${template}`, import.meta.url), destination, replace ? 0 : constants.COPYFILE_EXCL);
33
+ console.log(`Wrote ${relative}`);
34
+ }
35
+ catch (error) {
36
+ if (error.code !== "EEXIST")
37
+ throw error;
38
+ console.log(`Kept existing ${relative}`);
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "@mp-lb/expo-release",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Shared Expo project setup and release tooling.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=22"
9
+ },
10
+ "bin": {
11
+ "expo-release-apply-inputs": "dist/applyInputs.js",
12
+ "expo-release-icons": "dist/generateIcons.js",
13
+ "expo-release-setup": "dist/setup.js"
14
+ },
15
+ "files": [
16
+ "actions",
17
+ "dist",
18
+ "templates",
19
+ "README.md"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "build": "tsc -p tsconfig.json && chmod +x dist/applyInputs.js dist/generateIcons.js dist/setup.js",
26
+ "typecheck": "tsc -p tsconfig.test.json",
27
+ "test": "node --import tsx --test src/*.test.ts"
28
+ },
29
+ "dependencies": {
30
+ "@mp-lb/env-mapper": "0.2.1",
31
+ "@mp-lb/forum-secrets": "0.2.1",
32
+ "sharp": "0.34.5"
33
+ }
34
+ }
@@ -0,0 +1,23 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ validate:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ with:
16
+ path: app
17
+ persist-credentials: false
18
+ - name: Install shared Expo tooling
19
+ run: npm install --prefix .expo-tools --no-save --no-package-lock --registry https://registry.npmjs.org @mp-lb/expo-release@0.1.0
20
+ - uses: ./.expo-tools/node_modules/@mp-lb/expo-release/actions/mobile
21
+ with:
22
+ mode: ci
23
+ secrets-key: ${{ secrets.SECRETS_KEY }}
@@ -0,0 +1,32 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+ inputs:
8
+ mode:
9
+ description: Expo release operation
10
+ type: choice
11
+ options: [release, sync]
12
+ default: release
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ concurrency: release-main
18
+
19
+ jobs:
20
+ deploy:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ path: app
26
+ persist-credentials: false
27
+ - name: Install shared Expo tooling
28
+ run: npm install --prefix .expo-tools --no-save --no-package-lock --registry https://registry.npmjs.org @mp-lb/expo-release@0.1.0
29
+ - uses: ./.expo-tools/node_modules/@mp-lb/expo-release/actions/mobile
30
+ with:
31
+ mode: ${{ inputs.mode || 'release' }}
32
+ secrets-key: ${{ secrets.SECRETS_KEY }}
@@ -0,0 +1,22 @@
1
+ name: Test EAS Connection
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ permissions:
7
+ contents: read
8
+
9
+ jobs:
10
+ test-connection:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ path: app
16
+ persist-credentials: false
17
+ - name: Install shared Expo tooling
18
+ run: npm install --prefix .expo-tools --no-save --no-package-lock --registry https://registry.npmjs.org @mp-lb/expo-release@0.1.0
19
+ - uses: ./.expo-tools/node_modules/@mp-lb/expo-release/actions/mobile
20
+ with:
21
+ mode: connection
22
+ secrets-key: ${{ secrets.SECRETS_KEY }}
@@ -0,0 +1,47 @@
1
+ import type { ConfigContext, ExpoConfig } from "expo/config";
2
+ import packageJson from "./package.json";
3
+
4
+ function hasResolvedProjectId(projectId: unknown): projectId is string {
5
+ return (
6
+ typeof projectId === "string" &&
7
+ projectId.length > 0 &&
8
+ !projectId.startsWith("REPLACE_WITH_")
9
+ );
10
+ }
11
+
12
+ // Static config lives in app.json. This wrapper keeps the app's marketing
13
+ // version in lockstep with package.json, which the mobile repo maintains; build numbers
14
+ // are managed remotely by EAS (appVersionSource: remote + autoIncrement).
15
+ export default ({ config }: ConfigContext): ExpoConfig => {
16
+ const resolvedConfig: ExpoConfig = {
17
+ ...(config as ExpoConfig),
18
+ version: packageJson.version,
19
+ };
20
+
21
+ const projectId = resolvedConfig.extra?.eas?.projectId;
22
+ if (!hasResolvedProjectId(projectId)) {
23
+ const extra = { ...(resolvedConfig.extra ?? {}) };
24
+ const eas = extra.eas;
25
+
26
+ if (eas && typeof eas === "object") {
27
+ const nextEas = { ...(eas as Record<string, unknown>) };
28
+ delete nextEas.projectId;
29
+
30
+ if (Object.keys(nextEas).length > 0) {
31
+ extra.eas = nextEas;
32
+ } else {
33
+ delete extra.eas;
34
+ }
35
+ }
36
+
37
+ resolvedConfig.extra = extra;
38
+ delete resolvedConfig.updates;
39
+ } else {
40
+ resolvedConfig.updates = {
41
+ ...(resolvedConfig.updates ?? {}),
42
+ url: `https://u.expo.dev/${projectId}`,
43
+ };
44
+ }
45
+
46
+ return resolvedConfig;
47
+ };
@@ -0,0 +1,76 @@
1
+ {
2
+ "expo": {
3
+ "name": "REPLACE_WITH_APP_NAME",
4
+ "slug": "REPLACE_WITH_APP_SLUG",
5
+ "scheme": "REPLACE_WITH_URL_SCHEME",
6
+ "owner": "REPLACE_WITH_EXPO_OWNER",
7
+ "platforms": [
8
+ "ios",
9
+ "android",
10
+ "web"
11
+ ],
12
+ "version": "1.0.0",
13
+ "runtimeVersion": {
14
+ "policy": "fingerprint"
15
+ },
16
+ "orientation": "portrait",
17
+ "icon": "./assets/images/icon.png",
18
+ "userInterfaceStyle": "light",
19
+ "backgroundColor": "#FFFFFF",
20
+ "ios": {
21
+ "supportsTablet": true,
22
+ "bundleIdentifier": "REPLACE_WITH_IOS_BUNDLE_ID",
23
+ "config": {
24
+ "usesNonExemptEncryption": false
25
+ }
26
+ },
27
+ "android": {
28
+ "package": "REPLACE_WITH_ANDROID_PACKAGE",
29
+ "adaptiveIcon": {
30
+ "backgroundColor": "#FFFFFF",
31
+ "foregroundImage": "./assets/images/android-icon-foreground.png",
32
+ "backgroundImage": "./assets/images/android-icon-background.png",
33
+ "monochromeImage": "./assets/images/android-icon-monochrome.png"
34
+ },
35
+ "softwareKeyboardLayoutMode": "pan",
36
+ "intentFilters": [
37
+ {
38
+ "action": "VIEW",
39
+ "data": [
40
+ {
41
+ "scheme": "REPLACE_WITH_URL_SCHEME"
42
+ }
43
+ ],
44
+ "category": [
45
+ "BROWSABLE",
46
+ "DEFAULT"
47
+ ]
48
+ }
49
+ ]
50
+ },
51
+ "plugins": [
52
+ "expo-router",
53
+ [
54
+ "expo-splash-screen",
55
+ {
56
+ "image": "./assets/images/splash-icon.png",
57
+ "imageWidth": 200,
58
+ "resizeMode": "contain",
59
+ "backgroundColor": "#FFFFFF"
60
+ }
61
+ ]
62
+ ],
63
+ "experiments": {
64
+ "typedRoutes": true
65
+ },
66
+ "extra": {
67
+ "router": {},
68
+ "eas": {
69
+ "projectId": "REPLACE_WITH_EAS_PROJECT_ID"
70
+ }
71
+ },
72
+ "updates": {
73
+ "url": "https://u.expo.dev/REPLACE_WITH_EAS_PROJECT_ID"
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "cli": {
3
+ "version": ">=13.4.2",
4
+ "appVersionSource": "remote"
5
+ },
6
+ "build": {
7
+ "development": {
8
+ "distribution": "internal",
9
+ "autoIncrement": true,
10
+ "channel": "development",
11
+ "developmentClient": true,
12
+ "node": "22.17.1",
13
+ "environment": "development"
14
+ },
15
+ "production": {
16
+ "distribution": "store",
17
+ "autoIncrement": true,
18
+ "channel": "production",
19
+ "node": "22.17.1",
20
+ "environment": "production"
21
+ }
22
+ },
23
+ "submit": {
24
+ "production": {
25
+ "ios": {
26
+ "ascAppId": "REPLACE_WITH_APP_STORE_CONNECT_APP_ID"
27
+ },
28
+ "android": {
29
+ "track": "internal"
30
+ }
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,53 @@
1
+ # When .easignore exists, EAS uses it instead of .gitignore — keep the
2
+ # .gitignore entries here too.
3
+
4
+ # dependencies
5
+ node_modules/
6
+
7
+ # Expo
8
+ .expo/
9
+ .zap/
10
+ dist/
11
+ web-build/
12
+ expo-env.d.ts
13
+
14
+ # Native
15
+ .kotlin/
16
+ *.orig.*
17
+ *.jks
18
+ *.p8
19
+ *.p12
20
+ *.key
21
+ *.mobileprovision
22
+
23
+ # Metro
24
+ .metro-health-check*
25
+
26
+ # debug
27
+ npm-debug.*
28
+ yarn-debug.*
29
+ yarn-error.*
30
+
31
+ # macOS
32
+ .DS_Store
33
+ *.pem
34
+
35
+ # local env files
36
+ .env
37
+ .env*.local
38
+
39
+ # decrypted secrets
40
+ secrets.json
41
+
42
+ # typescript
43
+ *.tsbuildinfo
44
+
45
+ # generated native folders
46
+ /ios
47
+ /android
48
+
49
+ # Not needed for builds: shared docs store (large media), CI, docs
50
+ docs/
51
+ .github/
52
+ mvp.md
53
+ README.md
@@ -0,0 +1,3 @@
1
+ EXPO_PUBLIC_APP_ENV=production
2
+ EXPO_PUBLIC_API_BASE_URL=REPLACE_WITH_API_BASE_URL
3
+ EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY=REPLACE_WITH_CLERK_PUBLISHABLE_KEY
@@ -0,0 +1,24 @@
1
+ # Copy to inputs.env and fill in the project values. Keep secrets in CI.
2
+
3
+ APP_NAME=Doctrine
4
+ APP_SLUG=doctrine-mobile
5
+ URL_SCHEME=doctrine
6
+ EXPO_OWNER=mp-lb
7
+
8
+ # Permanent identity — cannot be changed after first store submission.
9
+ # iOS allows hyphens; Android package does not.
10
+ IOS_BUNDLE_ID=com.mp-lb.doctrine
11
+ ANDROID_PACKAGE=com.mplb.doctrine
12
+
13
+ # From App Store Connect (numeric "Apple ID" on the app's App Information
14
+ # page) and the Apple Developer membership page.
15
+ APP_STORE_CONNECT_APP_ID=6779461527
16
+ APPLE_TEAM_ID=A1B2C3D4E5
17
+
18
+ # Production endpoints. The Clerk key is the *publishable* (pk_live_) key —
19
+ # it base64-encodes the frontend API domain, so it changes if the domain does.
20
+ API_BASE_URL=https://api.doctrine.example
21
+ CLERK_PUBLISHABLE_KEY=pk_live_xxxx
22
+
23
+ # Written by `eas init`; leave blank until then.
24
+ EAS_PROJECT_ID=
@@ -0,0 +1,3 @@
1
+ legacy-peer-deps=true
2
+ @YOUR_SCOPE:registry=https://npm.pkg.github.com/
3
+ //npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
@@ -0,0 +1 @@
1
+ Write project scripts in TypeScript in the package that owns the behaviour, or `packages/scripts` when there is no natural owner, and include them in normal lint and typecheck checks. Expose each script as a thin Zap task that invokes it with `tsx` (for example, `zap t somemigration` runs `packages/scripts/somemigration.ts`); keep CI callers aligned when moving scripts.
@@ -0,0 +1,55 @@
1
+ project: REPLACE_WITH_APP_SLUG
2
+ env: [.env.local, .env]
3
+ profiles:
4
+ default:
5
+ env-files: [.env.local, .env]
6
+ services: [web]
7
+ ports: [EXPO_WEB_PORT, EXPO_NATIVE_PORT]
8
+ homepage: http://localhost:${EXPO_WEB_PORT}
9
+ native:
10
+ web:
11
+ cmd: npm run web -- --port ${EXPO_WEB_PORT}
12
+ env: "*"
13
+ app:
14
+ aliases: [mobile]
15
+ cmd: npm run start -- --port ${EXPO_NATIVE_PORT}
16
+ env: "*"
17
+ tasks:
18
+ install:
19
+ env: "*"
20
+ cmds:
21
+ - npm install {{REST}}
22
+ start:
23
+ env: "*"
24
+ cmds:
25
+ - npm run start -- --port ${EXPO_NATIVE_PORT} {{REST}}
26
+ ios:
27
+ env: "*"
28
+ cmds:
29
+ - npm run ios -- --port ${EXPO_NATIVE_PORT} {{REST}}
30
+ android:
31
+ env: "*"
32
+ cmds:
33
+ - npm run android -- --port ${EXPO_NATIVE_PORT} {{REST}}
34
+ web:
35
+ env: "*"
36
+ cmds:
37
+ - npm run web -- --port ${EXPO_WEB_PORT} {{REST}}
38
+ typecheck:
39
+ env: "*"
40
+ cmds:
41
+ - npm run typecheck
42
+ lint:
43
+ env: "*"
44
+ cmds:
45
+ - npm run lint
46
+ doctor:
47
+ env: "*"
48
+ cmds:
49
+ - npx expo-doctor
50
+ check:
51
+ env: "*"
52
+ cmds:
53
+ - zap task lint
54
+ - zap task typecheck
55
+ - zap task doctor