From 38c2a5b6301c8c7d74968315d7efe6ecec010ec3 Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:41:13 +0800 Subject: [PATCH 1/6] Create release.yml --- .github/workflows/release.yml | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..19c89534 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ +name: Auto Release on Develop + +on: + push: + branches: + - new-feat + tags: + - 'v*' # 可选:监听以 v 开头的标签 + + # 添加人工触发功能 + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + steps: + # Step 1: 检出代码 + - name: Checkout code + uses: actions/checkout@v3 + + # Step 2: 获取最新的 Tag + - name: Fetch Latest Tag + run: | + git fetch --tags + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + + # Step 3: 打印最新的 Tag(调试用) + - name: Show Latest Tag + run: echo "Latest Tag: $LATEST_TAG" + + # Step 2: 设置 Node.js 环境 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 22.12.0 + + # Step 3: 安装 Yarn + - name: Install Yarn + run: npm install -g yarn + + # Step 4: 添加 .yarnrc.yml 文件 + - name: Add .yarnrc.yml + run: | + echo "nodeLinker: node-modules" > webapp/.yarnrc.yml + + # Step 5: 安装依赖并编译 WebApp + - name: Install and Build WebApp + run: | + cd webapp + yarn install + yarn build # 根据实际的编译命令修改 + + # Step 6: 准备发布文件 + - name: Prepare Release Files + run: | + mkdir -p release + cp script/setup.bat release/ # 复制 setup.bat + cp dist/win-unpacked/PDFMathTranslate.exe release/ + + # Step 7: 打包为 ZIP 文件 + - name: Create ZIP File + run: | + zip -r release.zip release + shell: bash + + # Step 8: 创建 Release 并上传 ZIP 文件 + - name: Create a Release + uses: actions/create-release@v1 + with: + tag_name: ${{ github.ref_name }} + release_name: Release ${{ github.ref_name }} + body: | + PDFMathTranslate win client + draft: false + prerelease: false + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: release.zip + asset_name: release.zip + asset_content_type: application/zip From 67b949146c733fb822362b0aba98fc55fd00d36d Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:47:03 +0800 Subject: [PATCH 2/6] Update release.yml --- .github/workflows/release.yml | 48 ++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 19c89534..5faa7afe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,20 @@ -name: Auto Release on Develop +name: Auto Release with Manual Trigger for Latest Tag on: + # 自动触发 push: branches: - - new-feat + - new-feat # 替换为你的分支名称 tags: - - 'v*' # 可选:监听以 v 开头的标签 - - # 添加人工触发功能 + - 'v*' + + # 手动触发 workflow_dispatch: - + jobs: release: runs-on: ubuntu-latest + steps: # Step 1: 检出代码 - name: Checkout code @@ -27,51 +29,51 @@ jobs: # Step 3: 打印最新的 Tag(调试用) - name: Show Latest Tag - run: echo "Latest Tag: $LATEST_TAG" - - # Step 2: 设置 Node.js 环境 + run: echo "Latest Tag: ${{ env.LATEST_TAG}}" + + # Step 4: 设置 Node.js 环境为 v22.12.0 - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: 22.12.0 - # Step 3: 安装 Yarn + # Step 5: 安装 Yarn - name: Install Yarn - run: npm install -g yarn + run: npm install -g yarn@4.6.0 - # Step 4: 添加 .yarnrc.yml 文件 + # Step 6: 添加 .yarnrc.yml 文件 - name: Add .yarnrc.yml run: | echo "nodeLinker: node-modules" > webapp/.yarnrc.yml - # Step 5: 安装依赖并编译 WebApp - - name: Install and Build WebApp + # Step 7: 安装依赖并编译 Electron 应用 + - name: Install Dependencies and Build run: | - cd webapp yarn install - yarn build # 根据实际的编译命令修改 + yarn build - # Step 6: 准备发布文件 + # Step 8: 准备发布文件(仅复制 exe 文件) - name: Prepare Release Files run: | mkdir -p release - cp script/setup.bat release/ # 复制 setup.bat cp dist/win-unpacked/PDFMathTranslate.exe release/ - # Step 7: 打包为 ZIP 文件 + # Step 9: 打包为 ZIP 文件 - name: Create ZIP File run: | zip -r release.zip release shell: bash - # Step 8: 创建 Release 并上传 ZIP 文件 + # Step 10: 创建 Release 并上传 ZIP 文件 - name: Create a Release uses: actions/create-release@v1 with: - tag_name: ${{ github.ref_name }} - release_name: Release ${{ github.ref_name }} + tag_name: ${{ env.LATEST_TAG }} + release_name: Release ${{ env.LATEST_TAG }} body: | - PDFMathTranslate win client + 手动触发的发布,基于最新的标签 ${{ env.LATEST_TAG }}。 + 包含以下文件: + - 可执行文件:PDFMathTranslate.exe draft: false prerelease: false From f873a2cf5c10fe3feb10f1c090b50ac64aba492d Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:49:04 +0800 Subject: [PATCH 3/6] Update release.yml --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5faa7afe..71ccbd73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,8 @@ jobs: # Step 3: 打印最新的 Tag(调试用) - name: Show Latest Tag - run: echo "Latest Tag: ${{ env.LATEST_TAG}}" + run: | + echo "Latest Tag: ${{ env.LATEST_TAG}}" # Step 4: 设置 Node.js 环境为 v22.12.0 - name: Setup Node.js From 161512e972d8c781bfdcbcb4b18a170fa0a42550 Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:52:10 +0800 Subject: [PATCH 4/6] Update release.yml --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 71ccbd73..aa4a2c9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,9 @@ jobs: # Step 5: 安装 Yarn - name: Install Yarn - run: npm install -g yarn@4.6.0 + run: | + corepack enable + corepack prepare yarn@4.x --activate # Step 6: 添加 .yarnrc.yml 文件 - name: Add .yarnrc.yml From 0c849a8b6b37b4f876316a30879e796d6f2bb74d Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:53:58 +0800 Subject: [PATCH 5/6] Update release.yml --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa4a2c9b..14dc44b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,6 +51,7 @@ jobs: # Step 7: 安装依赖并编译 Electron 应用 - name: Install Dependencies and Build + working-directory: webapp run: | yarn install yarn build From 39900c322ecbbdb7f0503ed09abb72ddbd9f9200 Mon Sep 17 00:00:00 2001 From: hellofinch <42131198+hellofinch@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:56:55 +0800 Subject: [PATCH 6/6] Update release.yml --- .github/workflows/release.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14dc44b5..082f8b76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Auto Release with Manual Trigger for Latest Tag +name: Release win client on: # 自动触发 @@ -60,7 +60,8 @@ jobs: - name: Prepare Release Files run: | mkdir -p release - cp dist/win-unpacked/PDFMathTranslate.exe release/ + cp script/setup.bat release/ + cp webapp/dist/win-unpacked/PDFMathTranslate.exe release/ # Step 9: 打包为 ZIP 文件 - name: Create ZIP File @@ -75,9 +76,7 @@ jobs: tag_name: ${{ env.LATEST_TAG }} release_name: Release ${{ env.LATEST_TAG }} body: | - 手动触发的发布,基于最新的标签 ${{ env.LATEST_TAG }}。 - 包含以下文件: - - 可执行文件:PDFMathTranslate.exe + release draft: false prerelease: false