tcyeee_obsidian-image-cluster/.github/workflows/release.yml
tcyeee ed6954a22b ci: publish releases directly instead of leaving them as drafts
gh release create --draft has been requiring a manual "Publish release"
click on GitHub after every CI run since this workflow was added; if that
step gets forgotten, Obsidian's manifest.json version has no matching
public release ("No release matches your manifest version"). Every prior
release was published this way by hand. Drop --draft so a green CI run is
itself the publish step, and pull release notes from the pushed annotated
tag's message (with --generate-notes as a fallback for lightweight tags)
instead of leaving the release body empty.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 21:25:23 +08:00

64 lines
1.8 KiB
YAML

name: Release Obsidian plugin
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
# 版本取自 package.json 的 packageManager 字段
- uses: pnpm/action-setup@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"
- name: Build plugin
run: |
pnpm install --frozen-lockfile
pnpm run build
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: |
main.js
styles.css
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
# actions/checkout leaves a lightweight ref for the tag (pointing at the commit,
# not the annotated tag object), which loses the annotation message. Re-fetch the
# real tag object by name so %(contents) below reads the release notes we wrote
# into the tag message, not the commit's own message.
git fetch origin "refs/tags/$tag:refs/tags/$tag" --force
notes="$(git tag -l --format='%(contents)' "$tag")"
if [ -n "$notes" ]; then
echo "$notes" > /tmp/release-notes.md
gh release create "$tag" \
--title="$tag" \
--notes-file /tmp/release-notes.md \
main.js manifest.json styles.css
else
gh release create "$tag" \
--title="$tag" \
--generate-notes \
main.js manifest.json styles.css
fi