feat: added github workflow

This commit is contained in:
AidanTilgner 2024-02-01 13:26:58 -08:00
parent aaf2069cb1
commit 3220204d4d
3 changed files with 36 additions and 12 deletions

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

@ -0,0 +1,34 @@
name: Release Obsidian plugin
on:
push:
tags:
- "*"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "18.x"
- name: Build plugin
run: |
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--draft \
main.js manifest.json styles.css

10
main.ts
View file

@ -11,8 +11,6 @@ import OpenAI from "openai";
import { ChatCompletionCreateParamsBase } from "openai/resources/chat/completions";
import { getClient, getReplacement } from "utils/openai";
// Remember to rename these classes and interfaces!
interface AutogenSettings {
openaiApiKey: string;
model: ChatCompletionCreateParamsBase["model"];
@ -65,15 +63,9 @@ export default class Autogen extends Plugin {
const content = editor.getValue();
const windowSize = 5000;
console.log("Editor change: ", content);
// Execute pattern search once instead of looping
const match = pattern.exec(content);
if (match !== null) {
console.log("Found match:", match[0]);
// Calculate window around the match
const start = Math.max(match.index - windowSize / 2, 0);
const end = Math.min(
match.index + match[0].length + windowSize / 2,
@ -81,7 +73,6 @@ export default class Autogen extends Plugin {
);
const textWindow = content.substring(start, end);
console.log("Text window: ", textWindow);
const onConfirm = async (modal: Modal) => {
modal.contentEl.empty();
@ -150,7 +141,6 @@ export default class Autogen extends Plugin {
}
replaceText(editor: Editor, match: string, replacement: string) {
// replace the match with the replacement
const content = editor.getValue();
const newContent = content.replace(match, replacement);
editor.setValue(newContent);

View file

@ -4,8 +4,8 @@
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "In place autogeneration of content based on prompts.",
"author": "Obsidian",
"author": "Aidan Tilgner",
"authorUrl": "https://github.com/AidanTilgner",
"fundingUrl": "https://www.buymeacoffee.com/aidantilgner",
"isDesktopOnly": false
"isDesktopOnly": true
}