feat: 新增 setup-opencode action,支持 npm 全局安装和智能缓存

- 使用 npm 全局安装 OpenCode,支持版本管理和自动更新
- 智能缓存策略:缓存 npm 目录和全局安装,加速后续构建
- 支持淘宝镜像源和自定义 npm 镜像,国内环境友好
- 版本检测:自动比对已安装版本,避免重复安装
- 输出安装版本、缓存命中状态和更新状态
- 提供详细的使用文档和多场景示例
This commit is contained in:
Lyda
2026-03-17 16:17:03 +08:00
parent 1618c6fe6d
commit 489cc94316
6 changed files with 724 additions and 0 deletions
@@ -0,0 +1,21 @@
name: Custom Registry Example
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 使用自定义 npm 镜像源
uses: ./.gitea/actions/setup-opencode
with:
version: '1.2.3'
npm-registry: 'https://registry.npmmirror.com'
- name: 构建
run: |
opencode build