asc-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseasc workflow
asc workflow
Use this skill when you need lane-style automation inside the CLI using:
asc workflow runasc workflow validateasc workflow list
This feature is best for deterministic automation that lives in your repo, is reviewable in PRs, and can run the same way locally and in CI.
当你需要在CLI中实现lane风格的自动化时,可以使用该功能,涉及以下命令:
asc workflow runasc workflow validateasc workflow list
该功能最适合用于确定性的自动化流程,这类流程存储在你的仓库中,可在PR中进行评审,并且能在本地和CI环境中以相同方式运行。
Command discovery
命令探索
- Always use to confirm flags and subcommands:
--helpasc workflow --helpasc workflow run --helpasc workflow validate --helpasc workflow list --help
始终使用来确认可用的标志和子命令:
--helpasc workflow --helpasc workflow run --helpasc workflow validate --helpasc workflow list --help
End-to-end flow
端到端流程
- Author
.asc/workflow.json - Validate structure and references:
asc workflow validate
- Discover available workflows:
asc workflow list- (includes private helpers)
asc workflow list --all
- Preview execution without side effects:
asc workflow run --dry-run beta
- Execute with runtime params:
asc workflow run beta BUILD_ID:123456789 GROUP_ID:abcdef
- 编写文件
.asc/workflow.json - 验证文件结构和引用:
asc workflow validate
- 查看可用的工作流:
asc workflow list- (包含私有辅助工作流)
asc workflow list --all
- 预执行以预览效果,无实际副作用:
asc workflow run --dry-run beta
- 传入运行时参数执行:
asc workflow run beta BUILD_ID:123456789 GROUP_ID:abcdef
File location and format
文件位置与格式
- Default path:
.asc/workflow.json - Override path:
asc workflow run --file ./path/to/workflow.json <name> - JSONC comments are supported (and
//)/* ... */
- 默认路径:
.asc/workflow.json - 覆盖路径:
asc workflow run --file ./path/to/workflow.json <name> - 支持JSONC注释(和
//)/* ... */
Output and CI contract
输出与CI约定
- : structured JSON result (
stdout,status, durations)steps - : step command output, hook output, dry-run previews
stderr - always prints JSON and returns non-zero when invalid
asc workflow validate
This enables machine-safe checks:
bash
asc workflow validate | jq -e '.valid == true'
asc workflow run beta BUILD_ID:123 GROUP_ID:xyz | jq -e '.status == "ok"'- :结构化JSON结果(包含
stdout、status、执行时长)steps - :步骤命令输出、钩子输出、预执行预览内容
stderr - 始终输出JSON格式,当文件无效时返回非零状态码
asc workflow validate
这使得机器可安全地进行校验:
bash
asc workflow validate | jq -e '.valid == true'
asc workflow run beta BUILD_ID:123 GROUP_ID:xyz | jq -e '.status == "ok"'Schema (what the feature supports)
Schema(功能支持的内容)
Top-level keys:
- : global defaults
env - : command run once before steps
before_all - : command run once after successful steps
after_all - : command run when any failure occurs
error - : named workflow map
workflows
Workflow keys:
description- (not directly runnable)
private envsteps
Step forms:
- String shorthand: -> run step
"echo hello" - Object with:
- : shell command
run - : call sub-workflow
workflow - : label for reporting
name - : conditional var name
if - : env overrides for workflow-call steps only
with
顶级键:
- :全局默认环境变量
env - :在步骤执行前运行一次的命令
before_all - :在所有步骤成功执行后运行一次的命令
after_all - :当任何步骤失败时运行的命令
error - :命名工作流的映射表
workflows
工作流键:
- :描述信息
description - (不可直接运行)
private - :工作流专属环境变量
env - :工作流步骤
steps
步骤形式:
- 字符串简写形式:-> 运行该步骤
"echo hello" - 对象形式包含以下字段:
- :Shell命令
run - :调用子工作流
workflow - :用于报告的步骤名称
name - :条件变量名称
if - :仅在调用子工作流的步骤中生效的环境变量覆盖配置
with
Runtime params (KEY:VALUE
/ KEY=VALUE
)
KEY:VALUEKEY=VALUE运行时参数(KEY:VALUE
/ KEY=VALUE
)
KEY:VALUEKEY=VALUE- supports both separators:
asc workflow run <name> [KEY:VALUE ...]VERSION:2.1.0VERSION=2.1.0
- If both separators exist, the first one wins.
- Repeated keys are last-write-wins.
- In step commands, reference params via shell expansion ().
$VAR - Avoid putting secrets in ; pass them via CI secrets/env.
.asc/workflow.json
- 支持两种分隔符:
asc workflow run <name> [KEY:VALUE ...]VERSION:2.1.0VERSION=2.1.0
- 如果同时存在两种分隔符,以第一个为准
- 重复的参数键以最后一次赋值为准
- 在步骤命令中,通过Shell变量展开()来引用参数
$VAR - 避免在中存储敏感信息;请通过CI的环境变量或机密传递
.asc/workflow.json
Run-tail flags
后置运行标志
asc workflow run--dry-run--pretty--file
Examples:
asc workflow run beta --dry-runasc workflow run beta --file .asc/workflow.json BUILD_ID:123
asc workflow run--dry-run--pretty--file
示例:
asc workflow run beta --dry-runasc workflow run beta --file .asc/workflow.json BUILD_ID:123
Execution semantics
执行语义
- runs once before step execution
before_all - runs only when steps succeed
after_all - runs on failure (step failure, before/after hook failure)
error - Sub-workflows are executed inline as part of the call step
- Maximum sub-workflow nesting depth is 16
- 在步骤执行前仅运行一次
before_all - 仅在所有步骤成功执行后运行
after_all - 在出现失败时运行(步骤失败、前置/后置钩子失败)
error - 子工作流会作为调用步骤的一部分内联执行
- 子工作流的最大嵌套深度为16层
Env precedence
环境变量优先级
Main workflow run:
- <
definition.env< CLI paramsworkflow.env
Sub-workflow call step ():
"workflow": "...", "with": {...}- sub-workflow defaults
env - caller env (including CLI params) overrides
- step overrides all
with
主工作流运行时:
- <
definition.env< CLI参数workflow.env
子工作流调用步骤():
"workflow": "...", "with": {...}- 子工作流的默认值
env - 调用方的环境变量(包括CLI参数)会覆盖默认值
- 步骤的配置会覆盖所有上述值
with
Sub-workflows and private workflows
子工作流与私有工作流
- Use to call helper workflows.
"workflow": "<name>" - Use for helper-only workflows.
"private": true - Private workflows:
- cannot be run directly
- can be called by other workflows
- are hidden from unless
asc workflow listis used--all
- Validation catches unknown workflow references and cyclic references.
- 使用来调用辅助工作流
"workflow": "<name>" - 使用标记仅作为辅助使用的工作流
"private": true - 私有工作流:
- 无法直接运行
- 可被其他工作流调用
- 在中默认隐藏,除非使用
asc workflow list参数--all
- 验证过程会检测未知的工作流引用和循环引用
Conditionals (if
)
if条件判断(if
)
if- Add on a step.
"if": "VAR_NAME" - Step runs only if is truthy.
VAR_NAME - Truthy: ,
1,true,yes,y(case-insensitive).on - Resolution order for lookup:
if- merged workflow env/params
os.Getenv(VAR_NAME)
- 在步骤中添加配置
"if": "VAR_NAME" - 仅当为真值时,该步骤才会运行
VAR_NAME - 真值包括:、
1、true、yes、y(不区分大小写)on - 变量的查找顺序:
if- 合并后的工作流环境变量/参数
- (系统环境变量)
os.Getenv(VAR_NAME)
Dry-run behavior
预执行(Dry-run)行为
- does not execute commands.
asc workflow run --dry-run <name> - It prints previews to .
stderr - Dry-run shows raw commands (without env expansion), which helps avoid secret leakage in previews.
- 不会实际执行命令
asc workflow run --dry-run <name> - 会将预览内容输出到
stderr - 预执行会显示原始命令(不进行环境变量展开),有助于避免在预览中泄露敏感信息
Shell behavior
Shell行为
- Run steps use when bash is available.
bash -o pipefail -c - Fallback is when bash is unavailable.
sh -c - Pipelines therefore fail correctly in most CI shells when bash exists.
- 当系统存在bash时,步骤会使用来执行
bash -o pipefail -c - 当bash不可用时,会回退到
sh -c - 因此,在大多数CI Shell中,如果存在bash,流水线会正确地在失败时终止
Practical authoring rules
实用编写规则
- Keep workflow files in version control.
- Use IDs in step commands where possible for deterministic automation.
- Use for destructive
--confirmoperations inside steps.asc - Validate first, then dry-run, then real run.
- Keep hooks lightweight and side-effect aware.
json
{
"env": {
"APP_ID": "123456789",
"VERSION": "1.0.0"
},
"before_all": "asc auth status",
"after_all": "echo workflow_done",
"error": "echo workflow_failed",
"workflows": {
"beta": {
"description": "Distribute a build to a TestFlight group and notify",
"env": {
"GROUP_ID": ""
},
"steps": [
{
"name": "list_builds",
"run": "asc builds list --app $APP_ID --sort -uploadedDate --limit 5"
},
{
"name": "list_groups",
"run": "asc testflight beta-groups list --app $APP_ID --limit 20"
},
{
"name": "add_build_to_group",
"if": "BUILD_ID",
"run": "asc builds add-groups --build $BUILD_ID --group $GROUP_ID"
},
{
"name": "notify",
"if": "SLACK_WEBHOOK",
"run": "echo sent_release_notice"
}
]
},
"release": {
"description": "Submit a version for App Store review",
"steps": [
{
"workflow": "sync-metadata",
"with": {
"METADATA_DIR": "./metadata"
}
},
{
"name": "submit",
"run": "asc submit create --app $APP_ID --version $VERSION --build $BUILD_ID --confirm"
}
]
},
"sync-metadata": {
"private": true,
"description": "Private helper workflow (callable only via workflow steps)",
"steps": [
{
"name": "migrate_validate",
"run": "echo METADATA_DIR_is_$METADATA_DIR"
}
]
}
}
}- 将工作流文件纳入版本控制
- 尽可能在步骤命令中使用ID,以实现确定性的自动化
- 在步骤中执行具有破坏性的操作时,使用
asc参数--confirm - 先验证,再预执行,最后实际运行
- 保持钩子轻量化,并注意其副作用
json
{
"env": {
"APP_ID": "123456789",
"VERSION": "1.0.0"
},
"before_all": "asc auth status",
"after_all": "echo workflow_done",
"error": "echo workflow_failed",
"workflows": {
"beta": {
"description": "Distribute a build to a TestFlight group and notify",
"env": {
"GROUP_ID": ""
},
"steps": [
{
"name": "list_builds",
"run": "asc builds list --app $APP_ID --sort -uploadedDate --limit 5"
},
{
"name": "list_groups",
"run": "asc testflight beta-groups list --app $APP_ID --limit 20"
},
{
"name": "add_build_to_group",
"if": "BUILD_ID",
"run": "asc builds add-groups --build $BUILD_ID --group $GROUP_ID"
},
{
"name": "notify",
"if": "SLACK_WEBHOOK",
"run": "echo sent_release_notice"
}
]
},
"release": {
"description": "Submit a version for App Store review",
"steps": [
{
"workflow": "sync-metadata",
"with": {
"METADATA_DIR": "./metadata"
}
},
{
"name": "submit",
"run": "asc submit create --app $APP_ID --version $VERSION --build $BUILD_ID --confirm"
}
]
},
"sync-metadata": {
"private": true,
"description": "Private helper workflow (callable only via workflow steps)",
"steps": [
{
"name": "migrate_validate",
"run": "echo METADATA_DIR_is_$METADATA_DIR"
}
]
}
}
}Useful invocations
常用调用示例
bash
undefinedbash
undefinedValidate and fail CI on invalid file
验证文件有效性,若无效则终止CI流程
asc workflow validate | jq -e '.valid == true'
asc workflow validate | jq -e '.valid == true'
Show discoverable workflows
显示可发现的工作流
asc workflow list --pretty
asc workflow list --pretty
Include private helpers
包含私有辅助工作流
asc workflow list --all --pretty
asc workflow list --all --pretty
Preview a real run
预览实际运行效果
asc workflow run --dry-run beta BUILD_ID:123 GROUP_ID:grp_abc
asc workflow run --dry-run beta BUILD_ID:123 GROUP_ID:grp_abc
Run with params and assert success
传入参数运行并断言执行成功
asc workflow run beta BUILD_ID:123 GROUP_ID:grp_abc | jq -e '.status == "ok"'
undefinedasc workflow run beta BUILD_ID:123 GROUP_ID:grp_abc | jq -e '.status == "ok"'
undefined