generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
4,885 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,34 @@ | ||
name: Release Obsidian Plugin | ||
name: Release Obsidian plugin | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '14.x' | ||
- name: Get Version | ||
id: version | ||
run: | | ||
echo "::set-output name=tag::$(git describe --abbrev=0)" | ||
- name: Build | ||
id: build | ||
node-version: '18.x' | ||
|
||
- name: Build plugin | ||
run: | | ||
yarn | ||
yarn run build | ||
# Create the release on github | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
npm install | ||
npm run build | ||
- name: Create release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ github.ref }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
# Upload the main.js | ||
- name: Upload main.js | ||
id: upload-main | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./main.js | ||
asset_name: main.js | ||
asset_content_type: text/javascript | ||
# Upload the manifest.json | ||
- name: Upload manifest.json | ||
id: upload-manifest | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./manifest.json | ||
asset_name: manifest.json | ||
asset_content_type: application/json | ||
# Upload the style.css | ||
- name: Upload styles.css | ||
id: upload-css | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./styles.css | ||
asset_name: styles.css | ||
asset_content_type: text/css | ||
run: | | ||
tag="${GITHUB_REF#refs/tags/}" | ||
gh release create "$tag" \ | ||
--title="$tag" \ | ||
--notes-file="release-notes.md" \ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import fs from 'fs'; | ||
|
||
function readFiles(dirname, onFileContent, onError, done) { | ||
fs.readdir(dirname, function (err, filenames) { | ||
if (err) { | ||
onError(err); | ||
return; | ||
} | ||
|
||
for (let filename of filenames) { | ||
if (!filename.endsWith('.json')) continue; | ||
const content = fs.readFileSync(dirname + filename); | ||
onFileContent(filename, JSON.parse(content.toString())); | ||
} | ||
|
||
done(); | ||
}); | ||
} | ||
|
||
const iconList = []; | ||
|
||
readFiles( | ||
'../lucide/icons/', | ||
function (filename, content) { | ||
const id = filename.split('.')[0]; | ||
const tags = content.tags || []; | ||
const aliases = content.aliases || []; | ||
|
||
iconList.push({ | ||
id: 'lucide-' + id, | ||
aliases: [...tags, ...aliases], | ||
}); | ||
}, | ||
function (err) { | ||
throw err; | ||
}, | ||
function () { | ||
fs.writeFileSync( | ||
'./src/iconList.ts', | ||
`import Fuse from 'fuse.js'; | ||
import { getIconIds } from 'obsidian'; | ||
export const iconListRaw = ${JSON.stringify(iconList, null, 2)}; | ||
getIconIds().forEach(id => { | ||
if (!/^lucide/.test(id)) { | ||
iconListRaw.push({ | ||
id, | ||
aliases: [], | ||
}) | ||
} | ||
}) | ||
export const iconList = new Fuse(iconListRaw, { | ||
threshold: 0.1, | ||
minMatchCharLength: 2, | ||
keys: ['id', 'aliases'], | ||
}); | ||
` | ||
); | ||
} | ||
); |
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.