jcmexdev_obsidian-image-hoist/.github/workflows/release.yml

53 lines
1.3 KiB
YAML

name: Release Obsidian plugin
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Build plugin
run: |
npm ci
npm run build
- name: Validate version
run: |
tag="${GITHUB_REF#refs/tags/}"
manifest_version=$(jq -r '.version' manifest.json)
if [ "$tag" != "$manifest_version" ]; then
echo "Error: Tag '$tag' does not match manifest version '$manifest_version'"
echo "Obsidian releases require the tag to match the version in manifest.json exactly (e.g., 1.0.0, not v1.0.0)."
exit 1
fi
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
# Prepare list of files to upload
files=("main.js" "manifest.json")
if [ -f "styles.css" ]; then
files+=("styles.css")
fi
gh release create "$tag" \
--title="$tag" \
--draft \
--generate-notes \
"${files[@]}"