generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add linter to plugin build workflow
This update includes the following changes: - Add eslint to the workflow - Refactor workflow to add linter as a blocking check before compiling plugin code - Add workflow step with cached node dependencies to speed up the build process
- Loading branch information
1 parent
cae7cca
commit d8237dc
Showing
9 changed files
with
314 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: 'Node setup and cache' | ||
description: 'Setup Node.js packages and restore cache' | ||
|
||
inputs: | ||
node-version: | ||
description: 'Node version to use, default to 20' | ||
required: true | ||
default: '20' | ||
outputs: | ||
cache-hit: | ||
description: 'Forward actions/cache cache-hit output' | ||
value: ${{ steps.node-cache.outputs.cache-hit }} | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: ⚙️ Setup node.js ${{ inputs.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
- name: 📦 Cache node modules | ||
id: node-cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: node_modules | ||
key: node-modules-${{ inputs.node-version }}-${{ hashFiles('package-lock.json') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,62 @@ | ||
name: Release Obsidian plugin | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
name: Release Obsidian Plugin | ||
on: [push] | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
node-setup: | ||
name: ⚙️ Setup Node.js | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/node-cache | ||
id: cache-node-modules | ||
with: | ||
node-version: '20' | ||
- run: npm i | ||
if: steps.cache-node-modules.outputs.cache-hit != 'true' | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
run-lint: | ||
name: ✅ Linter | ||
needs: node-setup | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/node-cache | ||
id: cache-node-modules | ||
with: | ||
node-version: "18.x" | ||
node-version: '20' | ||
|
||
- name: Build plugin | ||
run: | | ||
npm install | ||
npm run build | ||
- name: ✅ Run code style linter | ||
id: linter | ||
run: npm run lint | ||
|
||
release-plugin: | ||
name: 📦 Release Obsidian Plugin | ||
needs: run-lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/node-cache | ||
id: cache-node-modules | ||
with: | ||
node-version: '20' | ||
|
||
- name: 📗 Build plugin | ||
id: build_plugin | ||
if: steps.cache-node-modules.outcome == 'success' | ||
run: npm run build | ||
|
||
- name: Create release | ||
- name: 📦 Create release | ||
if: steps.build_plugin.outcome == 'success' && contains(github.ref, 'refs/tags/') | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
tag="${GITHUB_REF#refs/tags/}" | ||
tag='${GITHUB_REF#refs/tags/}' | ||
gh release create "$tag" \ | ||
--title="$tag" \ | ||
gh release create '$tag' \ | ||
--title='$tag' \ | ||
--draft \ | ||
main.js manifest.json styles.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.