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 1e1fb39 commit 800a1da
Show file tree
Hide file tree
Showing 25 changed files with 1,749 additions and 1,318 deletions.
22 changes: 11 additions & 11 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ body:
value: |
**非常感谢您的反馈!Thank you very much for your feedback!**
有关翻译错误的内容请附在此 [issue](https://github.com/yetone/bob-plugin-openai-translator/issues/30) 中。
有关翻译错误的内容请附在此 [issue](https://github.com/openai-translator/bob-plugin-openai-translator/issues/30) 中。
Please post any translation-related errors in this [issue](https://github.com/yetone/bob-plugin-openai-translator/issues/30).
Please post any translation-related errors in this [issue](https://github.com/openai-translator/bob-plugin-openai-translator/issues/30).
- type: checkboxes
attributes:
Expand All @@ -28,10 +28,10 @@ body:
attributes:
label: Please read README
description: |
辛苦提 Bug 前,请确定是按照 README 中的 [使用方法](https://github.com/yetone/bob-plugin-openai-translator/tree/main#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) 部分安装的。
Before reporting bugs, please carefully read the [usage instructions]((https://github.com/yetone/bob-plugin-openai-translator/tree/main#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) section in README
辛苦提 Bug 前,请确定是按照 README 中的 [使用方法](https://github.com/openai-translator/bob-plugin-openai-translator/tree/main#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) 部分安装的。
Before reporting bugs, please carefully read the [usage instructions]((https://github.com/openai-translator/bob-plugin-openai-translator/tree/main#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) section in README
options:
- label: I have read the usage instructions section in README in detail.
required: true
Expand All @@ -40,7 +40,7 @@ body:
label: Please check your network and OpenAI API quota
description: |
如果您遇到的报错是 Failed to fetch 或者 API quota exceed,则说明是网络问题或者 OpenAI API 使用量超过阈值,这些问题都与 OpenAI Translator Bob Plugin 无关,请自行解决。
If you encounter error messages such as 'Failed to fetch' or 'API quota exceed', it means there is a network issue or the usage limit of OpenAI API has been exceeded. These issues are not related to OpenAI Translator Bob Plugin, please resolve them on your own.
options:
Expand All @@ -51,7 +51,7 @@ body:
label: OpenAI Translator Bob Plugin version
description: |
请提供您正在使用的 OpenAI Translator Bob Plugin 的版本。
Please provide the version of OpenAI Translator Bob Plugin you are using. For example, `v0.1.0`.
validations:
required: true
Expand All @@ -60,7 +60,7 @@ body:
label: 系统版本 | System version
description: |
请提供您正在使用的系统版本。
Please provide the version of the System you are using. For example, `macOS 11.2.3`.
validations:
required: true
Expand All @@ -78,7 +78,7 @@ body:
label: 复现步骤 | Reproduce step
description: |
请提供完整且简明的复现步骤,以方便及时定位并解决问题。
Please provide complete and concise reproduction steps to facilitate timely identification and resolution of the issue.
validations:
required: true
Expand All @@ -100,7 +100,7 @@ body:
label: 你是否愿意提交一份 PR 来修改这个错误?Are you willing to submit a PR?
description: |
我们期待开发人员和用户的帮助,以解决在 OpenAI Translator Bob Plugin 中发现的任何问题。 如果您愿意通过提交 PR 来解决此问题,请勾选。
We eagerly anticipate developers' and users' support and collaboration in resolving any issues found in OpenAI Translator Bob Plugin. If you are willing to offer a solution by submitting a PR to fix this matter, kindly mark the checkbox provided.
options:
- label: 我愿意提供 PR! I'm willing to submit a PR!
Expand Down
87 changes: 54 additions & 33 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,56 +19,72 @@ jobs:
packages: write

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

- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm

- name: Get version
id: get_version
uses: battila7/get-version-action@v2
- run: pnpm install
- run: pnpm run build

- name: Get tag message
id: tag
- name: Set up Git
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
git config --global user.name 'GitHub Actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Change version
- name: Determine tag version
id: determine_version
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
VERSION="${{ github.event.inputs.version }}"
if [[ $VERSION != v* ]]; then
VERSION="v$VERSION"
fi
echo "version=$VERSION" >> $GITHUB_ENV
- name: Package plugin
run: mkdir release && zip -j -r release/openai-translator-${{ steps.get_version.outputs.version-without-v }}.bobplugin ./src/*

- run: git checkout -- src/
run: |
VERSION="${{ env.version }}"
VERSION_NUMBER="${VERSION#v}"
mkdir release && zip -j -r release/openai-translator-${VERSION_NUMBER}.bobplugin ./dist/*
- name: Update appcast.json
- name: Update appcast.json and info.json
env:
VERSION: ${{ steps.get_version.outputs.version-without-v }}
MESSAGE: ${{ steps.tag.outputs.message }}
VERSION: ${{ env.version }}
MESSAGE: ${{ github.event.inputs.message }}
run: |
python3 scripts/update_release.py "$VERSION" "$MESSAGE"
VERSION_NUMBER="${VERSION#v}"
python3 scripts/update_release.py "$VERSION_NUMBER" "$MESSAGE"
- name: Commit files
run: |
git config --global user.name 'Bryan Lee'
git config --global user.email '[email protected]'
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.PAT }}
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true

- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
release_name: ${{ steps.get_version.outputs.version }}
release_name: ${{ github.ref_name }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: release/openai-translator-${{ steps.get_version.outputs.version-without-v }}.bobplugin
asset_name: openai-translator-${{ steps.get_version.outputs.version-without-v }}.bobplugin
tag: ${{ github.ref }}
file: release/openai-translator-${VERSION_NUMBER}.bobplugin
asset_name: openai-translator-${VERSION_NUMBER}.bobplugin
tag: ${{ github.ref_name }}
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
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.16.0
Loading

0 comments on commit 800a1da

Please sign in to comment.