create-disposabl-app 0.20.7 → 0.20.9
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/dist/disposabl.js +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/default/.github/scripts/android-signatures.mjs +60 -0
- package/dist/templates/default/.github/scripts/mobile.sh +83 -30
- package/dist/templates/default/.github/scripts/release-source.sh +28 -0
- package/dist/templates/default/.github/scripts/release.sh +8 -4
- package/dist/templates/default/.github/workflows/pipeline.yml +1 -1
- package/dist/templates/default/apps/mobile/app.config.js +5 -2
- package/dist/templates/default/apps/mobile/plugins/with-android-signing.js +18 -6
- package/dist/templates/default/apps/mobile/scripts/android-release-verify.mjs +117 -0
- package/dist/templates/default/apps/mobile/scripts/verify-play-aab.mjs +9 -6
- package/dist/templates/default/package.json +1 -1
- package/dist/templates/default/packages/tests/android-failure-workflow.test.ts +27 -0
- package/dist/templates/default/packages/tests/android-ota-artifacts.test.ts +2 -0
- package/dist/templates/default/packages/tests/android-ota-selection.test.ts +13 -1
- package/dist/templates/default/packages/tests/android-release-source.test.ts +123 -0
- package/dist/templates/default/packages/tests/android-signatures.test.ts +73 -0
- package/dist/templates/default/packages/tests/ios-ota.test.ts +20 -0
- package/dist/templates/default/packages/tests/mobile-android-signing.test.ts +19 -1
- package/dist/templates/default/packages/tests/package-release.test.ts +12 -5
- package/package.json +1 -1
package/dist/disposabl.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1563,7 +1563,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
1563
1563
|
import { Command, CommanderError } from "commander";
|
|
1564
1564
|
import * as p2 from "@clack/prompts";
|
|
1565
1565
|
// package.json
|
|
1566
|
-
var version = "0.20.
|
|
1566
|
+
var version = "0.20.9";
|
|
1567
1567
|
|
|
1568
1568
|
// ../cli/telemetry.ts
|
|
1569
1569
|
var import_proper_lockfile2 = __toESM(require_proper_lockfile(), 1);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { readdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
|
|
6
|
+
export function verifySignature(file, expected, run = execute) {
|
|
7
|
+
let certificates;
|
|
8
|
+
if (file.endsWith(".apk")) {
|
|
9
|
+
const output = run("apksigner", ["verify", "--print-certs", file]);
|
|
10
|
+
certificates = [
|
|
11
|
+
...output.matchAll(
|
|
12
|
+
/^(?:Signer #\d+|V[1-4] Signer:) certificate SHA-256 digest: ([a-fA-F0-9]{64})\s*$/gm,
|
|
13
|
+
),
|
|
14
|
+
].map((m) => m[1].toLowerCase());
|
|
15
|
+
} else if (file.endsWith(".aab")) {
|
|
16
|
+
const output = run("jarsigner", ["-verify", file]);
|
|
17
|
+
if (
|
|
18
|
+
!output.includes("jar verified.") ||
|
|
19
|
+
output.includes("unsigned entries")
|
|
20
|
+
)
|
|
21
|
+
throw new Error("Bundle signature verification failed");
|
|
22
|
+
const info = run("keytool", ["-printcert", "-jarfile", file]);
|
|
23
|
+
certificates = [
|
|
24
|
+
...info.matchAll(
|
|
25
|
+
/^\s*SHA256: ((?:[a-fA-F0-9]{2}:){31}[a-fA-F0-9]{2})\s*$/gm,
|
|
26
|
+
),
|
|
27
|
+
].map((m) => m[1].replaceAll(":", "").toLowerCase());
|
|
28
|
+
} else throw new Error("Expected an APK or AAB");
|
|
29
|
+
if (
|
|
30
|
+
certificates.length !== 1 ||
|
|
31
|
+
(expected !== "fallback" && certificates[0] !== expected)
|
|
32
|
+
)
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Artifact signer does not match the selected signing identity",
|
|
35
|
+
);
|
|
36
|
+
return certificates[0];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function execute(command, args) {
|
|
40
|
+
if (command === "apksigner") {
|
|
41
|
+
const sdk = process.env.ANDROID_HOME || process.env.ANDROID_SDK_ROOT;
|
|
42
|
+
if (!sdk)
|
|
43
|
+
throw new Error("Android SDK is required for signature verification");
|
|
44
|
+
const directory = join(sdk, "build-tools");
|
|
45
|
+
const versions = readdirSync(directory)
|
|
46
|
+
.filter((v) => /^\d+\.\d+\.\d+$/.test(v))
|
|
47
|
+
.sort((a, b) => b.localeCompare(a, "en", { numeric: true }));
|
|
48
|
+
if (!versions.length) throw new Error("Android build-tools are missing");
|
|
49
|
+
command = join(directory, versions[0], "apksigner");
|
|
50
|
+
}
|
|
51
|
+
return execFileSync(command, args, {
|
|
52
|
+
encoding: "utf8",
|
|
53
|
+
timeout: 30_000,
|
|
54
|
+
maxBuffer: 1024 * 1024,
|
|
55
|
+
env: { ...process.env, LANG: "C", LC_ALL: "C" },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
60
|
+
console.log(verifySignature(process.argv[2], process.argv[3]));
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
|
+
set +x
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/release-source.sh"
|
|
5
|
+
signing() {
|
|
6
|
+
# Arm cleanup before decoding or validating any private key material.
|
|
7
|
+
signing_temp=$(mktemp -d "$RUNNER_TEMP/android-signing.XXXXXX")
|
|
8
|
+
trap 'status=$?; rm -f "$signing_temp/upload.jks" "$signing_temp/check.p12"; rmdir "$signing_temp"; exit "$status"' EXIT
|
|
9
|
+
trap 'exit 130' INT
|
|
10
|
+
trap 'exit 143' TERM
|
|
11
|
+
unset ANDROID_KEYSTORE_PATH
|
|
12
|
+
ANDROID_SIGNING_MODE=fallback
|
|
13
|
+
ANDROID_SIGNING_ID=fallback
|
|
14
|
+
if [[ -n "${DISPOSABL_ANDROID_SIGNING:-}" ]]; then
|
|
15
|
+
[[ -z "${ANDROID_KEYSTORE_BASE64:-}${ANDROID_KEYSTORE_PASSWORD:-}${ANDROID_KEY_ALIAS:-}${ANDROID_KEY_PASSWORD:-}" ]] || { echo 'Conflicting Android signing inputs' >&2; return 1; }
|
|
16
|
+
local values
|
|
17
|
+
values=$(jq -er '[.keystoreBase64, .storePassword, .keyAlias, .keyPassword] | if all(.[]; type == "string" and length > 0 and (contains("\n") | not) and (contains("\r") | not)) then .[] else error("Invalid Android signing bundle") end' <<< "$DISPOSABL_ANDROID_SIGNING")
|
|
18
|
+
local -a parts
|
|
19
|
+
parts=()
|
|
20
|
+
while IFS= read -r value; do parts+=("$value"); done <<< "$values"
|
|
21
|
+
export ANDROID_KEYSTORE_BASE64="${parts[0]}" ANDROID_KEYSTORE_PASSWORD="${parts[1]}" ANDROID_KEY_ALIAS="${parts[2]}" ANDROID_KEY_PASSWORD="${parts[3]}"
|
|
22
|
+
for value in "${parts[@]}"; do printf '::add-mask::%s\n' "${value//%/%25}"; done
|
|
23
|
+
fi
|
|
24
|
+
if [[ -n "${ANDROID_KEYSTORE_BASE64:-}${ANDROID_KEYSTORE_PASSWORD:-}${ANDROID_KEY_ALIAS:-}${ANDROID_KEY_PASSWORD:-}" ]]; then
|
|
25
|
+
[[ -n "${ANDROID_KEYSTORE_BASE64:-}" && -n "${ANDROID_KEYSTORE_PASSWORD:-}" && -n "${ANDROID_KEY_ALIAS:-}" && -n "${ANDROID_KEY_PASSWORD:-}" ]] || { echo 'Incomplete Android signing credentials' >&2; return 1; }
|
|
26
|
+
export ANDROID_KEYSTORE_PATH="$signing_temp/upload.jks"
|
|
27
|
+
(umask 077; printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH")
|
|
28
|
+
keytool -list -keystore "$ANDROID_KEYSTORE_PATH" -storepass:env ANDROID_KEYSTORE_PASSWORD -alias "$ANDROID_KEY_ALIAS" >/dev/null
|
|
29
|
+
local check="$signing_temp/check.p12"
|
|
30
|
+
keytool -importkeystore -noprompt -srckeystore "$ANDROID_KEYSTORE_PATH" -srcstorepass:env ANDROID_KEYSTORE_PASSWORD -srcalias "$ANDROID_KEY_ALIAS" -srckeypass:env ANDROID_KEY_PASSWORD -destkeystore "$check" -deststoretype PKCS12 -deststorepass:env ANDROID_KEYSTORE_PASSWORD >/dev/null 2>&1 || { echo 'Invalid Android key password' >&2; return 1; }
|
|
31
|
+
rm -f "$check"
|
|
32
|
+
ANDROID_SIGNING_MODE=release
|
|
33
|
+
ANDROID_SIGNING_ID=$(keytool -exportcert -keystore "$ANDROID_KEYSTORE_PATH" -storepass:env ANDROID_KEYSTORE_PASSWORD -alias "$ANDROID_KEY_ALIAS" | sha256sum | cut -d' ' -f1)
|
|
34
|
+
fi
|
|
35
|
+
export ANDROID_SIGNING_MODE ANDROID_SIGNING_ID
|
|
36
|
+
}
|
|
3
37
|
manifest() {
|
|
4
|
-
bun x --no-install expo config --json | jq -ce --arg channel "${CHANNEL:-}" --arg runtime "${RUNTIME:-}" '
|
|
38
|
+
bun x --no-install expo config --json | jq -ce --arg channel "${CHANNEL:-}" --arg runtime "${RUNTIME:-}" --arg signing "${ANDROID_SIGNING_MODE:-fallback}" --arg signingId "${ANDROID_SIGNING_ID:-fallback}" '
|
|
5
39
|
def required($name): if type == "string" and (test("[^[:space:]]")) then . else error("Missing or invalid " + $name) end;
|
|
6
|
-
{channel: ($channel | required("channel")), projectId: (.extra.eas.projectId | required("projectId")), applicationId: (.android.package | required("applicationId")), runtimeVersion: ($runtime | required("runtimeVersion") | if test("^[a-f0-9]{40,64}$") then . else error("Invalid runtimeVersion") end), androidArchitectures: (.extra.disposablAndroidArchitectures | if type == "array" and length > 0 then . else error("Missing Android architectures") end)}
|
|
40
|
+
{signing: $signing, signingId: $signingId, channel: ($channel | required("channel")), projectId: (.extra.eas.projectId | required("projectId")), applicationId: (.android.package | required("applicationId")), runtimeVersion: ($runtime | required("runtimeVersion") | if test("^[a-f0-9]{40,64}$") then . else error("Invalid runtimeVersion") end), androidArchitectures: (.extra.disposablAndroidArchitectures | if type == "array" and length > 0 then . else error("Missing Android architectures") end)}
|
|
7
41
|
'
|
|
8
42
|
}
|
|
9
43
|
case "${1:?operation required}" in
|
|
@@ -41,7 +75,7 @@ bun -e '
|
|
|
41
75
|
if (value !== process.env[backend[1]]) throw new Error(`EAS overrides the deployed backend: ${key}`);
|
|
42
76
|
continue;
|
|
43
77
|
}
|
|
44
|
-
if (/^(GITHUB_|RUNNER_|GH_|DISPOSABL_|BUN_|CI$|NODE_OPTIONS$|PATH$|HOME$|SOURCE(_PATH)?$|CHANNEL$|PLATFORM$|RELEASE_PREFIX$|MACOS_|EAS_(ENVIRONMENT|CLI)$|EXPO_(TOKEN|PROJECT_ID|OWNER|SLUG|NO_DOTENV)$)/.test(key)) throw new Error(`Reserved EAS variable: ${key}`);
|
|
78
|
+
if (/^(GITHUB_|RUNNER_|GH_|DISPOSABL_|ANDROID_|UPDATE_POLICY$|BUN_|CI$|NODE_OPTIONS$|PATH$|HOME$|SOURCE(_PATH)?$|CHANNEL$|PLATFORM$|RELEASE_PREFIX$|MACOS_|EAS_(ENVIRONMENT|CLI)$|EXPO_(TOKEN|PROJECT_ID|OWNER|SLUG|NO_DOTENV)$)/.test(key)) throw new Error(`Reserved EAS variable: ${key}`);
|
|
45
79
|
if (key === "EXPO_PUBLIC_DISPOSABL_ANALYTICS_ENABLED") continue;
|
|
46
80
|
const delimiter = crypto.randomUUID();
|
|
47
81
|
appendFileSync(process.env.GITHUB_ENV, `${key}<<${delimiter}\n${value}\n${delimiter}\n`);
|
|
@@ -63,6 +97,7 @@ for ((offset=0; ; offset+=25)); do
|
|
|
63
97
|
done
|
|
64
98
|
;;
|
|
65
99
|
expo-fingerprint)
|
|
100
|
+
signing
|
|
66
101
|
artifact=android.apk
|
|
67
102
|
export artifact
|
|
68
103
|
for ((page=1; ; page++)); do
|
|
@@ -78,20 +113,12 @@ bun -e '
|
|
|
78
113
|
const wanted = JSON.parse(process.env.MANIFEST);
|
|
79
114
|
const release = await Bun.file(`${process.env.RUNNER_TEMP}/release.json`).json();
|
|
80
115
|
const prior = JSON.parse(/<!-- android (\{[^\n]+\}) -->/.exec(release.body || "")?.[1] || "null");
|
|
81
|
-
const reusable = prior && Object.keys(wanted).every(k => JSON.stringify(prior[k]) === JSON.stringify(wanted[k])) && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === process.env.artifact && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
|
|
82
|
-
|
|
83
|
-
if (blocked) {
|
|
84
|
-
const reason = "Configure Android production signing credentials before building a production APK.";
|
|
85
|
-
console.error(`::notice::${reason}`);
|
|
86
|
-
const report = Bun.spawnSync(["node", ".github/scripts/disposabl.mjs", "report", "android", "blocked", reason], {
|
|
87
|
-
cwd: process.env.GITHUB_WORKSPACE, stdout: "inherit", stderr: "inherit",
|
|
88
|
-
});
|
|
89
|
-
if (report.exitCode) throw new Error("Cannot report Android prerequisites.");
|
|
90
|
-
}
|
|
91
|
-
console.log(`build=${blocked ? "blocked" : !reusable}\nruntime=${wanted.runtimeVersion}\ntag=${reusable ? release.tag_name : ""}\nsha=${reusable ? prior.sha256 : ""}`);
|
|
116
|
+
const reusable = wanted.signing === "fallback" && process.env.ANDROID_PLAY_SUBMIT !== "true" && prior && Object.keys(wanted).every(k => JSON.stringify(prior[k]) === JSON.stringify(wanted[k])) && /^[a-f0-9]{64}$/.test(prior.sha256 || "") && release.assets.some(a => a.name === process.env.artifact && a.state === "uploaded" && a.size > 0 && a.digest === `sha256:${prior.sha256}`);
|
|
117
|
+
console.log(`build=${!reusable}\nruntime=${wanted.runtimeVersion}\ntag=${reusable ? release.tag_name : ""}\nsha=${reusable ? prior.sha256 : ""}`);
|
|
92
118
|
' >> "$GITHUB_OUTPUT"
|
|
93
119
|
;;
|
|
94
120
|
expo-update)
|
|
121
|
+
signing
|
|
95
122
|
artifact=android.apk
|
|
96
123
|
mkdir -p dist/release
|
|
97
124
|
gh release download "$TAG" --pattern "$artifact" --dir dist/release
|
|
@@ -100,7 +127,7 @@ cd apps/mobile
|
|
|
100
127
|
MANIFEST=$(manifest)
|
|
101
128
|
bun x --no-install expo export --platform android --output-dir dist/update
|
|
102
129
|
test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
|
|
103
|
-
|
|
130
|
+
verify_release_source android
|
|
104
131
|
bun x "$EAS_CLI" update --platform android --channel "$CHANNEL" --environment "$EAS_ENVIRONMENT" --skip-bundler --input-dir dist/update --message "$SOURCE" --non-interactive
|
|
105
132
|
jq --arg sha "$SHA" --arg tag "$TAG" '. + {sha256: $sha, action: "update", sourceTag: $tag}' <<< "$MANIFEST" > ../../dist/release/android.json
|
|
106
133
|
# The trusted publisher retrieves this verified binary from its existing release.
|
|
@@ -108,22 +135,12 @@ jq --arg sha "$SHA" --arg tag "$TAG" '. + {sha256: $sha, action: "update", sourc
|
|
|
108
135
|
rm "../../dist/release/$artifact"
|
|
109
136
|
;;
|
|
110
137
|
android-build)
|
|
138
|
+
signing
|
|
111
139
|
bash ../../.github/scripts/android-runner.sh check
|
|
112
140
|
MANIFEST=$(manifest)
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
signing_values=$(jq -er '[.keystoreBase64, .storePassword, .keyAlias, .keyPassword] | if all(.[]; type == "string" and length > 0 and (contains("\n") | not) and (contains("\r") | not)) then .[] else error("Invalid Android signing bundle") end' <<< "$DISPOSABL_ANDROID_SIGNING")
|
|
117
|
-
mapfile -t signing <<< "$signing_values"
|
|
118
|
-
for value in "${signing[@]}"; do printf '::add-mask::%s\n' "${value//%/%25}"; done
|
|
119
|
-
export ANDROID_KEYSTORE_BASE64="${signing[0]}" ANDROID_KEYSTORE_PASSWORD="${signing[1]}" ANDROID_KEY_ALIAS="${signing[2]}" ANDROID_KEY_PASSWORD="${signing[3]}"
|
|
120
|
-
unset signing_values signing value DISPOSABL_ANDROID_SIGNING
|
|
121
|
-
fi
|
|
122
|
-
: "${ANDROID_KEYSTORE_BASE64:?}" "${ANDROID_KEYSTORE_PASSWORD:?}" "${ANDROID_KEY_ALIAS:?}" "${ANDROID_KEY_PASSWORD:?}"
|
|
123
|
-
export ANDROID_KEYSTORE_PATH="$RUNNER_TEMP/android-release.jks"
|
|
124
|
-
trap 'rm -f "$ANDROID_KEYSTORE_PATH"' EXIT
|
|
125
|
-
(umask 077; printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH")
|
|
126
|
-
fi
|
|
141
|
+
bun x --no-install expo config --json > "$RUNNER_TEMP/android-config.json"
|
|
142
|
+
node scripts/android-release-verify.mjs inputs "$RUNNER_TEMP/android-config.json" "$MANIFEST"
|
|
143
|
+
verify_release_source android
|
|
127
144
|
bun x --no-install expo prebuild --platform android --no-install
|
|
128
145
|
test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
|
|
129
146
|
artifact=android.apk
|
|
@@ -131,12 +148,48 @@ binary=android/app/build/outputs/apk/release/app-release.apk
|
|
|
131
148
|
fingerprint=assets/fingerprint
|
|
132
149
|
|
|
133
150
|
(cd android && bash ../../../.github/scripts/android-runner.sh build)
|
|
151
|
+
if [[ "$CHANNEL" == production && "$ANDROID_SIGNING_MODE" == release ]]; then
|
|
152
|
+
(cd android && ./gradlew :app:bundleRelease --no-daemon --build-cache)
|
|
153
|
+
test -s android/app/build/outputs/bundle/release/app-release.aab
|
|
154
|
+
mkdir -p ../../dist/release
|
|
155
|
+
cp android/app/build/outputs/bundle/release/app-release.aab ../../dist/release/android.aab
|
|
156
|
+
else
|
|
157
|
+
echo 'Fallback-signed APK is not Play-ready.'
|
|
158
|
+
fi
|
|
134
159
|
node ../../.github/scripts/verify-android-abis.mjs "$binary" "$MANIFEST"
|
|
160
|
+
certificate=$(node ../../.github/scripts/android-signatures.mjs "$binary" "$ANDROID_SIGNING_ID")
|
|
161
|
+
node scripts/android-release-verify.mjs artifact "$RUNNER_TEMP/android-config.json" "$MANIFEST" "$binary" "$certificate"
|
|
162
|
+
if [[ "$CHANNEL" == production && "$ANDROID_SIGNING_MODE" == release ]]; then
|
|
163
|
+
node ../../.github/scripts/android-signatures.mjs ../../dist/release/android.aab "$certificate" >/dev/null
|
|
164
|
+
node scripts/android-release-verify.mjs artifact "$RUNNER_TEMP/android-config.json" "$MANIFEST" ../../dist/release/android.aab "$certificate"
|
|
165
|
+
fi
|
|
135
166
|
test "$(unzip -p "$binary" "$fingerprint")" = "$RUNTIME"
|
|
136
167
|
test "$(bun x --no-install expo-updates runtimeversion:resolve --platform android --workflow managed | jq -er .runtimeVersion)" = "$RUNTIME"
|
|
137
168
|
mkdir -p ../../dist/release
|
|
138
169
|
cp "$binary" "../../dist/release/$artifact"
|
|
139
|
-
|
|
170
|
+
aab_sha=""
|
|
171
|
+
if [[ -f ../../dist/release/android.aab ]]; then aab_sha=$(sha256sum ../../dist/release/android.aab | cut -d' ' -f1); fi
|
|
172
|
+
jq --arg sha "$(sha256sum "$binary" | cut -d' ' -f1)" --arg aab "$aab_sha" --arg certificate "$certificate" '. + {sha256: $sha, aabSha256: $aab, certificateSha256: $certificate, action: "build"}' <<< "$MANIFEST" > ../../dist/release/android.json
|
|
173
|
+
;;
|
|
174
|
+
android-submit)
|
|
175
|
+
: "${EXPO_TOKEN:?Expo token required}" "${EXPO_PROJECT_ID:?Expo project required}" "${ANDROID_PLAY_SERVICE_ACCOUNT:?Play service account required}" "${ANDROID_PLAY_TRACK:?Play track required}" "${ANDROID_PLAY_UPLOAD_CERT_SHA256:?Play upload certificate SHA256 required}"
|
|
176
|
+
[[ "$ANDROID_PLAY_TRACK" =~ ^(internal|alpha|beta|production)$ ]] || { echo 'Invalid Play track' >&2; exit 1; }
|
|
177
|
+
[[ "$ANDROID_PLAY_UPLOAD_CERT_SHA256" =~ ^[a-f0-9]{64}$ ]] || { echo 'Invalid Play upload certificate SHA256' >&2; exit 1; }
|
|
178
|
+
jq -e --arg cert "$ANDROID_PLAY_UPLOAD_CERT_SHA256" '.signing == "release" and .signingId == $cert' ../../dist/release/android.json >/dev/null || { echo 'Android upload certificate mismatch' >&2; exit 1; }
|
|
179
|
+
test -s ../../dist/release/android.aab || { echo 'Signed Android bundle required for submission' >&2; exit 1; }
|
|
180
|
+
printf '%s %s\n' "$(jq -er '.aabSha256 | select(test("^[a-f0-9]{64}$"))' ../../dist/release/android.json)" ../../dist/release/android.aab | sha256sum -c -
|
|
181
|
+
node ../../.github/scripts/android-signatures.mjs ../../dist/release/android.aab "$ANDROID_PLAY_UPLOAD_CERT_SHA256" >/dev/null
|
|
182
|
+
jq -e '.type == "service_account" and (.client_email | type == "string" and length > 0) and (.private_key | type == "string" and length > 0)' <<< "$ANDROID_PLAY_SERVICE_ACCOUNT" >/dev/null
|
|
183
|
+
submit_temp=$(mktemp -d "$RUNNER_TEMP/android-submit.XXXXXX")
|
|
184
|
+
key="$submit_temp/play-service-account.json"
|
|
185
|
+
trap 'status=$?; if [[ -f "$submit_temp/eas-original.json" ]]; then mv "$submit_temp/eas-original.json" eas.json; fi; rm -f "$key"; rmdir "$submit_temp"; exit "$status"' EXIT
|
|
186
|
+
trap 'exit 130' INT
|
|
187
|
+
trap 'exit 143' TERM
|
|
188
|
+
cp eas.json "$submit_temp/eas-original.json"
|
|
189
|
+
(umask 077; printf '%s' "$ANDROID_PLAY_SERVICE_ACCOUNT" > "$key")
|
|
190
|
+
jq --arg key "$key" --arg track "$ANDROID_PLAY_TRACK" '.submit.production.android = {serviceAccountKeyPath: $key, track: $track, releaseStatus: "draft"}' "$submit_temp/eas-original.json" > eas.json
|
|
191
|
+
verify_release_source android
|
|
192
|
+
bun x "$EAS_CLI" submit --platform android --profile production --path ../../dist/release/android.aab --non-interactive --wait
|
|
140
193
|
;;
|
|
141
194
|
*) echo "Unknown operation: $1" >&2; exit 1 ;;
|
|
142
195
|
esac
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Product Android releases are immutable queued main builds. Other artifacts
|
|
4
|
+
# and PR updates retain their current-head requirement.
|
|
5
|
+
verify_release_source() {
|
|
6
|
+
local platform=${1:?platform required} context=${2:-build} comparison path
|
|
7
|
+
if [[ "$platform" == android && "${CHANNEL:-}" == production && "${GH_REPO:-}" == disposabl-dev/create-disposabl-app && "${GITHUB_EVENT_NAME:-}" == push ]]; then
|
|
8
|
+
[[ "${GITHUB_REF:-}" == refs/heads/main && "${SOURCE:-}" =~ ^[0-9a-f]{40}$ && "${GITHUB_SHA:-}" == "$SOURCE" ]] || { echo 'Invalid queued Android source' >&2; return 1; }
|
|
9
|
+
# The artifact publisher deliberately executes trusted main scripts instead
|
|
10
|
+
# of the build checkout. Its source still must match the originating event.
|
|
11
|
+
if [[ "$context" != publish ]]; then
|
|
12
|
+
comparison=$(git rev-parse HEAD) || return 1
|
|
13
|
+
[[ "$comparison" == "$SOURCE" ]] || { echo 'Android checkout source mismatch' >&2; return 1; }
|
|
14
|
+
fi
|
|
15
|
+
comparison=$(gh api "repos/$GH_REPO/compare/$SOURCE...main" --jq .status) || return 1
|
|
16
|
+
case "$comparison" in
|
|
17
|
+
ahead|identical) return 0 ;;
|
|
18
|
+
*) echo 'Queued Android source is no longer on main' >&2; return 1 ;;
|
|
19
|
+
esac
|
|
20
|
+
fi
|
|
21
|
+
if [[ "$context" == publish ]]; then
|
|
22
|
+
if [[ "$CHANNEL" == production ]]; then path=git/ref/heads/main; else path="pulls/${PR:?PR required}"; fi
|
|
23
|
+
else
|
|
24
|
+
path=${SOURCE_PATH:?source path required}
|
|
25
|
+
fi
|
|
26
|
+
comparison=$(gh api "repos/$GH_REPO/$path" --jq 'if has("head") then (if .state == "open" then .head.sha else "closed" end) else .object.sha end') || return 1
|
|
27
|
+
[[ "$comparison" == "$SOURCE" ]]
|
|
28
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
set -euo pipefail
|
|
3
|
+
source "$(dirname "${BASH_SOURCE[0]}")/release-source.sh"
|
|
3
4
|
case "${1:?operation required}" in
|
|
4
5
|
package-release)
|
|
5
6
|
[[ -f "packages/$PACKAGE/package.json" ]] || exit 0
|
|
@@ -46,8 +47,7 @@ echo "PR=$pr" >> "$GITHUB_ENV"
|
|
|
46
47
|
;;
|
|
47
48
|
release-publish)
|
|
48
49
|
check_source() {
|
|
49
|
-
|
|
50
|
-
else test "$(gh api "repos/$GH_REPO/pulls/$PR" --jq 'if .state == "open" then .head.sha else "closed" end')" = "$SOURCE"; fi
|
|
50
|
+
verify_release_source "$platform" publish
|
|
51
51
|
}
|
|
52
52
|
# Desktop installers publish only from main. Android retains PR previews.
|
|
53
53
|
for platform in android linux windows macos; do
|
|
@@ -70,7 +70,7 @@ for platform in android linux windows macos; do
|
|
|
70
70
|
const wanted = JSON.parse(readFileSync(process.env.ANDROID_MANIFEST, "utf8"));
|
|
71
71
|
const release = JSON.parse(readFileSync(`${process.env.RUNNER_TEMP}/android-source.json`, "utf8"));
|
|
72
72
|
const prior = JSON.parse(/<!-- android (\{[^\n]+\}) -->/.exec(release.body || "")?.[1] || "null");
|
|
73
|
-
const fields = ["channel", "projectId", "applicationId", "runtimeVersion", "sha256"];
|
|
73
|
+
const fields = ["channel", "projectId", "applicationId", "runtimeVersion", "signing", "signingId", "sha256"];
|
|
74
74
|
if (release.draft !== false || !prior || wanted.channel !== process.env.CHANNEL
|
|
75
75
|
|| !/^[a-f0-9]{40,64}$/.test(wanted.runtimeVersion || "") || !/^[a-f0-9]{64}$/.test(wanted.sha256 || "")
|
|
76
76
|
|| !fields.every(k => typeof wanted[k] === "string" && wanted[k].trim() && prior[k] === wanted[k])
|
|
@@ -111,12 +111,16 @@ for platform in android linux windows macos; do
|
|
|
111
111
|
done
|
|
112
112
|
;;
|
|
113
113
|
verify-artifacts)
|
|
114
|
-
check_source() {
|
|
114
|
+
check_source() { verify_release_source "$PLATFORM"; }
|
|
115
115
|
check_source
|
|
116
116
|
for file in dist/release/*; do test -f "$file"; test -s "$file"; done
|
|
117
117
|
case "$PLATFORM" in
|
|
118
118
|
android)
|
|
119
119
|
test -s dist/release/android.json
|
|
120
|
+
if jq -e '.action == "build" and .signing == "release" and .channel == "production"' dist/release/android.json >/dev/null; then
|
|
121
|
+
test -s dist/release/android.aab
|
|
122
|
+
printf '%s %s\n' "$(jq -er '.aabSha256 | select(test("^[a-f0-9]{64}$"))' dist/release/android.json)" dist/release/android.aab | sha256sum -c -
|
|
123
|
+
fi
|
|
120
124
|
if [[ ! -s dist/release/android.apk ]]; then
|
|
121
125
|
jq -e '(.action == "update") and (.sourceTag | type == "string" and length > 0)' dist/release/android.json > /dev/null
|
|
122
126
|
fi
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{name: Pipeline,"on": {pull_request: {branches: [main]},push: {branches: [main]}},permissions: {contents: read,pull-requests: read},concurrency: {group: "${{ github.workflow }}-${{ github.ref }}",cancel-in-progress: "${{ github.event_name == 'pull_request' }}"},env: {CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",DISPOSABL_MOBILE_CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",EAS_ENVIRONMENT: "${{ github.event_name == 'push' && 'production' || 'preview' }}",EAS_CLI: eas-cli@27.2.0,BUN_VERSION: 1.4.4,NODE_VERSION: "24",LINUX_RUNNER: ubuntu-24.04,WEB_RUNNER: ubuntu-24.04,WINDOWS_RUNNER: windows-2025,MACOS_RUNNER: macos-26,RELEASE_PREFIX: app,DISPOSABL_ANDROID_VERSION_CODE: "${{ github.run_number }}",DISPOSABL_IOS_BUILD_NUMBER: "${{ github.run_number }}",GH_TOKEN: "${{ github.token }}",GH_REPO: "${{ github.repository }}",SOURCE: "${{ github.event.pull_request.head.sha || github.sha }}",SOURCE_PATH: "${{ github.event_name == 'pull_request' && format('pulls/{0}', github.event.number) || 'git/ref/heads/main' }}",DISPOSABL_RELEASE_VERSION: "1.0.${{ github.run_number }}"},jobs: {changes: {name: Select work,if: "github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository",permissions: {contents: read,pull-requests: read,actions: read},runs-on: ubuntu-24.04,timeout-minutes: 5,outputs: {linux_runner: "${{ steps.platforms.outputs.linux_runner }}",android_runner: "${{ steps.platforms.outputs.android_runner }}",macos_runner: "${{ steps.platforms.outputs.macos_runner }}",changed: "${{ steps.platforms.outputs.changed }}",android: "${{ steps.platforms.outputs.android }}",ios: "${{ steps.platforms.outputs.ios }}",desktop: "${{ steps.platforms.outputs.desktop }}",packages: "${{ steps.platforms.outputs.packages }}"},steps: [&item0 {uses: actions/checkout@v6,with: {ref: "${{ env.SOURCE }}",persist-credentials: false}},{name: Select affected platforms,shell: bash,id: platforms,env: {PR: "${{ github.event.number }}",EXPO_CONNECTED: "${{ secrets.EXPO_TOKEN != '' }}",IOS_BUILDS_ENABLED: "${{ vars.IOS_BUILDS_ENABLED != 'false' }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/platforms.sh\""}]},web: {name: Web,needs: changes,if: "needs.changes.outputs.changed == 'true'",permissions: &permissions {contents: read,pull-requests: read,id-token: write},timeout-minutes: 20,runs-on: "${{ needs.changes.outputs.linux_runner }}",outputs: {desktop: "${{ needs.changes.outputs.desktop }}",ios: "${{ needs.changes.outputs.ios }}",packages: "${{ needs.changes.outputs.packages }}",release: "${{ steps.artifacts.outcome == 'success' }}",android_build: "${{ steps.fingerprint.outputs.build }}",android_runtime: "${{ steps.fingerprint.outputs.runtime }}",convex_url: "${{ steps.deploy.outputs.CONVEX_URL }}",convex_site_url: "${{ steps.deploy.outputs.CONVEX_SITE_URL }}"},env: {PLATFORM: android,ANDROID_SIGNING_READY: "${{ secrets.DISPOSABL_ANDROID_SIGNING != '' || (secrets.ANDROID_KEYSTORE_BASE64 != '' && secrets.ANDROID_KEYSTORE_PASSWORD != '' && secrets.ANDROID_KEY_ALIAS != '' && secrets.ANDROID_KEY_PASSWORD != '') }}",EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1"},steps: [*item0,&item1 {uses: actions/setup-node@v6,with: {node-version: "24",package-manager-cache: false}},&item2 {uses: oven-sh/setup-bun@v2,with: {bun-version: 1.4.4}},&item3 {uses: actions/cache@v4,with: {path: ~/.bun/install/cache,key: "bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock') }}",restore-keys: "bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-"}},&item4 {run: "bun install --frozen-lockfile ${{ github.job == 'desktop' && '--filter \"*desktop*\" --filter @disposabl/backend' || (github.job == 'android' || startsWith(github.job, 'ios-')) && '--filter @disposabl/mobile' || '' }}"},{name: Report build start,run: "node .github/scripts/disposabl.mjs report web,api,mcp building\nif [[ -z \"$EXPO_TOKEN\" ]]; then node .github/scripts/disposabl.mjs report android blocked 'Connect Expo before building Android.'; fi\nif [[ '${{ github.event_name }}' == pull_request ]]; then node .github/scripts/disposabl.mjs report cli,typescript-sdk blocked 'Packages publish after merge to main.'; fi\n"},{name: Check,run: bun run check},{name: Build selected clients,run: "for package in cli sdk; do\n if test -f \"packages/$package/package.json\"; then bun run --cwd \"packages/$package\" build; fi\ndone\n"},{name: Deploy,id: deploy,timeout-minutes: 10,env: {TRUSTED: "${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}",CONVEX_DEPLOY_KEY: "${{ secrets[github.event_name == 'push' && 'CONVEX_DEPLOY_KEY' || 'CONVEX_DEPLOY_KEY_PREVIEW'] }}"},run: "if [[ \"$TRUSTED\" != true ]]; then VITE_CONVEX_URL=https://ci.invalid VITE_CONVEX_SITE_URL=https://ci.invalid bun run build --filter=@disposabl/web; exit; fi\n: \"${CONVEX_DEPLOY_KEY:?Configure the Convex deployment secret for this repository}\"\ncd packages/backend\nexport AUTH_TARGET=--prod\ntarget=()\nif [[ \"$CHANNEL\" != production ]]; then export AUTH_TARGET=\"--preview-name $CHANNEL\"; target=(--preview-name \"$CHANNEL\"); fi\nbun x --no-install convex deploy --yes \"${target[@]}\" --cmd-url-env-var-name CONVEX_URL --cmd 'for name in CONVEX_URL CONVEX_SITE_URL; do value=$(printenv \"$name\"); test -n \"$value\" || exit 1; for prefix in \"\" VITE_ EXPO_PUBLIC_; do export \"$prefix$name=$value\"; printf \"%s=%s\\n\" \"$prefix$name\" \"$value\" | tee -a \"$GITHUB_ENV\" >> \"$GITHUB_OUTPUT\"; done; done; bun run --cwd ../.. build --filter=@disposabl/web'\nsetup_target=(--prod)\nif [[ \"$CHANNEL\" != production ]]; then setup_target=(\"${target[@]}\"); fi\nbun x --no-install convex run \"${setup_target[@]}\" billing:setup '{}'\nbun x --no-install static-hosting upload $AUTH_TARGET --no-spa --dist ../../apps/web/dist/client\n"},{name: Report web result,if: always(),run: "node .github/scripts/disposabl.mjs report web,api,mcp ${{ steps.deploy.outcome == 'success' && 'ready' || 'failed' }}"},{name: Expo,if: "needs.changes.outputs.android == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Channel,if: "needs.changes.outputs.android == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Fingerprint,id: fingerprint,if: "needs.changes.outputs.android == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-fingerprint"},{name: Update,if: "steps.fingerprint.outputs.build == 'false'",env: {TAG: "${{ steps.fingerprint.outputs.tag }}",SHA: "${{ steps.fingerprint.outputs.sha }}",RUNTIME: "${{ steps.fingerprint.outputs.runtime }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-update"},&item5 {name: Publish,if: "github.job == 'android' || (github.job == 'web' && hashFiles('dist/release/android.json') != '') || github.job == 'desktop'",shell: bash,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/release.sh\" verify-artifacts"},&item6 {name: Upload release artifacts,id: artifacts,if: "hashFiles('dist/release/*') != ''",uses: actions/upload-artifact@v4,with: {name: "release-${{ env.PLATFORM }}",path: dist/release/,retention-days: 3,compression-level: 0,if-no-files-found: error}}]},android: {name: Android,needs: [changes,web],if: "needs.web.outputs.android_build == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.android_runner }}",timeout-minutes: 30,env: {PLATFORM: android,EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}"},steps: [*item0,{name: Prepare Android disk space,run: bash .github/scripts/android-runner.sh prepare},*item1,*item2,*item3,*item4,{name: Report mobile build,run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" building"},{name: Expo,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Java,uses: actions/setup-java@v5,with: {distribution: temurin,java-version: "17"}},{name: SDK,uses: android-actions/setup-android@v3,with: {packages: platform-tools}},{name: Gradle,uses: gradle/actions/setup-gradle@v4,with: {cache-read-only: false}},{name: Restore native compiler cache,if: "github.event_name == 'push'",id: native-cache,uses: actions/cache/restore@v4,with: {path: "${{ runner.temp }}/ccache",key: "android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}"}},{name: Install native compiler cache,if: "github.event_name == 'push' && steps.native-cache.outputs.cache-hit == 'true'",run: "sudo apt-get update -qq\nsudo apt-get install -y ccache\nprintf 'CCACHE_DIR=%s\\nCCACHE_COMPILERCHECK=content\\nCMAKE_C_COMPILER_LAUNCHER=ccache\\nCMAKE_CXX_COMPILER_LAUNCHER=ccache\\n' \"$RUNNER_TEMP/ccache\" >> \"$GITHUB_ENV\"\n"},{name: Build,working-directory: apps/mobile,env: {RUNTIME: "${{ needs.web.outputs.android_runtime }}",DISPOSABL_ANDROID_CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",DISPOSABL_ANDROID_SIGNING: "${{ github.event_name == 'push' && secrets.DISPOSABL_ANDROID_SIGNING || '' }}",ANDROID_KEYSTORE_BASE64: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_BASE64 || '' }}",ANDROID_KEYSTORE_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_PASSWORD || '' }}",ANDROID_KEY_ALIAS: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_ALIAS || '' }}",ANDROID_KEY_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_PASSWORD || '' }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" android-build"},*item5,*item6]},android-failure: {name: Report Android failure,needs: android,if: "always() && (needs.android.result == 'failure' || needs.android.result == 'cancelled')",permissions: {contents: read,id-token: write},runs-on: ubuntu-24.04,timeout-minutes: 5,steps: [*item0,*item1,{run: "node .github/scripts/disposabl.mjs report android failed \"Android build failed or was cancelled; check the workflow log.\""}]},ios-preview: {name: iOS simulator preview,needs: [changes,web],if: "github.event_name == 'pull_request' && needs.web.outputs.ios == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.macos_runner }}",timeout-minutes: 20,env: {EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Report build,run: node .github/scripts/disposabl.mjs report ios building},{name: Load Expo environment,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Verify update channel,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Publish compatible iOS preview update,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota"},{name: Xcode toolchain,run: "xcodebuild -version\nxcrun swift --version\n"},{name: Build simulator archive,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" simulator"},{uses: actions/upload-artifact@v4,with: {name: ios-simulator,path: dist/apple/ios-simulator.zip,retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Report simulator archive,run: "echo 'iOS simulator archive is available in this workflow run’s artifacts; it is not a device or TestFlight build.' >> \"$GITHUB_STEP_SUMMARY\"\nnode .github/scripts/disposabl.mjs report ios ready 'Simulator archive available in workflow artifacts.'\n"},{name: Report failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report ios failed 'iOS simulator build failed; check the workflow log.'"}]},ios-production: {name: iOS production and TestFlight,needs: [changes,web],if: "github.event_name == 'push' && needs.web.outputs.ios == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 20,env: {EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Check Expo connection,id: apple-prerequisites,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" prerequisites"},{name: Load Expo environment,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Verify update channel,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Select iOS update or native build,id: ios-plan,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota-plan"},{name: Publish compatible iOS production update,if: "steps.ios-plan.outputs.action == 'update'",working-directory: apps/mobile,env: {RUNTIME: "${{ steps.ios-plan.outputs.runtime }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota"},{name: Build and submit to TestFlight,if: "steps.ios-plan.outputs.action == 'build'",working-directory: apps/mobile,env: {ASC_APP_ID: "${{ secrets.ASC_APP_ID || vars.ASC_APP_ID }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" production"},{name: Reconcile delivery of the compatible native build,if: "steps.ios-plan.outputs.action == 'update'",working-directory: apps/mobile,env: {BUILD_ID: "${{ steps.ios-plan.outputs.build_id }}",ASC_APP_ID: "${{ secrets.ASC_APP_ID || vars.ASC_APP_ID }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" deliver"},{name: Report failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report ios failed 'iOS update, native build or submission failed; check the workflow log.'"}]},desktop: {needs: web,permissions: *permissions,name: "${{ matrix.platform }}",if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.web.outputs.desktop != '[]' && needs.web.outputs.desktop != ''",strategy: {fail-fast: false,matrix: {include: "${{ fromJSON(needs.web.outputs.desktop) }}"}},runs-on: "${{ matrix.runner }}",timeout-minutes: 20,env: {PLATFORM: "${{ matrix.platform }}",DISPOSABL_RELEASE_VERSION: "1.${{ github.run_number }}.${{ github.run_attempt }}",DISPOSABL_DESKTOP_PLATFORM: "${{ matrix.platform }}",DISPOSABL_DESKTOP_UPDATE_CHANNEL: production,CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",electron_config_cache: "${{ github.workspace }}/.cache/electron"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Report desktop build,run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" building"},{name: Electron,uses: actions/cache@v4,with: {path: .cache/electron,key: "electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bun.lock') }}"}},{name: Packages,if: "matrix.platform == 'linux'",run: "command -v fakeroot && command -v rpmbuild && command -v dpkg-deb || { sudo apt-get update && sudo apt-get install -y fakeroot dpkg rpm; }"},{name: Configure desktop update identity,shell: bash,run: "id=$(node -p \"require('./disposabl.json').desktopId || ''\")\nif [[ ! \"$id\" =~ ^[a-f0-9]{32}$ ]]; then echo 'Desktop identity missing; regenerate this app before its first installation.' >&2; exit 1; fi\necho \"DISPOSABL_DESKTOP_ID=$id\" >> \"$GITHUB_ENV\"\necho \"DISPOSABL_DESKTOP_UPDATE_URL=${CONVEX_SITE_URL}/desktop/updates/$id\" >> \"$GITHUB_ENV\"\n"},{name: Build,if: "matrix.platform != 'macos'",run: bun run --cwd apps/desktop preview},{name: Build macOS,if: "matrix.platform == 'macos'",shell: bash,env: {MACOS_SIGNING_CONFIG: "${{ secrets.MACOS_SIGNING_CONFIG }}"},run: bash .github/scripts/macos-release.sh},*item5,{name: Publish desktop update feed,if: "matrix.platform == 'windows' || (matrix.platform == 'macos' && env.MACOS_NOTARIZE == 'true')",shell: bash,env: {CONVEX_DEPLOY_KEY: "${{ secrets.CONVEX_DEPLOY_KEY }}"},run: "test \"$(gh api \"repos/$GH_REPO/git/ref/heads/main\" --jq .object.sha)\" = \"$SOURCE\"\nnode apps/desktop/publish-update.mjs\n"},{name: Upload desktop release artifacts,if: "matrix.platform != 'macos' || env.MACOS_NOTARIZE == 'true'",uses: actions/upload-artifact@v4,with: {name: "release-${{ env.PLATFORM }}",path: dist/release/,retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Upload staged update feed,if: "matrix.platform != 'linux' && env.DISPOSABL_DESKTOP_UPDATE_URL != '' && (matrix.platform != 'macos' || env.MACOS_NOTARIZE == 'true')",uses: actions/upload-artifact@v4,with: {name: "desktop-update-${{ env.PLATFORM }}",path: dist/update/,retention-days: 3,if-no-files-found: error}},{name: Upload unsigned macOS artifact,if: "matrix.platform == 'macos' && env.MACOS_NOTARIZE != 'true'",uses: actions/upload-artifact@v4,with: {name: macos-unsigned,path: "dist/release/*.dmg\ndist/release/*.zip\n",retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Report macOS artifact,if: "matrix.platform == 'macos' && env.MACOS_NOTARIZE != 'true'",run: "echo 'macOS DMG is ad-hoc signed, not Developer ID signed or notarized. Download it from this workflow run’s artifacts.' >> \"$GITHUB_STEP_SUMMARY\"\nnode .github/scripts/disposabl.mjs report macos blocked 'Ad-hoc signed DMG available in workflow artifacts; Developer ID signing and notarization are not configured.'\n"},{name: Report desktop failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" failed"},{name: Clean up macOS signing,if: "always() && matrix.platform == 'macos'",shell: bash,run: bash .github/scripts/macos-release.sh cleanup}]},packages: {name: "Package / ${{ matrix.package }}",needs: [changes,web],if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.web.outputs.packages != '[]' && needs.web.outputs.packages != ''",runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 15,permissions: {contents: write,id-token: write},concurrency: {group: "npm-${{ matrix.package }}",cancel-in-progress: false},strategy: {fail-fast: false,matrix: {package: "${{ fromJSON(needs.web.outputs.packages) }}"}},env: {PACKAGE: "${{ matrix.package }}"},steps: [{uses: actions/checkout@v6,with: {fetch-depth: 0,persist-credentials: false}},*item1,*item2,*item3,*item4,{name: Disposabl GitHub App token,run: node .github/scripts/disposabl.mjs token},{name: Publish package if configured,run: bash .github/scripts/release.sh package-release}]},publish: {needs: [changes,web,android,desktop],if: "always() && !cancelled() && needs.web.result == 'success' && (needs.web.outputs.release == 'true' || needs.android.result == 'success' || needs.desktop.result == 'success')",environment: publishing,runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 15,permissions: {contents: write,actions: read,id-token: write},steps: [{uses: actions/checkout@v6,with: {ref: main,persist-credentials: false}},{uses: actions/setup-node@v6,with: {node-version: "24",package-manager-cache: false}},{name: Disposabl installation token,run: node .github/scripts/disposabl.mjs token},{name: Select release source,id: source,run: bash .github/scripts/release.sh release-source},{uses: actions/download-artifact@v4,if: "steps.source.outputs.current == 'true'",with: {pattern: release-*,path: artifacts}},{name: Publish verified build artifacts,if: "steps.source.outputs.current == 'true'",run: bash .github/scripts/release.sh release-publish}]}}}
|
|
1
|
+
{name: Pipeline,"on": {pull_request: {branches: [main]},push: {branches: [main]}},permissions: {contents: read,pull-requests: read},concurrency: {group: "${{ github.workflow }}-${{ github.ref }}",cancel-in-progress: "${{ github.event_name == 'pull_request' }}"},env: {CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",DISPOSABL_MOBILE_CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",EAS_ENVIRONMENT: "${{ github.event_name == 'push' && 'production' || 'preview' }}",EAS_CLI: eas-cli@27.2.0,BUN_VERSION: 1.4.4,NODE_VERSION: "24",LINUX_RUNNER: ubuntu-24.04,WEB_RUNNER: ubuntu-24.04,WINDOWS_RUNNER: windows-2025,MACOS_RUNNER: macos-26,RELEASE_PREFIX: app,DISPOSABL_ANDROID_VERSION_CODE: "${{ github.run_number }}",DISPOSABL_IOS_BUILD_NUMBER: "${{ github.run_number }}",GH_TOKEN: "${{ github.token }}",GH_REPO: "${{ github.repository }}",SOURCE: "${{ github.event.pull_request.head.sha || github.sha }}",SOURCE_PATH: "${{ github.event_name == 'pull_request' && format('pulls/{0}', github.event.number) || 'git/ref/heads/main' }}",DISPOSABL_RELEASE_VERSION: "1.0.${{ github.run_number }}"},jobs: {changes: {name: Select work,if: "github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository",permissions: {contents: read,pull-requests: read,actions: read},runs-on: ubuntu-24.04,timeout-minutes: 30,outputs: {linux_runner: "${{ steps.platforms.outputs.linux_runner }}",android_runner: "${{ steps.platforms.outputs.android_runner }}",macos_runner: "${{ steps.platforms.outputs.macos_runner }}",changed: "${{ steps.platforms.outputs.changed }}",android: "${{ steps.platforms.outputs.android }}",ios: "${{ steps.platforms.outputs.ios }}",desktop: "${{ steps.platforms.outputs.desktop }}",packages: "${{ steps.platforms.outputs.packages }}"},steps: [&item0 {uses: actions/checkout@v6,with: {ref: "${{ env.SOURCE }}",persist-credentials: false}},{name: Select affected platforms,shell: bash,id: platforms,env: {PR: "${{ github.event.number }}",EXPO_CONNECTED: "${{ secrets.EXPO_TOKEN != '' }}",IOS_BUILDS_ENABLED: "${{ vars.IOS_BUILDS_ENABLED != 'false' }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/platforms.sh\""}]},web: {name: Web,needs: changes,if: "needs.changes.outputs.changed == 'true'",permissions: &permissions {contents: read,pull-requests: read,id-token: write},timeout-minutes: 20,runs-on: "${{ needs.changes.outputs.linux_runner }}",outputs: {desktop: "${{ needs.changes.outputs.desktop }}",ios: "${{ needs.changes.outputs.ios }}",packages: "${{ needs.changes.outputs.packages }}",release: "${{ steps.artifacts.outcome == 'success' }}",android_build: "${{ steps.fingerprint.outputs.build }}",android_runtime: "${{ steps.fingerprint.outputs.runtime }}",convex_url: "${{ steps.deploy.outputs.CONVEX_URL }}",convex_site_url: "${{ steps.deploy.outputs.CONVEX_SITE_URL }}"},env: {PLATFORM: android,DISPOSABL_ANDROID_SIGNING: "${{ github.event_name == 'push' && secrets.DISPOSABL_ANDROID_SIGNING || '' }}",ANDROID_KEYSTORE_BASE64: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_BASE64 || '' }}",ANDROID_KEYSTORE_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_PASSWORD || '' }}",ANDROID_KEY_ALIAS: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_ALIAS || '' }}",ANDROID_KEY_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_PASSWORD || '' }}",ANDROID_PLAY_SUBMIT: "${{ vars.ANDROID_PLAY_SUBMIT }}",EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1"},steps: [*item0,&item1 {uses: actions/setup-node@v6,with: {node-version: "24",package-manager-cache: false}},&item2 {uses: oven-sh/setup-bun@v2,with: {bun-version: 1.4.4}},&item3 {uses: actions/cache@v4,with: {path: ~/.bun/install/cache,key: "bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-${{ hashFiles('bun.lock') }}",restore-keys: "bun-${{ github.job == 'desktop' && 'desktop-' || '' }}${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}-"}},&item4 {run: "bun install --frozen-lockfile ${{ github.job == 'desktop' && '--filter \"*desktop*\" --filter @disposabl/backend' || (github.job == 'android' || startsWith(github.job, 'ios-')) && '--filter @disposabl/mobile' || '' }}"},{name: Report build start,run: "node .github/scripts/disposabl.mjs report web,api,mcp building\nif [[ -z \"$EXPO_TOKEN\" ]]; then node .github/scripts/disposabl.mjs report android blocked 'Connect Expo before building Android.'; fi\nif [[ '${{ github.event_name }}' == pull_request ]]; then node .github/scripts/disposabl.mjs report cli,typescript-sdk blocked 'Packages publish after merge to main.'; fi\n"},{name: Check,run: bun run check},{name: Build selected clients,run: "for package in cli sdk; do\n if test -f \"packages/$package/package.json\"; then bun run --cwd \"packages/$package\" build; fi\ndone\n"},{name: Deploy,id: deploy,timeout-minutes: 10,env: {TRUSTED: "${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}",CONVEX_DEPLOY_KEY: "${{ secrets[github.event_name == 'push' && 'CONVEX_DEPLOY_KEY' || 'CONVEX_DEPLOY_KEY_PREVIEW'] }}"},run: "if [[ \"$TRUSTED\" != true ]]; then VITE_CONVEX_URL=https://ci.invalid VITE_CONVEX_SITE_URL=https://ci.invalid bun run build --filter=@disposabl/web; exit; fi\n: \"${CONVEX_DEPLOY_KEY:?Configure the Convex deployment secret for this repository}\"\ncd packages/backend\nexport AUTH_TARGET=--prod\ntarget=()\nif [[ \"$CHANNEL\" != production ]]; then export AUTH_TARGET=\"--preview-name $CHANNEL\"; target=(--preview-name \"$CHANNEL\"); fi\nbun x --no-install convex deploy --yes \"${target[@]}\" --cmd-url-env-var-name CONVEX_URL --cmd 'for name in CONVEX_URL CONVEX_SITE_URL; do value=$(printenv \"$name\"); test -n \"$value\" || exit 1; for prefix in \"\" VITE_ EXPO_PUBLIC_; do export \"$prefix$name=$value\"; printf \"%s=%s\\n\" \"$prefix$name\" \"$value\" | tee -a \"$GITHUB_ENV\" >> \"$GITHUB_OUTPUT\"; done; done; bun run --cwd ../.. build --filter=@disposabl/web'\nsetup_target=(--prod)\nif [[ \"$CHANNEL\" != production ]]; then setup_target=(\"${target[@]}\"); fi\nbun x --no-install convex run \"${setup_target[@]}\" billing:setup '{}'\nbun x --no-install static-hosting upload $AUTH_TARGET --no-spa --dist ../../apps/web/dist/client\n"},{name: Report web result,if: always(),run: "node .github/scripts/disposabl.mjs report web,api,mcp ${{ steps.deploy.outcome == 'success' && 'ready' || 'failed' }}"},{name: Expo,if: "needs.changes.outputs.android == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Channel,if: "needs.changes.outputs.android == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Fingerprint,id: fingerprint,if: "needs.changes.outputs.android == 'true'",env: {},working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-fingerprint"},{name: Update,if: "steps.fingerprint.outputs.build == 'false'",env: {TAG: "${{ steps.fingerprint.outputs.tag }}",SHA: "${{ steps.fingerprint.outputs.sha }}",RUNTIME: "${{ steps.fingerprint.outputs.runtime }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-update"},&item5 {name: Publish,if: "github.job == 'android' || (github.job == 'web' && hashFiles('dist/release/android.json') != '') || github.job == 'desktop'",shell: bash,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/release.sh\" verify-artifacts"},&item6 {name: Upload release artifacts,id: artifacts,if: "hashFiles('dist/release/*') != ''",uses: actions/upload-artifact@v4,with: {name: "release-${{ env.PLATFORM }}",path: dist/release/,retention-days: 3,compression-level: 0,if-no-files-found: error}}]},android: {name: Android,needs: [changes,web],if: "needs.web.outputs.android_build == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.android_runner }}",timeout-minutes: 30,env: {PLATFORM: android,EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}"},steps: [*item0,{name: Prepare Android disk space,run: bash .github/scripts/android-runner.sh prepare},*item1,*item2,*item3,*item4,{name: Report mobile build,run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" building"},{name: Expo,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Java,uses: actions/setup-java@v5,with: {distribution: temurin,java-version: "17"}},{name: SDK,uses: android-actions/setup-android@v3,with: {packages: platform-tools}},{name: Gradle,uses: gradle/actions/setup-gradle@v4,with: {cache-read-only: false}},{name: Restore native compiler cache,if: "github.event_name == 'push'",id: native-cache,uses: actions/cache/restore@v4,with: {path: "${{ runner.temp }}/ccache",key: "android-ccache-v1-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}"}},{name: Install native compiler cache,if: "github.event_name == 'push' && steps.native-cache.outputs.cache-hit == 'true'",run: "sudo apt-get update -qq\nsudo apt-get install -y ccache\nprintf 'CCACHE_DIR=%s\\nCCACHE_COMPILERCHECK=content\\nCMAKE_C_COMPILER_LAUNCHER=ccache\\nCMAKE_CXX_COMPILER_LAUNCHER=ccache\\n' \"$RUNNER_TEMP/ccache\" >> \"$GITHUB_ENV\"\n"},{name: Select Android bundle validation,id: bundletool-needed,env: {SIGNING_BUNDLE: "${{ github.event_name == 'push' && secrets.DISPOSABL_ANDROID_SIGNING || '' }}",SIGNING_STORE: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_BASE64 || '' }}",SIGNING_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_PASSWORD || '' }}",SIGNING_ALIAS: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_ALIAS || '' }}",SIGNING_KEY_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_PASSWORD || '' }}"},run: "if [[ -n \"$SIGNING_BUNDLE$SIGNING_STORE$SIGNING_PASSWORD$SIGNING_ALIAS$SIGNING_KEY_PASSWORD\" ]]; then echo 'needed=true' >> \"$GITHUB_OUTPUT\"; fi\n"},{name: Download verified bundletool,if: "steps.bundletool-needed.outputs.needed == 'true'",run: "curl --fail --location --silent --show-error --retry 3 https://github.com/google/bundletool/releases/download/1.18.3/bundletool-all-1.18.3.jar --output \"$RUNNER_TEMP/bundletool.jar\"\necho 'a099cfa1543f55593bc2ed16a70a7c67fe54b1747bb7301f37fdfd6d91028e29 '\"$RUNNER_TEMP/bundletool.jar\" | sha256sum --check --status\n"},{name: Build,working-directory: apps/mobile,env: {RUNTIME: "${{ needs.web.outputs.android_runtime }}",BUNDLETOOL_JAR: "${{ runner.temp }}/bundletool.jar",DISPOSABL_ANDROID_CHANNEL: "${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'production' }}",DISPOSABL_ANDROID_SIGNING: "${{ github.event_name == 'push' && secrets.DISPOSABL_ANDROID_SIGNING || '' }}",ANDROID_KEYSTORE_BASE64: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_BASE64 || '' }}",ANDROID_KEYSTORE_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEYSTORE_PASSWORD || '' }}",ANDROID_KEY_ALIAS: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_ALIAS || '' }}",ANDROID_KEY_PASSWORD: "${{ github.event_name == 'push' && secrets.ANDROID_KEY_PASSWORD || '' }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" android-build"},*item5,*item6]},android-submit: {name: Android Play submission,needs: android,if: "github.event_name == 'push' && vars.ANDROID_PLAY_SUBMIT == 'true' && needs.android.result == 'success'",runs-on: ubuntu-24.04,timeout-minutes: 30,permissions: {contents: read},env: {EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1"},steps: [*item0,*item1,*item2,{uses: actions/setup-java@v5,with: {distribution: temurin,java-version: "17"}},{uses: actions/download-artifact@v4,with: {name: release-android,path: dist/release}},{name: Submit Android bundle,working-directory: apps/mobile,env: {ANDROID_PLAY_SERVICE_ACCOUNT: "${{ secrets.ANDROID_PLAY_SERVICE_ACCOUNT }}",ANDROID_PLAY_TRACK: "${{ vars.ANDROID_PLAY_TRACK }}",ANDROID_PLAY_UPLOAD_CERT_SHA256: "${{ vars.ANDROID_PLAY_UPLOAD_CERT_SHA256 }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" android-submit"}]},android-failure: {name: Report Android failure,needs: android,if: "always() && (needs.android.result == 'failure' || needs.android.result == 'cancelled')",permissions: {contents: read,id-token: write},runs-on: ubuntu-24.04,timeout-minutes: 5,steps: [*item0,*item1,{run: "node .github/scripts/disposabl.mjs report android failed \"Android build failed or was cancelled; check the workflow log.\""}]},ios-preview: {name: iOS simulator preview,needs: [changes,web],if: "github.event_name == 'pull_request' && needs.web.outputs.ios == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.macos_runner }}",timeout-minutes: 20,env: {EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Report build,run: node .github/scripts/disposabl.mjs report ios building},{name: Load Expo environment,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Verify update channel,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Publish compatible iOS preview update,if: "env.EXPO_TOKEN != ''",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota"},{name: Xcode toolchain,run: "xcodebuild -version\nxcrun swift --version\n"},{name: Build simulator archive,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" simulator"},{uses: actions/upload-artifact@v4,with: {name: ios-simulator,path: dist/apple/ios-simulator.zip,retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Report simulator archive,run: "echo 'iOS simulator archive is available in this workflow run’s artifacts; it is not a device or TestFlight build.' >> \"$GITHUB_STEP_SUMMARY\"\nnode .github/scripts/disposabl.mjs report ios ready 'Simulator archive available in workflow artifacts.'\n"},{name: Report failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report ios failed 'iOS simulator build failed; check the workflow log.'"}]},ios-production: {name: iOS production and TestFlight,needs: [changes,web],if: "github.event_name == 'push' && needs.web.outputs.ios == 'true'",permissions: *permissions,runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 20,env: {EXPO_TOKEN: "${{ secrets.EXPO_TOKEN }}",EXPO_PROJECT_ID: "${{ secrets.EXPO_PROJECT_ID || vars.EXPO_PROJECT_ID }}",EXPO_OWNER: "${{ secrets.EXPO_OWNER || vars.EXPO_OWNER }}",EXPO_SLUG: "${{ secrets.EXPO_SLUG || vars.EXPO_SLUG }}",EXPO_NO_DOTENV: "1",CONVEX_URL: "${{ needs.web.outputs.convex_url }}",CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",EXPO_PUBLIC_CONVEX_URL: "${{ needs.web.outputs.convex_url }}",EXPO_PUBLIC_CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Check Expo connection,id: apple-prerequisites,working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" prerequisites"},{name: Load Expo environment,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-env"},{name: Verify update channel,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/mobile.sh\" expo-channel"},{name: Select iOS update or native build,id: ios-plan,if: "steps.apple-prerequisites.outputs.ready == 'true'",working-directory: apps/mobile,run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota-plan"},{name: Publish compatible iOS production update,if: "steps.ios-plan.outputs.action == 'update'",working-directory: apps/mobile,env: {RUNTIME: "${{ steps.ios-plan.outputs.runtime }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" ota"},{name: Build and submit to TestFlight,if: "steps.ios-plan.outputs.action == 'build'",working-directory: apps/mobile,env: {ASC_APP_ID: "${{ secrets.ASC_APP_ID || vars.ASC_APP_ID }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" production"},{name: Reconcile delivery of the compatible native build,if: "steps.ios-plan.outputs.action == 'update'",working-directory: apps/mobile,env: {BUILD_ID: "${{ steps.ios-plan.outputs.build_id }}",ASC_APP_ID: "${{ secrets.ASC_APP_ID || vars.ASC_APP_ID }}"},run: "bash \"$GITHUB_WORKSPACE/.github/scripts/apple.sh\" deliver"},{name: Report failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report ios failed 'iOS update, native build or submission failed; check the workflow log.'"}]},desktop: {needs: web,permissions: *permissions,name: "${{ matrix.platform }}",if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.web.outputs.desktop != '[]' && needs.web.outputs.desktop != ''",strategy: {fail-fast: false,matrix: {include: "${{ fromJSON(needs.web.outputs.desktop) }}"}},runs-on: "${{ matrix.runner }}",timeout-minutes: 20,env: {PLATFORM: "${{ matrix.platform }}",DISPOSABL_RELEASE_VERSION: "1.${{ github.run_number }}.${{ github.run_attempt }}",DISPOSABL_DESKTOP_PLATFORM: "${{ matrix.platform }}",DISPOSABL_DESKTOP_UPDATE_CHANNEL: production,CONVEX_SITE_URL: "${{ needs.web.outputs.convex_site_url }}",electron_config_cache: "${{ github.workspace }}/.cache/electron"},steps: [*item0,*item1,*item2,*item3,*item4,{name: Report desktop build,run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" building"},{name: Electron,uses: actions/cache@v4,with: {path: .cache/electron,key: "electron-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('bun.lock') }}"}},{name: Packages,if: "matrix.platform == 'linux'",run: "command -v fakeroot && command -v rpmbuild && command -v dpkg-deb || { sudo apt-get update && sudo apt-get install -y fakeroot dpkg rpm; }"},{name: Configure desktop update identity,shell: bash,run: "id=$(node -p \"require('./disposabl.json').desktopId || ''\")\nif [[ ! \"$id\" =~ ^[a-f0-9]{32}$ ]]; then echo 'Desktop identity missing; regenerate this app before its first installation.' >&2; exit 1; fi\necho \"DISPOSABL_DESKTOP_ID=$id\" >> \"$GITHUB_ENV\"\necho \"DISPOSABL_DESKTOP_UPDATE_URL=${CONVEX_SITE_URL}/desktop/updates/$id\" >> \"$GITHUB_ENV\"\n"},{name: Build,if: "matrix.platform != 'macos'",run: bun run --cwd apps/desktop preview},{name: Build macOS,if: "matrix.platform == 'macos'",shell: bash,env: {MACOS_SIGNING_CONFIG: "${{ secrets.MACOS_SIGNING_CONFIG }}"},run: bash .github/scripts/macos-release.sh},*item5,{name: Publish desktop update feed,if: "matrix.platform == 'windows' || (matrix.platform == 'macos' && env.MACOS_NOTARIZE == 'true')",shell: bash,env: {CONVEX_DEPLOY_KEY: "${{ secrets.CONVEX_DEPLOY_KEY }}"},run: "test \"$(gh api \"repos/$GH_REPO/git/ref/heads/main\" --jq .object.sha)\" = \"$SOURCE\"\nnode apps/desktop/publish-update.mjs\n"},{name: Upload desktop release artifacts,if: "matrix.platform != 'macos' || env.MACOS_NOTARIZE == 'true'",uses: actions/upload-artifact@v4,with: {name: "release-${{ env.PLATFORM }}",path: dist/release/,retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Upload staged update feed,if: "matrix.platform != 'linux' && env.DISPOSABL_DESKTOP_UPDATE_URL != '' && (matrix.platform != 'macos' || env.MACOS_NOTARIZE == 'true')",uses: actions/upload-artifact@v4,with: {name: "desktop-update-${{ env.PLATFORM }}",path: dist/update/,retention-days: 3,if-no-files-found: error}},{name: Upload unsigned macOS artifact,if: "matrix.platform == 'macos' && env.MACOS_NOTARIZE != 'true'",uses: actions/upload-artifact@v4,with: {name: macos-unsigned,path: "dist/release/*.dmg\ndist/release/*.zip\n",retention-days: 3,compression-level: 0,if-no-files-found: error}},{name: Report macOS artifact,if: "matrix.platform == 'macos' && env.MACOS_NOTARIZE != 'true'",run: "echo 'macOS DMG is ad-hoc signed, not Developer ID signed or notarized. Download it from this workflow run’s artifacts.' >> \"$GITHUB_STEP_SUMMARY\"\nnode .github/scripts/disposabl.mjs report macos blocked 'Ad-hoc signed DMG available in workflow artifacts; Developer ID signing and notarization are not configured.'\n"},{name: Report desktop failure,if: failure() || cancelled(),run: "node .github/scripts/disposabl.mjs report \"$PLATFORM\" failed"},{name: Clean up macOS signing,if: "always() && matrix.platform == 'macos'",shell: bash,run: bash .github/scripts/macos-release.sh cleanup}]},packages: {name: "Package / ${{ matrix.package }}",needs: [changes,web],if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.web.outputs.packages != '[]' && needs.web.outputs.packages != ''",runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 15,permissions: {contents: write,id-token: write},concurrency: {group: "npm-${{ matrix.package }}",cancel-in-progress: false},strategy: {fail-fast: false,matrix: {package: "${{ fromJSON(needs.web.outputs.packages) }}"}},env: {PACKAGE: "${{ matrix.package }}"},steps: [{uses: actions/checkout@v6,with: {fetch-depth: 0,persist-credentials: false}},*item1,*item2,*item3,*item4,{name: Disposabl GitHub App token,run: node .github/scripts/disposabl.mjs token},{name: Publish package if configured,run: bash .github/scripts/release.sh package-release}]},publish: {needs: [changes,web,android,desktop],if: "always() && !cancelled() && needs.web.result == 'success' && (needs.web.outputs.release == 'true' || needs.android.result == 'success' || needs.desktop.result == 'success')",environment: publishing,runs-on: "${{ needs.changes.outputs.linux_runner }}",timeout-minutes: 15,permissions: {contents: write,actions: read,id-token: write},steps: [{uses: actions/checkout@v6,with: {ref: main,persist-credentials: false}},{uses: actions/setup-node@v6,with: {node-version: "24",package-manager-cache: false}},{name: Disposabl installation token,run: node .github/scripts/disposabl.mjs token},{name: Select release source,id: source,run: bash .github/scripts/release.sh release-source},{uses: actions/download-artifact@v4,if: "steps.source.outputs.current == 'true'",with: {pattern: release-*,path: artifacts}},{name: Publish verified build artifacts,if: "steps.source.outputs.current == 'true'",run: bash .github/scripts/release.sh release-publish}]}}}
|
|
@@ -162,13 +162,16 @@ module.exports = ({ config }) => {
|
|
|
162
162
|
// Start from the newest cached bundle while downloading for the next launch.
|
|
163
163
|
checkAutomatically: "ON_LOAD",
|
|
164
164
|
fallbackToCacheTimeout: 0,
|
|
165
|
-
...(projectId
|
|
165
|
+
...(projectId && process.env.UPDATE_POLICY !== "disabled"
|
|
166
166
|
? {
|
|
167
167
|
url: `https://u.expo.dev/${projectId}`,
|
|
168
168
|
requestHeaders: { "expo-channel-name": channel },
|
|
169
169
|
}
|
|
170
170
|
: {}),
|
|
171
|
-
...(process.env.EXPO_PUBLIC_E2E === "true"
|
|
171
|
+
...(process.env.EXPO_PUBLIC_E2E === "true" ||
|
|
172
|
+
process.env.UPDATE_POLICY === "disabled"
|
|
173
|
+
? { enabled: false, url: undefined, requestHeaders: undefined }
|
|
174
|
+
: {}),
|
|
172
175
|
},
|
|
173
176
|
};
|
|
174
177
|
};
|
|
@@ -5,13 +5,9 @@ module.exports = (config) =>
|
|
|
5
5
|
withAppBuildGradle(config, (mod) => {
|
|
6
6
|
if (mod.modResults.language !== "groovy")
|
|
7
7
|
throw new Error("Expected a Groovy Android build");
|
|
8
|
-
|
|
9
|
-
mod.modResults.contents.includes("// Disposabl production APK signing.")
|
|
10
|
-
)
|
|
11
|
-
return mod;
|
|
12
|
-
mod.modResults.contents += `
|
|
8
|
+
const block = `
|
|
13
9
|
// Disposabl production APK signing. Preview APKs retain Expo's debug signing.
|
|
14
|
-
if (System.getenv("DISPOSABL_ANDROID_CHANNEL") == "production") {
|
|
10
|
+
if (System.getenv("DISPOSABL_ANDROID_CHANNEL") == "production" && System.getenv("ANDROID_KEYSTORE_PATH")) {
|
|
15
11
|
android {
|
|
16
12
|
signingConfigs {
|
|
17
13
|
disposablRelease {
|
|
@@ -47,5 +43,21 @@ if (System.getenv("DISPOSABL_ANDROID_CHANNEL") == "production") {
|
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
`;
|
|
46
|
+
const legacy = block.replace(
|
|
47
|
+
' && System.getenv("ANDROID_KEYSTORE_PATH")',
|
|
48
|
+
"",
|
|
49
|
+
);
|
|
50
|
+
if (mod.modResults.contents.includes(block)) return mod;
|
|
51
|
+
if (mod.modResults.contents.includes(legacy)) {
|
|
52
|
+
mod.modResults.contents = mod.modResults.contents.replace(legacy, block);
|
|
53
|
+
} else {
|
|
54
|
+
if (
|
|
55
|
+
mod.modResults.contents.includes("// Disposabl production APK signing.")
|
|
56
|
+
)
|
|
57
|
+
throw new Error(
|
|
58
|
+
"Customized Android signing block requires manual migration",
|
|
59
|
+
);
|
|
60
|
+
mod.modResults.contents += block;
|
|
61
|
+
}
|
|
50
62
|
return mod;
|
|
51
63
|
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { verifyBundle } from "./verify-play-aab.mjs";
|
|
5
|
+
|
|
6
|
+
export function verifyInputs(config, manifest, env) {
|
|
7
|
+
if (config.android?.package !== manifest.applicationId)
|
|
8
|
+
throw new Error("Expo package does not match release manifest");
|
|
9
|
+
const version = String(env.DISPOSABL_ANDROID_VERSION_CODE || "1");
|
|
10
|
+
if (
|
|
11
|
+
!/^[1-9]\d*$/.test(version) ||
|
|
12
|
+
BigInt(version) > 2100000000n ||
|
|
13
|
+
String(config.android?.versionCode) !== version
|
|
14
|
+
)
|
|
15
|
+
throw new Error("Expo Android version does not match the release version");
|
|
16
|
+
const abis = config.extra?.disposablAndroidArchitectures;
|
|
17
|
+
if (
|
|
18
|
+
!Array.isArray(abis) ||
|
|
19
|
+
!abis.length ||
|
|
20
|
+
new Set(abis).size !== abis.length ||
|
|
21
|
+
abis.some(
|
|
22
|
+
(abi) => !["arm64-v8a", "x86_64", "armeabi-v7a", "x86"].includes(abi),
|
|
23
|
+
) ||
|
|
24
|
+
JSON.stringify(abis) !== JSON.stringify(manifest.androidArchitectures)
|
|
25
|
+
)
|
|
26
|
+
throw new Error("Invalid Android architectures");
|
|
27
|
+
if (env.CHANNEL === "production") {
|
|
28
|
+
if (env.GH_REPO === "disposabl-dev/create-disposabl-app") {
|
|
29
|
+
if (
|
|
30
|
+
config.android?.package !== "com.yastai.disposabl" ||
|
|
31
|
+
config.extra?.disposablAndroidPayments !== false ||
|
|
32
|
+
JSON.stringify(abis) !== JSON.stringify(["arm64-v8a", "x86_64"]) ||
|
|
33
|
+
env.EXPO_PUBLIC_DISPOSABL_ANALYTICS_ENABLED !== "true" ||
|
|
34
|
+
env.UPDATE_POLICY !== "disabled" ||
|
|
35
|
+
config.updates?.requestHeaders != null
|
|
36
|
+
)
|
|
37
|
+
throw new Error("Disposabl production configuration policy mismatch");
|
|
38
|
+
// Shared builds retain the Expo identity for runtime fingerprinting.
|
|
39
|
+
// That identity never enables OTA: URL, headers and enabled are checked.
|
|
40
|
+
if (config.extra?.eas?.projectId !== manifest.projectId)
|
|
41
|
+
throw new Error("Disposabl Expo project identity mismatch");
|
|
42
|
+
}
|
|
43
|
+
if (env.EXPO_PUBLIC_E2E === "true")
|
|
44
|
+
throw new Error("E2E is not permitted in production");
|
|
45
|
+
for (const key of [
|
|
46
|
+
"EXPO_PUBLIC_CONVEX_URL",
|
|
47
|
+
"EXPO_PUBLIC_CONVEX_SITE_URL",
|
|
48
|
+
]) {
|
|
49
|
+
const url = new URL(env[key]);
|
|
50
|
+
if (
|
|
51
|
+
url.protocol !== "https:" ||
|
|
52
|
+
["localhost", "127.0.0.1", "10.0.2.2", "[::1]"].includes(url.hostname)
|
|
53
|
+
)
|
|
54
|
+
throw new Error(`${key} must be a non-loopback HTTPS URL`);
|
|
55
|
+
}
|
|
56
|
+
if (
|
|
57
|
+
env.UPDATE_POLICY === "disabled" &&
|
|
58
|
+
(config.updates?.enabled !== false || config.updates?.url)
|
|
59
|
+
)
|
|
60
|
+
throw new Error("Production updates must be disabled");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function verifyEmbedded(config, embedded) {
|
|
65
|
+
for (const [name, actual, expected] of [
|
|
66
|
+
["package", embedded.android?.package, config.android?.package],
|
|
67
|
+
["version", embedded.android?.versionCode, config.android?.versionCode],
|
|
68
|
+
["scheme", embedded.scheme, config.scheme],
|
|
69
|
+
["updates", embedded.updates?.enabled, config.updates?.enabled],
|
|
70
|
+
[
|
|
71
|
+
"payments",
|
|
72
|
+
embedded.extra?.disposablAndroidPayments,
|
|
73
|
+
config.extra?.disposablAndroidPayments,
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
"architectures",
|
|
77
|
+
embedded.extra?.disposablAndroidArchitectures,
|
|
78
|
+
config.extra?.disposablAndroidArchitectures,
|
|
79
|
+
],
|
|
80
|
+
])
|
|
81
|
+
if (JSON.stringify(actual) !== JSON.stringify(expected))
|
|
82
|
+
throw new Error(`Bundled Expo ${name} does not match build config`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (
|
|
86
|
+
process.argv[1] &&
|
|
87
|
+
import.meta.url === pathToFileURL(process.argv[1]).href
|
|
88
|
+
) {
|
|
89
|
+
const [operation, configPath, manifestText, artifact, cert] =
|
|
90
|
+
process.argv.slice(2);
|
|
91
|
+
const config = JSON.parse(readFileSync(configPath, "utf8"));
|
|
92
|
+
const manifest = JSON.parse(manifestText);
|
|
93
|
+
verifyInputs(config, manifest, process.env);
|
|
94
|
+
if (operation === "artifact") {
|
|
95
|
+
const entry = artifact.endsWith(".aab")
|
|
96
|
+
? "base/assets/app.config"
|
|
97
|
+
: "assets/app.config";
|
|
98
|
+
const embedded = JSON.parse(
|
|
99
|
+
execFileSync("unzip", ["-p", artifact, entry], { encoding: "utf8" }),
|
|
100
|
+
);
|
|
101
|
+
verifyEmbedded(config, embedded);
|
|
102
|
+
if (artifact.endsWith(".aab")) {
|
|
103
|
+
if (!process.env.BUNDLETOOL_JAR)
|
|
104
|
+
throw new Error("Bundletool is required for AAB validation");
|
|
105
|
+
verifyBundle({
|
|
106
|
+
bundle: artifact,
|
|
107
|
+
packageId: manifest.applicationId,
|
|
108
|
+
version: String(config.android.versionCode),
|
|
109
|
+
architectures: manifest.androidArchitectures,
|
|
110
|
+
expectedCert: cert.toUpperCase(),
|
|
111
|
+
bundletool: process.env.BUNDLETOOL_JAR,
|
|
112
|
+
production: process.env.CHANNEL === "production",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else if (operation !== "inputs")
|
|
116
|
+
throw new Error("Expected inputs or artifact");
|
|
117
|
+
}
|
|
@@ -17,13 +17,16 @@ export function verifyBundle({
|
|
|
17
17
|
expectedCert,
|
|
18
18
|
bundletool,
|
|
19
19
|
production = false,
|
|
20
|
+
execute,
|
|
20
21
|
}) {
|
|
21
|
-
const run =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const run =
|
|
23
|
+
execute ??
|
|
24
|
+
((command, args) =>
|
|
25
|
+
execFileSync(command, args, {
|
|
26
|
+
encoding: "utf8",
|
|
27
|
+
env: { ...process.env, LANG: "C", LC_ALL: "C" },
|
|
28
|
+
maxBuffer: 8 * 1024 * 1024,
|
|
29
|
+
}));
|
|
27
30
|
const entries = run("unzip", ["-Z1", bundle]).split("\n");
|
|
28
31
|
const actual = [
|
|
29
32
|
...new Set(
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "disposabl-dev",
|
|
3
3
|
"private": true,
|
|
4
4
|
"scripts": {
|
|
5
|
-
"check": "bun run generate && turbo run typecheck lint && bun fmt --check",
|
|
5
|
+
"check": "bun fmt --check && bun run generate && turbo run typecheck lint && bun fmt --check",
|
|
6
6
|
"hooks:install": ".githooks/install",
|
|
7
7
|
"test": "bun run --cwd packages/tests test",
|
|
8
8
|
"test:unit": "bun run --cwd packages/tests test:unit",
|
|
@@ -36,6 +36,33 @@ test("Android uses its selected runner while allowing native build and cache fin
|
|
|
36
36
|
);
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
test("product and generated apps share one artifact build and gate submission", () => {
|
|
40
|
+
const job = workflow.jobs.android;
|
|
41
|
+
assert.equal(job.if, "needs.web.outputs.android_build == 'true'");
|
|
42
|
+
assert.equal(workflow.jobs["android-play"], undefined);
|
|
43
|
+
assert.equal(
|
|
44
|
+
job.steps.filter((step: { run?: string }) =>
|
|
45
|
+
step.run?.includes("android-build"),
|
|
46
|
+
).length,
|
|
47
|
+
1,
|
|
48
|
+
);
|
|
49
|
+
const submit = workflow.jobs["android-submit"];
|
|
50
|
+
assert.equal(submit.needs, "android");
|
|
51
|
+
assert.equal(
|
|
52
|
+
submit.if,
|
|
53
|
+
"github.event_name == 'push' && vars.ANDROID_PLAY_SUBMIT == 'true' && needs.android.result == 'success'",
|
|
54
|
+
);
|
|
55
|
+
assert.ok(
|
|
56
|
+
submit.steps.some(
|
|
57
|
+
(step: { uses?: string }) => step.uses === "actions/download-artifact@v4",
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
const fingerprint = workflow.jobs.web.steps.find(
|
|
61
|
+
(step: { name?: string }) => step.name === "Fingerprint",
|
|
62
|
+
);
|
|
63
|
+
assert.equal(fingerprint.if, "needs.changes.outputs.android == 'true'");
|
|
64
|
+
});
|
|
65
|
+
|
|
39
66
|
test("Android failure reporting handles failed and cancelled builds independently", () => {
|
|
40
67
|
const job = workflow.jobs["android-failure"];
|
|
41
68
|
const hasPlayJob = !!workflow.jobs["android-play"];
|
|
@@ -27,6 +27,8 @@ function publish(
|
|
|
27
27
|
const channel = options.production ? "production" : "pr-1";
|
|
28
28
|
const sourceTag = `app-${channel}-android${options.production ? "-8-1" : ""}`;
|
|
29
29
|
const manifest = {
|
|
30
|
+
signing: "fallback",
|
|
31
|
+
signingId: "fallback",
|
|
30
32
|
channel,
|
|
31
33
|
projectId: "project",
|
|
32
34
|
applicationId: "app.fixture",
|
|
@@ -12,7 +12,7 @@ import { join, resolve } from "node:path";
|
|
|
12
12
|
import { spawnSync } from "node:child_process";
|
|
13
13
|
|
|
14
14
|
function verifyOtaSelection() {
|
|
15
|
-
for (const [channel, tag, reusable, architectures] of [
|
|
15
|
+
for (const [channel, tag, reusable, architectures, signing, submit] of [
|
|
16
16
|
["pr-1", "app-pr-1-android", true],
|
|
17
17
|
["production", "app-production-android", true],
|
|
18
18
|
["production", "app-production-android-8-1", true],
|
|
@@ -24,6 +24,15 @@ function verifyOtaSelection() {
|
|
|
24
24
|
["pr-1", "app-pr-1-windows", false],
|
|
25
25
|
["production", "app-production-android-8-1", false, ["arm64-v8a"]],
|
|
26
26
|
["production", "app-production-android-8-1", false, null],
|
|
27
|
+
["production", "app-production-android-8-1", false, undefined, "release"],
|
|
28
|
+
[
|
|
29
|
+
"production",
|
|
30
|
+
"app-production-android-8-1",
|
|
31
|
+
false,
|
|
32
|
+
undefined,
|
|
33
|
+
"fallback",
|
|
34
|
+
"true",
|
|
35
|
+
],
|
|
27
36
|
] as const) {
|
|
28
37
|
const cwd = mkdtempSync(join(tmpdir(), "android-ota-selection-"));
|
|
29
38
|
try {
|
|
@@ -31,6 +40,8 @@ function verifyOtaSelection() {
|
|
|
31
40
|
const runtime = "b".repeat(40);
|
|
32
41
|
const hash = "a".repeat(64);
|
|
33
42
|
const manifest = {
|
|
43
|
+
signing: signing ?? "fallback",
|
|
44
|
+
signingId: signing === "release" ? "c".repeat(64) : "fallback",
|
|
34
45
|
channel,
|
|
35
46
|
projectId: "project",
|
|
36
47
|
applicationId: "app.fixture",
|
|
@@ -92,6 +103,7 @@ else process.exit(1);
|
|
|
92
103
|
RELEASE_PREFIX: "app",
|
|
93
104
|
GITHUB_OUTPUT: output,
|
|
94
105
|
ANDROID_SIGNING_READY: "true",
|
|
106
|
+
ANDROID_PLAY_SUBMIT: submit ?? "false",
|
|
95
107
|
},
|
|
96
108
|
},
|
|
97
109
|
);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import {
|
|
4
|
+
mkdtempSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
readFileSync,
|
|
8
|
+
rmSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join, resolve } from "node:path";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
|
|
14
|
+
const scripts = resolve(import.meta.dirname, "../../.github/scripts");
|
|
15
|
+
const sha = "a".repeat(40);
|
|
16
|
+
const newer = "b".repeat(40);
|
|
17
|
+
|
|
18
|
+
test("queued product Android source is accepted only while its event commit remains on main", () => {
|
|
19
|
+
const temp = mkdtempSync(join(tmpdir(), "android-source-"));
|
|
20
|
+
try {
|
|
21
|
+
const bin = join(temp, "bin");
|
|
22
|
+
mkdirSync(bin);
|
|
23
|
+
writeFileSync(join(bin, "git"), '#!/bin/sh\nprintf "%s\\n" "$CHECKOUT"\n', {
|
|
24
|
+
mode: 0o755,
|
|
25
|
+
});
|
|
26
|
+
writeFileSync(
|
|
27
|
+
join(bin, "gh"),
|
|
28
|
+
'#!/bin/sh\ncase "$*" in *compare*) printf "%s\\n" "$COMPARISON";; *) printf "%s\\n" "$CURRENT";; esac\nexit "${GH_EXIT:-0}"\n',
|
|
29
|
+
{ mode: 0o755 },
|
|
30
|
+
);
|
|
31
|
+
const env = {
|
|
32
|
+
...process.env,
|
|
33
|
+
PATH: `${bin}:/usr/bin:/bin`,
|
|
34
|
+
HOME: temp,
|
|
35
|
+
GH_REPO: "disposabl-dev/create-disposabl-app",
|
|
36
|
+
CHANNEL: "production",
|
|
37
|
+
GITHUB_EVENT_NAME: "push",
|
|
38
|
+
GITHUB_REF: "refs/heads/main",
|
|
39
|
+
GITHUB_SHA: sha,
|
|
40
|
+
SOURCE: sha,
|
|
41
|
+
SOURCE_PATH: "git/ref/heads/main",
|
|
42
|
+
CHECKOUT: sha,
|
|
43
|
+
COMPARISON: "ahead",
|
|
44
|
+
CURRENT: newer,
|
|
45
|
+
};
|
|
46
|
+
const run = (
|
|
47
|
+
patch: Record<string, string | undefined> = {},
|
|
48
|
+
platform = "android",
|
|
49
|
+
context = "build",
|
|
50
|
+
) =>
|
|
51
|
+
spawnSync(
|
|
52
|
+
"/bin/bash",
|
|
53
|
+
[
|
|
54
|
+
"-c",
|
|
55
|
+
'set -euo pipefail; source "$1"; verify_release_source "$2" "$3"',
|
|
56
|
+
"_",
|
|
57
|
+
join(scripts, "release-source.sh"),
|
|
58
|
+
platform,
|
|
59
|
+
context,
|
|
60
|
+
],
|
|
61
|
+
{ cwd: temp, env: { ...env, ...patch }, encoding: "utf8" },
|
|
62
|
+
);
|
|
63
|
+
for (const comparison of ["ahead", "identical"]) {
|
|
64
|
+
assert.equal(run({ COMPARISON: comparison }).status, 0);
|
|
65
|
+
assert.equal(
|
|
66
|
+
run({ COMPARISON: comparison, CHECKOUT: newer }, "android", "publish")
|
|
67
|
+
.status,
|
|
68
|
+
0,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
for (const patch of [
|
|
72
|
+
{ COMPARISON: "diverged" },
|
|
73
|
+
{ COMPARISON: "behind" },
|
|
74
|
+
{ COMPARISON: "" },
|
|
75
|
+
{ GH_EXIT: "1" },
|
|
76
|
+
{ GITHUB_SHA: newer },
|
|
77
|
+
{ CHECKOUT: newer },
|
|
78
|
+
{ GITHUB_REF: "refs/heads/other" },
|
|
79
|
+
])
|
|
80
|
+
assert.notEqual(run(patch).status, 0, JSON.stringify(patch));
|
|
81
|
+
assert.notEqual(run({ GH_REPO: "user/generated-app" }).status, 0);
|
|
82
|
+
assert.equal(
|
|
83
|
+
run({ GH_REPO: "user/generated-app", CURRENT: sha }).status,
|
|
84
|
+
0,
|
|
85
|
+
);
|
|
86
|
+
assert.notEqual(run({}, "ios").status, 0);
|
|
87
|
+
assert.notEqual(
|
|
88
|
+
run({
|
|
89
|
+
CHANNEL: "pr-1",
|
|
90
|
+
GITHUB_EVENT_NAME: "pull_request",
|
|
91
|
+
SOURCE_PATH: "pulls/1",
|
|
92
|
+
}).status,
|
|
93
|
+
0,
|
|
94
|
+
);
|
|
95
|
+
assert.equal(
|
|
96
|
+
run({
|
|
97
|
+
CHANNEL: "pr-1",
|
|
98
|
+
GITHUB_EVENT_NAME: "pull_request",
|
|
99
|
+
SOURCE_PATH: "pulls/1",
|
|
100
|
+
CURRENT: sha,
|
|
101
|
+
}).status,
|
|
102
|
+
0,
|
|
103
|
+
);
|
|
104
|
+
assert.notEqual(
|
|
105
|
+
run({ CURRENT: sha, GH_EXIT: "1", GH_REPO: "user/generated-app" }).status,
|
|
106
|
+
0,
|
|
107
|
+
);
|
|
108
|
+
} finally {
|
|
109
|
+
rmSync(temp, { recursive: true, force: true });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test("Android build, submit and artifact publishing use the shared source guard", () => {
|
|
114
|
+
const mobile = readFileSync(join(scripts, "mobile.sh"), "utf8");
|
|
115
|
+
for (const operation of ["android-build", "android-submit"]) {
|
|
116
|
+
const branch = mobile.split(` ${operation})`)[1].split(";;")[0];
|
|
117
|
+
assert.match(branch, /verify_release_source android/);
|
|
118
|
+
assert.doesNotMatch(branch, /repos\/\$GH_REPO\/\$SOURCE_PATH/);
|
|
119
|
+
}
|
|
120
|
+
const release = readFileSync(join(scripts, "release.sh"), "utf8");
|
|
121
|
+
assert.match(release, /verify_release_source "\$platform" publish/);
|
|
122
|
+
assert.match(release, /verify_release_source "\$PLATFORM"/);
|
|
123
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
|
|
6
|
+
// Import the executable helper without adding JavaScript files to the tests
|
|
7
|
+
// workspace's TypeScript compilation scope.
|
|
8
|
+
const { verifySignature } = (await import(
|
|
9
|
+
pathToFileURL(
|
|
10
|
+
resolve(
|
|
11
|
+
import.meta.dirname,
|
|
12
|
+
"../../.github/scripts/android-signatures.mjs",
|
|
13
|
+
),
|
|
14
|
+
).href
|
|
15
|
+
)) as {
|
|
16
|
+
verifySignature: (
|
|
17
|
+
file: string,
|
|
18
|
+
expected: string,
|
|
19
|
+
run: (command: string, args: string[]) => string,
|
|
20
|
+
) => string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const cert = "ab".repeat(32);
|
|
24
|
+
test("APK verifier requires exactly one verified signer and checks the selected identity", () => {
|
|
25
|
+
const valid = () => `Signer #1 certificate SHA-256 digest: ${cert}\n`;
|
|
26
|
+
assert.equal(verifySignature("fixture.apk", "fallback", valid), cert);
|
|
27
|
+
assert.equal(verifySignature("fixture.apk", cert, valid), cert);
|
|
28
|
+
assert.equal(
|
|
29
|
+
verifySignature(
|
|
30
|
+
"fixture.apk",
|
|
31
|
+
cert,
|
|
32
|
+
() => `V2 Signer: certificate SHA-256 digest: ${cert}\n`,
|
|
33
|
+
),
|
|
34
|
+
cert,
|
|
35
|
+
);
|
|
36
|
+
assert.throws(
|
|
37
|
+
() => verifySignature("fixture.apk", "00".repeat(32), valid),
|
|
38
|
+
/signer/,
|
|
39
|
+
);
|
|
40
|
+
assert.throws(() => verifySignature("fixture.apk", cert, () => ""), /signer/);
|
|
41
|
+
assert.throws(
|
|
42
|
+
() => verifySignature("fixture.apk", cert, () => valid() + valid()),
|
|
43
|
+
/signer/,
|
|
44
|
+
);
|
|
45
|
+
assert.throws(
|
|
46
|
+
() =>
|
|
47
|
+
verifySignature("fixture.apk", cert, () => {
|
|
48
|
+
throw new Error("invalid signature");
|
|
49
|
+
}),
|
|
50
|
+
/invalid signature/,
|
|
51
|
+
);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("bundle verification rejects unsigned entries and certificate mismatches", () => {
|
|
55
|
+
const run = (command: string) =>
|
|
56
|
+
command === "jarsigner"
|
|
57
|
+
? "jar verified."
|
|
58
|
+
: `SHA256: ${cert.match(/../g)!.join(":")}\n`;
|
|
59
|
+
assert.equal(verifySignature("fixture.aab", cert, run), cert);
|
|
60
|
+
assert.throws(
|
|
61
|
+
() =>
|
|
62
|
+
verifySignature(
|
|
63
|
+
"fixture.aab",
|
|
64
|
+
cert,
|
|
65
|
+
() => "jar verified. contains unsigned entries",
|
|
66
|
+
),
|
|
67
|
+
/signature/,
|
|
68
|
+
);
|
|
69
|
+
assert.throws(
|
|
70
|
+
() => verifySignature("fixture.aab", "00".repeat(32), run),
|
|
71
|
+
/signer/,
|
|
72
|
+
);
|
|
73
|
+
});
|
|
@@ -265,3 +265,23 @@ test("every EAS backend alias must match the deployed backend before publication
|
|
|
265
265
|
const result = await run("expo-env", { EAS_VARS: JSON.stringify(matching) });
|
|
266
266
|
assert.equal(result.status, 0, result.stderr);
|
|
267
267
|
});
|
|
268
|
+
|
|
269
|
+
test("EAS environment cannot replace Android signing or submission policy", async () => {
|
|
270
|
+
for (const key of [
|
|
271
|
+
"ANDROID_KEYSTORE_BASE64",
|
|
272
|
+
"ANDROID_KEYSTORE_PASSWORD",
|
|
273
|
+
"ANDROID_KEY_ALIAS",
|
|
274
|
+
"ANDROID_KEY_PASSWORD",
|
|
275
|
+
"ANDROID_KEYSTORE_PATH",
|
|
276
|
+
"ANDROID_SIGNING_ID",
|
|
277
|
+
"ANDROID_PLAY_SUBMIT",
|
|
278
|
+
"ANDROID_PLAY_UPLOAD_CERT_SHA256",
|
|
279
|
+
"UPDATE_POLICY",
|
|
280
|
+
]) {
|
|
281
|
+
const result = await run("expo-env", {
|
|
282
|
+
EAS_VARS: JSON.stringify({ [key]: "fixture-override" }),
|
|
283
|
+
});
|
|
284
|
+
assert.notEqual(result.status, 0);
|
|
285
|
+
assert.match(result.stderr, new RegExp(`Reserved EAS variable: ${key}`));
|
|
286
|
+
}
|
|
287
|
+
});
|
|
@@ -43,10 +43,28 @@ test("preview keeps Expo signing and plugin application is idempotent", async ()
|
|
|
43
43
|
const result = await generate("android {}", true);
|
|
44
44
|
assert.match(
|
|
45
45
|
result,
|
|
46
|
-
/if \(System\.getenv\("DISPOSABL_ANDROID_CHANNEL"\) == "production"\)/,
|
|
46
|
+
/if \(System\.getenv\("DISPOSABL_ANDROID_CHANNEL"\) == "production" && System\.getenv\("ANDROID_KEYSTORE_PATH"\)\)/,
|
|
47
47
|
);
|
|
48
48
|
assert.equal(
|
|
49
49
|
result.split("// Disposabl production APK signing.").length - 1,
|
|
50
50
|
1,
|
|
51
51
|
);
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
test("prebuild migrates the old signing block without deleting later custom content", async () => {
|
|
55
|
+
const current = await generate();
|
|
56
|
+
const legacy = current.replace(
|
|
57
|
+
' && System.getenv("ANDROID_KEYSTORE_PATH")',
|
|
58
|
+
"",
|
|
59
|
+
);
|
|
60
|
+
assert.equal(
|
|
61
|
+
await generate(`${legacy}\n// retained customization`),
|
|
62
|
+
`${current}\n// retained customization`,
|
|
63
|
+
);
|
|
64
|
+
await assert.rejects(
|
|
65
|
+
generate(
|
|
66
|
+
legacy.replace("Production Android signing inputs", "Custom inputs"),
|
|
67
|
+
),
|
|
68
|
+
/manual migration/,
|
|
69
|
+
);
|
|
70
|
+
});
|
|
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
|
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import {
|
|
5
5
|
copyFileSync,
|
|
6
|
+
existsSync,
|
|
6
7
|
mkdirSync,
|
|
7
8
|
mkdtempSync,
|
|
8
9
|
readFileSync,
|
|
@@ -26,10 +27,11 @@ function release(options: {
|
|
|
26
27
|
join(directory, "packages/sdk/package.json"),
|
|
27
28
|
JSON.stringify({ name: "@fixture/sdk", version: "1.0.0-development" }),
|
|
28
29
|
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
for (const file of ["release.sh", "release-source.sh"])
|
|
31
|
+
copyFileSync(
|
|
32
|
+
new URL(`../../.github/scripts/${file}`, import.meta.url),
|
|
33
|
+
join(directory, file),
|
|
34
|
+
);
|
|
33
35
|
const executable = (name: string, body: string) =>
|
|
34
36
|
writeFileSync(join(bin, name), `#!/bin/bash\nset -eu\n${body}\n`, {
|
|
35
37
|
mode: 0o755,
|
|
@@ -73,7 +75,12 @@ fi`,
|
|
|
73
75
|
FAIL_RELEASE: String(options.failure ?? false),
|
|
74
76
|
},
|
|
75
77
|
});
|
|
76
|
-
|
|
78
|
+
const calls = join(directory, "calls");
|
|
79
|
+
assert.ok(
|
|
80
|
+
existsSync(calls),
|
|
81
|
+
result.stderr || "Release script did not start",
|
|
82
|
+
);
|
|
83
|
+
return { ...result, calls: readFileSync(calls, "utf8") };
|
|
77
84
|
} finally {
|
|
78
85
|
rmSync(directory, { recursive: true, force: true });
|
|
79
86
|
}
|