feat: 更新 GitHub 令牌配置以支持私有仓库的自动更新,优化发布工作流
This commit is contained in:
1 parent
56acfb275b
commit
7534d31b2f
4 files changed
+27
-18
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# GitHub Personal Access Token for private repository access
|
# GitHub Personal Access Token for private repository access
|
||||||
# Required for auto-updates from private repositories
|
# Required for auto-updates from private repositories
|
||||||
GH_TOKEN=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
|
GH_TOKEN=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
|
||||||
|
|
||||||
# For private repositories, you might also need:
|
# For private repositories, you might also need:
|
||||||
# GITHUB_TOKEN= # Alternative token name that some tools might use
|
# GITHUB_TOKEN= # Alternative token name that some tools might use
|
||||||
@@ -81,22 +81,22 @@ jobs:
|
|||||||
git push origin v${{ env.VERSION }}
|
git push origin v${{ env.VERSION }}
|
||||||
|
|
||||||
- name: Build for all platforms
|
- name: Build for all platforms
|
||||||
run: pnpm build:win
|
run: pnpm release
|
||||||
env:
|
env:
|
||||||
# 在 macOS 上禁用代码签名
|
# 在 macOS 上禁用代码签名
|
||||||
CSC_IDENTITY_AUTO_DISCOVERY: false
|
CSC_IDENTITY_AUTO_DISCOVERY: false
|
||||||
# GitHub token 用于发布
|
# GitHub token 用于发布
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Create GitHub Release
|
# - name: Create GitHub Release
|
||||||
uses: softprops/action-gh-release@v2
|
# uses: softprops/action-gh-release@v2
|
||||||
with:
|
# with:
|
||||||
tag_name: v${{ env.VERSION }}
|
# tag_name: v${{ env.VERSION }}
|
||||||
name: Release v${{ env.VERSION }}
|
# name: Release v${{ env.VERSION }}
|
||||||
body_path: CHANGELOG.md
|
# body_path: CHANGELOG.md
|
||||||
draft: false
|
# draft: false
|
||||||
prerelease: false
|
# prerelease: false
|
||||||
files: |
|
# files: |
|
||||||
release/${{ env.VERSION }}/*
|
# release/${{ env.VERSION }}/*
|
||||||
env:
|
# env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
+5
-4
@@ -36,10 +36,11 @@
|
|||||||
"lint:fix": "eslint . --ext .js,.ts,.vue --fix .",
|
"lint:fix": "eslint . --ext .js,.ts,.vue --fix .",
|
||||||
"test": "npm run build:pre && playwright test",
|
"test": "npm run build:pre && playwright test",
|
||||||
"test:linux": "npm run build:pre && xvfb-run --auto-servernum --server-args='-screen 0, 1280x960x24' -- playwright test",
|
"test:linux": "npm run build:pre && xvfb-run --auto-servernum --server-args='-screen 0, 1280x960x24' -- playwright test",
|
||||||
"release": "standard-version",
|
"pub": "npm run build:pre && electron-builder --config=buildAssets/builder/config.js --windows --publish=always",
|
||||||
"release:major": "standard-version --release-as major",
|
"release": "standard-version && npm run pub",
|
||||||
"release:minor": "standard-version --release-as minor",
|
"release:major": "standard-version --release-as major && npm run pub",
|
||||||
"release:patch": "standard-version --release-as patch"
|
"release:minor": "standard-version --release-as minor && npm run pub",
|
||||||
|
"release:patch": "standard-version --release-as patch && npm run pub"
|
||||||
},
|
},
|
||||||
"standard-version": {
|
"standard-version": {
|
||||||
"types": [
|
"types": [
|
||||||
|
|||||||
@@ -17,6 +17,14 @@ export class AutoUpdater {
|
|||||||
autoUpdater.allowPrerelease = false
|
autoUpdater.allowPrerelease = false
|
||||||
autoUpdater.channel = 'latest'
|
autoUpdater.channel = 'latest'
|
||||||
|
|
||||||
|
// 如果是私有仓库,设置认证信息
|
||||||
|
if (process.env.GH_TOKEN || process.env.GITHUB_TOKEN) {
|
||||||
|
// 使用环境变量中的令牌
|
||||||
|
autoUpdater.requestHeaders = {
|
||||||
|
'Authorization': `token ${process.env.GH_TOKEN || process.env.GITHUB_TOKEN}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 设置事件监听器
|
// 设置事件监听器
|
||||||
this.setupEventListeners()
|
this.setupEventListeners()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user