Files
tutti/.github/workflows/publish-tutti-app-catalog.yml
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

346 lines
14 KiB
YAML

name: Publish Tutti App Catalog
on:
workflow_dispatch:
inputs:
catalog_mode:
description: Catalog publish mode. Merge preserves existing apps; replace publishes only selected apps.
required: true
default: merge
type: choice
options:
- merge
- replace
app_ids:
description: Optional comma or newline separated remote app ids. In merge mode, leave empty to refresh the existing catalog.
required: false
type: string
withdraw_app_versions:
description: Optional comma or newline separated appId@version entries to withdraw before publishing. Requires merge mode; immutable release files are retained.
required: false
type: string
aws_region:
description: AWS region. Defaults to vars.TUTTI_APP_RELEASES_AWS_REGION.
required: false
type: string
aws_role_arn:
description: AWS role ARN. Defaults to vars.TUTTI_APP_RELEASES_AWS_ROLE_ARN.
required: false
type: string
s3_bucket:
description: S3 bucket. Defaults to vars.TUTTI_APP_RELEASES_S3_BUCKET.
required: false
type: string
s3_prefix:
description: S3 prefix. Defaults to vars.TUTTI_APP_RELEASES_S3_PREFIX.
required: false
type: string
cloudfront_distribution_id:
description: Optional CloudFront distribution id to invalidate after catalog upload.
required: false
type: string
permissions:
contents: read
id-token: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
publish:
runs-on: ubuntu-latest
env:
CATALOG_MODE: ${{ inputs.catalog_mode }}
APP_IDS_INPUT: ${{ inputs.app_ids }}
WITHDRAW_APP_VERSIONS_INPUT: ${{ inputs.withdraw_app_versions }}
AWS_REGION_VALUE: ${{ inputs.aws_region || vars.TUTTI_APP_RELEASES_AWS_REGION }}
AWS_ROLE_ARN_VALUE: ${{ inputs.aws_role_arn || vars.TUTTI_APP_RELEASES_AWS_ROLE_ARN }}
S3_BUCKET_VALUE: ${{ inputs.s3_bucket || vars.TUTTI_APP_RELEASES_S3_BUCKET }}
S3_PREFIX_VALUE: ${{ inputs.s3_prefix || vars.TUTTI_APP_RELEASES_S3_PREFIX }}
CLOUDFRONT_DISTRIBUTION_ID_VALUE: ${{ inputs.cloudfront_distribution_id || vars.TUTTI_APP_RELEASES_CLOUDFRONT_DISTRIBUTION_ID }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Validate AWS configuration
shell: bash
run: |
missing=()
for name in AWS_REGION_VALUE AWS_ROLE_ARN_VALUE S3_BUCKET_VALUE; do
if [ -z "${!name:-}" ]; then
missing+=("${name}")
fi
done
if [ "${#missing[@]}" -gt 0 ]; then
printf 'Missing required AWS configuration: %s\n' "${missing[*]}" >&2
exit 1
fi
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.AWS_REGION_VALUE }}
role-to-assume: ${{ env.AWS_ROLE_ARN_VALUE }}
- name: Withdraw app versions
if: env.WITHDRAW_APP_VERSIONS_INPUT != ''
shell: bash
run: |
if [ "${CATALOG_MODE}" != "merge" ]; then
echo "withdraw_app_versions requires catalog_mode=merge" >&2
exit 1
fi
mkdir -p tutti-app-releases/withdrawals
prefix="${S3_PREFIX_VALUE%/}"
: > tutti-app-releases/withdrawn-app-ids.txt
: > tutti-app-releases/withdrawn-versions.txt
catalog_key="catalog.json"
if [ -n "${prefix}" ]; then
catalog_key="${prefix}/${catalog_key}"
fi
if ! aws s3api get-object \
--bucket "${S3_BUCKET_VALUE}" \
--key "${catalog_key}" \
tutti-app-releases/withdrawal-baseline-catalog.json \
>/dev/null 2>tutti-app-releases/withdrawal-catalog-error.txt; then
if ! grep -Eq "(404|Not Found|NoSuchKey)" \
tutti-app-releases/withdrawal-catalog-error.txt; then
cat tutti-app-releases/withdrawal-catalog-error.txt >&2
exit 1
fi
fi
while IFS= read -r raw_entry; do
entry="$(echo "${raw_entry}" | xargs)"
if [ -z "${entry}" ]; then
continue
fi
if [[ "${entry}" != *@* ]]; then
echo "Withdrawal entry must be appId@version: ${entry}" >&2
exit 1
fi
app_id="${entry%@*}"
version="${entry##*@}"
if [[ ! "${app_id}" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "Invalid app id in withdrawal entry: ${entry}" >&2
exit 1
fi
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid semver in withdrawal entry: ${entry}" >&2
exit 1
fi
marker="${app_id}@${version}"
if grep -Fqx "${marker}" tutti-app-releases/withdrawn-versions.txt; then
echo "Duplicate withdrawal entry: ${marker}" >&2
exit 1
fi
versions_key="apps/${app_id}/versions.json"
versions_path="tutti-app-releases/withdrawals/${app_id}.json"
updated_path="tutti-app-releases/withdrawals/${app_id}.updated.json"
if [ -n "${prefix}" ]; then
versions_key="${prefix}/${versions_key}"
fi
if etag="$(aws s3api head-object \
--bucket "${S3_BUCKET_VALUE}" \
--key "${versions_key}" \
--query ETag \
--output text 2>tutti-app-releases/withdrawal-head-error.txt)"; then
aws s3api get-object \
--bucket "${S3_BUCKET_VALUE}" \
--key "${versions_key}" \
"${versions_path}" \
>/dev/null
pnpm --package @tutti-os/app-release-tools@latest dlx build-tutti-app-versions \
--existing-versions "${versions_path}" \
--set-status-version "${version}" \
--status withdrawn \
--output "${updated_path}"
put_condition=(--if-match "${etag}")
elif grep -Eq "(404|Not Found|NoSuchKey)" \
tutti-app-releases/withdrawal-head-error.txt; then
if [ ! -f tutti-app-releases/withdrawal-baseline-catalog.json ]; then
echo "Cannot bootstrap missing versions index for ${app_id}: catalog baseline is unavailable" >&2
exit 1
fi
min_tutti_version="$(node -e '
const fs = require("fs");
const catalog = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
const appId = process.argv[2];
const version = process.argv[3];
const compatibility = catalog.compatibility?.apps?.[appId] ?? [];
const compatible = compatibility.find(
(entry) => entry?.app?.manifest?.version === version
);
if (compatible?.minTuttiVersion) {
console.log(compatible.minTuttiVersion);
process.exit(0);
}
const legacy = (catalog.apps ?? []).find(
(app) =>
app?.manifest?.appId === appId &&
app?.manifest?.version === version
);
if (legacy) console.log("0.0.0");
' tutti-app-releases/withdrawal-baseline-catalog.json "${app_id}" "${version}")"
if [ -z "${min_tutti_version}" ]; then
echo "Cannot infer compatibility baseline for ${app_id}@${version}" >&2
exit 1
fi
release_key="apps/${app_id}/${version}/release.json"
release_path="tutti-app-releases/withdrawals/${app_id}.${version}.release.json"
if [ -n "${prefix}" ]; then
release_key="${prefix}/${release_key}"
fi
aws s3api get-object \
--bucket "${S3_BUCKET_VALUE}" \
--key "${release_key}" \
"${release_path}" \
>/dev/null
pnpm --package @tutti-os/app-release-tools@latest dlx build-tutti-app-versions \
--release-file "${release_path}" \
--min-tutti-version "${min_tutti_version}" \
--status withdrawn \
--output "${updated_path}"
put_condition=(--if-none-match '*')
else
cat tutti-app-releases/withdrawal-head-error.txt >&2
exit 1
fi
aws s3api put-object \
--bucket "${S3_BUCKET_VALUE}" \
--key "${versions_key}" \
--body "${updated_path}" \
--content-type application/json \
--cache-control "public, max-age=60" \
"${put_condition[@]}" \
>/dev/null
printf '%s\n' "${app_id}" >> tutti-app-releases/withdrawn-app-ids.txt
printf '%s\n' "${marker}" >> tutti-app-releases/withdrawn-versions.txt
done < <(printf '%s\n' "${WITHDRAW_APP_VERSIONS_INPUT}" | tr ',' '\n')
sort -u -o tutti-app-releases/withdrawn-app-ids.txt \
tutti-app-releases/withdrawn-app-ids.txt
echo "Withdrawn versions:"
cat tutti-app-releases/withdrawn-versions.txt
- name: Resolve catalog app ids
shell: bash
run: |
if [ "${CATALOG_MODE}" != "merge" ] && [ "${CATALOG_MODE}" != "replace" ]; then
echo "Unknown catalog mode: ${CATALOG_MODE}" >&2
exit 1
fi
app_ids_value="${APP_IDS_INPUT}"
mkdir -p tutti-app-releases
prefix="${S3_PREFIX_VALUE%/}"
catalog_key="catalog.json"
if [ -n "${prefix}" ]; then
s3_root="s3://${S3_BUCKET_VALUE}/${prefix}"
catalog_key="${prefix}/catalog.json"
else
s3_root="s3://${S3_BUCKET_VALUE}"
fi
if [ "${CATALOG_MODE}" = "merge" ]; then
if aws s3api head-object --bucket "${S3_BUCKET_VALUE}" --key "${catalog_key}" >/dev/null 2>tutti-app-releases/catalog-head-error.txt; then
aws s3 cp "${s3_root}/catalog.json" tutti-app-releases/existing-catalog.json
elif grep -Eq "(404|Not Found|NoSuchKey)" tutti-app-releases/catalog-head-error.txt; then
echo "No existing catalog found. Merge will publish selected app ids only." >&2
else
echo "Failed to check existing catalog. Refusing to publish a partial merge catalog." >&2
cat tutti-app-releases/catalog-head-error.txt >&2
exit 1
fi
fi
if [ -z "${app_ids_value}" ] && [ "${CATALOG_MODE}" = "merge" ] && [ -f tutti-app-releases/existing-catalog.json ]; then
existing_app_ids="$(node -e '
const fs = require("fs");
const catalog = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
const appIds = new Set(
(catalog.apps ?? []).map((app) => app?.manifest?.appId)
);
for (const appId of Object.keys(catalog.compatibility?.apps ?? {})) {
appIds.add(appId);
}
for (const appId of Object.keys(catalog.compatibility?.capabilityApps ?? {})) {
appIds.add(appId);
}
for (const appId of [...appIds].filter(Boolean).map((value) => value.trim()).filter(Boolean).sort()) {
console.log(appId);
}
' tutti-app-releases/existing-catalog.json)"
app_ids_value="${existing_app_ids}"
fi
if [ -s tutti-app-releases/withdrawn-app-ids.txt ]; then
app_ids_value="${app_ids_value},$(paste -sd, tutti-app-releases/withdrawn-app-ids.txt)"
fi
: > tutti-app-releases/app-ids.txt
while IFS= read -r app_id; do
app_id="$(echo "${app_id}" | xargs)"
if [ -z "${app_id}" ]; then
continue
fi
printf '%s\n' "${app_id}" >> tutti-app-releases/app-ids.txt
done < <(printf '%s\n' "${app_ids_value}" | tr ',' '\n')
if [ ! -s tutti-app-releases/app-ids.txt ]; then
echo "At least one app id is required" >&2
exit 1
fi
- name: Publish app catalog
shell: bash
run: |
args=(
--s3-bucket "${S3_BUCKET_VALUE}"
--s3-prefix "${S3_PREFIX_VALUE}"
--mode "${CATALOG_MODE}"
--output-dir tutti-app-catalog
)
while IFS= read -r app_id; do
args+=(--app-id "${app_id}")
done < tutti-app-releases/app-ids.txt
pnpm --package @tutti-os/app-release-tools@latest dlx publish-tutti-app-catalog "${args[@]}"
- name: Verify app catalog artifacts
shell: bash
run: |
pnpm --package @tutti-os/app-release-tools@latest dlx verify-tutti-app-release-artifacts \
--catalog-file tutti-app-catalog/catalog.json
- name: Invalidate CloudFront catalog
if: env.CLOUDFRONT_DISTRIBUTION_ID_VALUE != ''
shell: bash
run: |
prefix="${S3_PREFIX_VALUE%/}"
if [ -n "${prefix}" ]; then
path_to_invalidate="/${prefix}/catalog.json"
else
path_to_invalidate="/catalog.json"
fi
aws cloudfront create-invalidation \
--distribution-id "${CLOUDFRONT_DISTRIBUTION_ID_VALUE}" \
--paths "${path_to_invalidate}"