raven-pensieve_obsidian-ace.../.github/workflows/release.yml
RavenHogwarts f2fd8e44e0 ci: 添加构建制品证明生成功能
在发布工作流中添加构建制品证明生成步骤,以增强
安全性和可追溯性。

新增 id-token 和 attestations 权限以支持制品
证明的生成。使用 actions/attest-build-provenance
操作为主要输出文件(main.js、manifest.json 和
styles.css)生成证明,确保发布的制品的完整性
和来源可验证。
2026-05-13 15:11:31 +08:00

92 lines
2.9 KiB
YAML

name: Release Obsidian plugin
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*" # 匹配类似 1.0.0 或 1.0.0-beta.1 的格式
permissions:
contents: write
id-token: write
attestations: write
env:
PLUGIN_ID: ace-code-editor # 插件ID
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的git历史
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Prepare manifest
id: prepare_manifest
run: |
if [[ ${{ github.ref }} == *"beta"* ]]; then
echo "📦 Using beta manifest"
cp manifest-beta.json manifest.json
else
echo "📦 Using stable manifest"
fi
- name: Build
id: build
run: |
pnpm install --frozen-lockfile
pnpm run build
echo "tag_name=$(git tag --sort version:refname | tail -n 1)" >> $GITHUB_OUTPUT
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: |
dist/main.js
dist/manifest.json
dist/styles.css
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: ${{ contains(github.ref, 'beta') }}
generate_release_notes: true
body: |
${{ contains(github.ref, 'beta') && '🚧 This is a beta release' || '🎉 This is a stable release' }}
**Version:** ${{ github.ref_name }}
files: |
dist/main.js
dist/manifest.json
dist/styles.css
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}