ci: replace build workflow with dedicated CI and release pipelines and update version bumping logic

This commit is contained in:
Juan Carlos Garcia Esquivel 2026-04-30 02:15:37 -06:00
parent fab29b6b6a
commit 07207f3b74
No known key found for this signature in database
GPG key ID: AE72E3F3B26486E1
4 changed files with 90 additions and 32 deletions

34
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,34 @@
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build

View file

@ -1,28 +0,0 @@
name: Node.js build
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run build --if-present
- run: npm run lint

53
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,53 @@
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[@]}"

View file

@ -11,7 +11,6 @@ writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
// update versions.json with target version and minAppVersion from manifest.json
// but only if the target version is not already in versions.json
const versions = JSON.parse(readFileSync('versions.json', 'utf8'));
if (!Object.values(versions).includes(minAppVersion)) {
versions[targetVersion] = minAppVersion;
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));
}
versions[targetVersion] = minAppVersion;
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));