Skip to content

Commit

Permalink
refactor: migrate project to TypeScript and Rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
liby committed Aug 7, 2024
1 parent 3a6677d commit 821089b
Show file tree
Hide file tree
Showing 21 changed files with 1,732 additions and 1,097 deletions.
88 changes: 59 additions & 29 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Release
name: Bump Version and Release

on:
push:
tags: [ v\d+\.\d+\.\d+ ]

workflow_dispatch:
inputs:
version:
description: 'Tag version (e.g., 1.0.0 or v1.0.0)'
required: true
message:
description: 'Tag message'
required: true

jobs:
release:
Expand All @@ -14,52 +19,77 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Get tag message
id: tag
- name: Determine tag version
id: determine_version
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
echo "message=$(git tag -l --format='%(contents:subject)' ${{ steps.get_version.outputs.version }})" >> $GITHUB_OUTPUT
VERSION="${{ github.event.inputs.version }}"
if [[ $VERSION != v* ]]; then
VERSION="v$VERSION"
fi
VERSION_NUMBER="${VERSION#v}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
- name: Change version
- name: Update info.json
run: |
OLD_VERSION=$(grep '"version":' src/info.json | awk -F\" '{print $4}')
sed -i "s/$OLD_VERSION/${{ steps.get_version.outputs.version-without-v }}/" src/info.json
OLD_VERSION=$(grep '"version":' public/info.json | awk -F\" '{print $4}')
sed -i "s/$OLD_VERSION/${{ env.VERSION_NUMBER }}/" public/info.json
- name: Package plugin
run: mkdir release && zip -j -r release/openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin ./src/*
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm

- run: pnpm install
- run: pnpm run build

- run: git checkout -- src/
- name: Package plugin
run: |
zip -j -r dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin ./dist/*
echo "Packaged file: dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin"
- name: Update appcast.json
env:
VERSION_NUMBER: ${{ env.VERSION_NUMBER }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
python3 scripts/update_release.py ${{ steps.get_version.outputs.version-without-v }} '${{ steps.tag.outputs.message }}'
python3 scripts/update_appcast.py "$VERSION_NUMBER" "$MESSAGE"
- name: Commit files
run: |
git config --global user.name 'Bryan Lee'
git config --global user.email '38807139+liby@users.noreply.github.com'
git commit -am 'chore: update appcast.json and info.json'
git commit -a -m 'chore: update appcast.json and info.json'
- name: Create tag
env:
VERSION: ${{ env.VERSION }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
git tag -a "$VERSION" -m "$MESSAGE"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.PAT }}
tags: true

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
release_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ env.VERSION }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin
asset_name: openai-polisher-${{ steps.get_version.outputs.version-without-v }}.bobplugin
tag: ${{ github.ref }}
file: dist/openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin
asset_name: openai-polisher-${{ env.VERSION_NUMBER }}.bobplugin
tag: ${{ env.VERSION }}
overwrite: true
body: ${{ steps.tag.outputs.message }}
body: ${{ github.event.inputs.message }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
*.bobplugin
*.log*
dist
node_modules
174 changes: 1 addition & 173 deletions LICENSE.md

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ChatGPT 向我们展示了 GPT 模型的伟大之处,所以我使用 ChatGPT

1. 安装 [Bob](https://bobtranslate.com/guide/#%E5%AE%89%E8%A3%85),一款 macOS 平台的翻译和 OCR 软件;[openai-translator.bobplugin](https://github.com/yetone/bob-plugin-openai-translator/releases/latest) >= **1.0.0** 以后默认开启流式输出,需要 Bob 版本 >= **1.8.0**

2. 下载此插件: [openai-polisher.bobplugin](https://github.com/yetone/bob-plugin-openai-polisher/releases)
2. 下载此插件: [openai-polisher.bobplugin](https://github.com/openai-translator/bob-plugin-openai-polisher/releases)

3. 安装此插件:
![安装步骤](https://user-images.githubusercontent.com/1206493/222712959-4a4b27e2-b129-408a-a8af-24a3a89df2dd.gif)
Expand All @@ -54,9 +54,3 @@ ChatGPT 向我们展示了 GPT 模型的伟大之处,所以我使用 ChatGPT

我这只是个小小的 Bob 插件,强大的是 Bob 本身,向它的开发者 [ripperhe](https://github.com/ripperhe) 致敬!

### 请作者喝一杯咖啡

<div align="center">
<img height="360" src="https://user-images.githubusercontent.com/1206493/220753437-90e4039c-d95f-4b6a-9a08-b3d6de13211f.png" />
<img height="360" src="https://user-images.githubusercontent.com/1206493/220756036-d9ac4512-0375-4a32-8c2e-8697021058a2.png" />
</div>
22 changes: 11 additions & 11 deletions appcast.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,77 +5,77 @@
"version": "2.0.0",
"desc": "Support for custom models, drop of support for `v1/completions`",
"sha256": "520985c6b10de2ae55651ddc94f5123fe9655ceb3962a276fd814ebad2facc2f",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v2.0.0/openai-polisher-2.0.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v2.0.0/openai-polisher-2.0.0.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "1.2.2",
"desc": "优化 HTTP Error 429 的错误信息",
"sha256": "25c10ebdd3133c37407740511f096a171d5219ad0d35c84d5bb00bf81bc205aa",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v1.2.2/openai-polisher-1.2.2.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v1.2.2/openai-polisher-1.2.2.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "1.2.1",
"desc": "Supports the latest GPT-4 and 3.5 Turbo models",
"sha256": "efd43255e1014e92405fb1521c4d61fea4d50f8fb6a00a292790a49b1102420a",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v1.2.1/openai-polisher-1.2.1.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v1.2.1/openai-polisher-1.2.1.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "1.2.0",
"desc": "Fix invalid custom system prompt",
"sha256": "26d21851dcf5af88e44768d524874932c099238f91ae4114ddf78f80caf090ad",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v1.2.0/openai-polisher-1.2.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v1.2.0/openai-polisher-1.2.0.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "1.1.0",
"desc": "Handle fragmented stream data from OpenAI API",
"sha256": "2cefc695cb1ab9f8b2b93440d105a6f0fcbadc0198a0d785cd1d9920bd3f3fbf",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v1.1.0/openai-polisher-1.1.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v1.1.0/openai-polisher-1.1.0.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "1.0.0",
"desc": "Supports streaming output, requires Bob version >= 1.8.0",
"sha256": "e540344dfd152d40779455301cc38750fdcf8db2e3d3e2f7ef89329d607be3c2",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v1.0.0/openai-polisher-1.0.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v1.0.0/openai-polisher-1.0.0.bobplugin",
"minBobVersion": "1.8.0"
},
{
"version": "0.2.0",
"desc": "fix(ci): add permissions",
"sha256": "1138da2e03ab8209722cc8bb4c7ecddb7aedc3acd77e7b3ca573400ad801e1a8",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v0.2.0/openai-polisher-0.2.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v0.2.0/openai-polisher-0.2.0.bobplugin",
"minBobVersion": "0.5.0"
},
{
"version": "0.1.0",
"desc": "Support custom prompt",
"sha256": "9dd8dd4d52f24df0bbf946e48f9e57cc417ef18be4bc37639fc3308aa5e7b98b",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v0.1.0/openai-polisher-0.1.0.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v0.1.0/openai-polisher-0.1.0.bobplugin",
"minBobVersion": "0.5.0"
},
{
"version": "0.0.3",
"desc": "Add an option to display the reason for polishing or not.",
"sha256": "31cdc98bcd9f5bf473c67f5bc2e60da6d3f984b0ac97fdfebce981eb8504981b",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v0.0.3/openai-polisher-0.0.3.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v0.0.3/openai-polisher-0.0.3.bobplugin",
"minBobVersion": "0.5.0"
},
{
"version": "0.0.2",
"desc": "Support the polishing of Japanese and other languages",
"sha256": "1945ca77329079b550571b329461ae50933f8da70aa9d1fbe176dba288548896",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v0.0.2/openai-polisher-0.0.2.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v0.0.2/openai-polisher-0.0.2.bobplugin",
"minBobVersion": "0.5.0"
},
{
"version": "0.0.1",
"desc": "release v0.0.1!",
"sha256": "0b3f7dc3f8bfcb08c090d0abd3809421172ac7e04a95c602f7bae2fa4d37160b",
"url": "https://github.com/yetone/bob-plugin-openai-polisher/releases/download/v0.0.1/openai-polisher-0.0.1.bobplugin",
"url": "https://github.com/openai-translator/bob-plugin-openai-polisher/releases/download/v0.0.1/openai-polisher-0.0.1.bobplugin",
"minBobVersion": "0.5.0"
}
]
Expand Down
7 changes: 0 additions & 7 deletions docs/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,3 @@ ChatGPT has shown us the greatness of the GPT model, so I used ChatGPT's API to
## Thanks

I'm just a small Bob plugin, and the powerful part is Bob itself. I pay tribute to its developer [ripperhe](https://github.com/ripperhe)!

### Buy me a coffee

<div align="center">
<img height="360" src="https://user-images.githubusercontent.com/1206493/220753437-90e4039c-d95f-4b6a-9a08-b3d6de13211f.png" />
<img height="360" src="https://user-images.githubusercontent.com/1206493/220756036-d9ac4512-0375-4a32-8c2e-8697021058a2.png" />
</div>
Loading

0 comments on commit 821089b

Please sign in to comment.