---
title: "从 CI 下载到标签发布"
description: "同一个项目用两份工作流交付源码 ZIP 和校验和。提交样例中的 CHANGELOG.md，保留 .github/ 的目录结构，将 XOVA_ACTIONS_SHA 替换为 xova-dev/actions 中已通过 CI 的完整提交 SHA。"
canonical_url: "https://actions.xovajs.com/zh-cn/examples/downloads"
---
# 从 CI 下载到标签发布

> 同一个项目用两份工作流交付源码 ZIP 和校验和。提交样例中的 CHANGELOG.md，保留 .github/ 的目录结构，将 XOVA_ACTIONS_SHA 替换为 xova-dev/actions 中已通过 CI 的完整提交 SHA。

同一个项目用两份工作流交付源码 ZIP 和校验和。提交样例中的 `CHANGELOG.md`，保留 `.github/` 的目录结构，将 `XOVA_ACTIONS_SHA` 替换为 `xova-dev/actions` 中已通过 CI 的完整提交 SHA。

[完整项目](https://github.com/xova-dev/actions/tree/main/examples/downloads)

## 项目配置

本例只需 Git、unzip 和 sha256sum。替换项目检查、构建命令及附件清单即可用于 APK 等其他文件。

```json [.github/xova.json]
{
  "schemaVersion": 1,
  "setup": { "install-command": ":" },
  "code": { "check-command": "git show --check --oneline HEAD" },
  "artifact": {
    "kind": "release-assets",
    "check-command": "git ls-files --error-unmatch CHANGELOG.md",
    "build-command": "mkdir -p dist && git archive --format=zip -o dist/source.zip HEAD && cd dist && unzip -tq source.zip && sha256sum source.zip > source.zip.sha256",
    "output-directory": "dist"
  },
  "github-release": { "assets": ["source.zip", "source.zip.sha256"] }
}
```

## 日常 CI

PR、main 推送和每夜定时使用同一套检查。构建在检查通过后开始，下载 Actions 产物并打开 `payload/` 即可测试。只需代码检查时可省略 build job。

```yaml [.github/workflows/ci.yml]
name: CI
on:
  pull_request:
  push:
    branches: [main]
  schedule:
    - cron: '15 2 * * *'
permissions:
  contents: read
jobs:
  check:
    uses: xova-dev/actions/.github/workflows/check.yml@XOVA_ACTIONS_SHA
  build:
    needs: check
    uses: xova-dev/actions/.github/workflows/check.yml@XOVA_ACTIONS_SHA
    with:
      task: artifact
      source-sha: ${{ needs.check.outputs.source-sha }}
```

## 标签发布

标签运行复用同一 SHA 的完整 CI，未命中就补跑，再用相同配置重新构建并传递本次运行的附件 ID。只发版本说明时，设 `"github-release": {}`，让 publish 直接依赖 verify 并传其 SHA，省略 build 和附件 ID。

```yaml [.github/workflows/publish.yml]
name: Publish
on:
  push:
    tags: ['v*']
permissions:
  contents: read
jobs:
  verify:
    uses: xova-dev/actions/.github/workflows/check-ci.yml@XOVA_ACTIONS_SHA
    permissions:
      contents: read
      actions: read
    with:
      run-check-on-miss: true
  build:
    needs: verify
    uses: xova-dev/actions/.github/workflows/check.yml@XOVA_ACTIONS_SHA
    with:
      task: artifact
      source-sha: ${{ needs.verify.outputs.source-sha }}
  publish:
    needs: build
    uses: xova-dev/actions/.github/workflows/publish.yml@XOVA_ACTIONS_SHA
    permissions:
      contents: write
      id-token: write
    with:
      expected-sha: ${{ needs.build.outputs.source-sha }}
      release-artifact-id: ${{ needs.build.outputs.artifact-id }}
```

可选交付见[发布 npm 包](https://actions.xovajs.com/zh-cn/guides/releasing)和[独立或随稳定版部署](https://actions.xovajs.com/zh-cn/guides/deployment)。


## Sitemap

See the full [sitemap](https://actions.xovajs.com/sitemap.md) for all pages.
