Files
xget-now/.github/workflows/publish-extension.yml
T
xixu-me 367c9fee96 Rename extension from Xget for Chromium to Xget Now
Updated all references, documentation, metadata, and user-facing strings to use the new name 'Xget Now' instead of 'Xget for Chromium'. This includes changes in issue templates, workflow files, privacy and security policies, README, manifest, package.json, popup UI, and code comments/logs. Repository URLs and links have also been updated to reflect the new project name.
2025-08-10 12:06:54 +08:00

181 lines
6.8 KiB
YAML

name: 发布扩展到多个应用商店
on:
workflow_dispatch:
inputs:
version:
description: "版本号 (例如: 1.0.0)"
required: true
type: string
permissions:
contents: write
packages: write
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
- name: 验证 manifest.json
run: |
# 验证 manifest.json 是否为有效的 JSON
node -e "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8'))"
echo "✅ manifest.json 格式有效"
- name: 从输入设置版本
id: version
run: |
# 使用手动提供的版本
VERSION="${{ inputs.version }}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "手动设置版本: $VERSION"
- name: 更新 manifest 版本
run: |
# 更新 manifest.json 中的版本以匹配标签
node -e "
const fs = require('fs');
const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
manifest.version = '${{ steps.version.outputs.version }}';
fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2));
console.log('已更新 manifest.json 版本为:', manifest.version);
"
- name: 更新 package.json 版本
run: |
# 更新 package.json 中的版本以匹配标签
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
pkg.version = '${{ steps.version.outputs.version }}';
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));
console.log('已更新 package.json 版本为:', pkg.version);
"
- name: 提交并推送版本更新
run: |
# 配置 git 用户信息以进行提交
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# 添加更新的文件
git add manifest.json package.json
# 检查是否有需要提交的更改
if git diff --staged --quiet; then
echo "没有版本更改需要提交"
else
# 提交版本更新
git commit -m "chore: 更新版本到 ${{ steps.version.outputs.version }} [skip ci]"
# 为此版本创建并推送新标签
git tag "v${{ steps.version.outputs.version }}"
# 推送到主分支并包含标签
git push origin HEAD:main
git push origin "v${{ steps.version.outputs.version }}"
echo "✅ 版本更新已提交并推送到主分支,包含标签"
fi
- name: 创建扩展包
run: |
# 创建通用扩展 zip 包(适用于所有基于 Chromium 的浏览器)
zip -r extension.zip . \
-x "*.git*" \
-x "node_modules/*" \
-x ".github/*" \
-x "*.md" \
-x "LICENSE" \
-x "*.zip" \
-x "*.crx"
echo "📦 已创建扩展包"
ls -la *.zip
- name: 发布到 Chrome 应用商店
continue-on-error: true
id: chrome-publish
uses: mnao305/chrome-extension-upload@v5.0.0
with:
file-path: extension.zip
extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
client-id: ${{ secrets.CHROME_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
publish: true # 如果只想上传而不发布,设置为 false
- name: 发布到 Microsoft Edge 加载项
continue-on-error: true
id: edge-publish
uses: wdzeng/edge-addon@v2
with:
product-id: ${{ secrets.EDGE_PRODUCT_ID }}
zip-path: extension.zip
api-key: ${{ secrets.EDGE_API_KEY }}
client-id: ${{ secrets.EDGE_CLIENT_ID }}
notes-for-certification: "自动发布 v${{ steps.version.outputs.version }} - ${{ github.sha }}"
- name: 创建 GitHub 发布
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: Xget Now ${{ steps.version.outputs.version }}
files: |
extension.zip
generate_release_notes: true
body: |
此版本已自动发布到多个扩展商店。
## 📦 安装选项
- **Chrome 应用商店**: [从 Chrome 应用商店安装](https://chromewebstore.google.com/detail/ajiejgobfcifcikbahpijopolfjoodgf?hl=zh-CN)
- **Microsoft Edge 加载项**: [从 Microsoft Edge 加载项安装](https://microsoftedge.microsoft.com/addons/detail/jigpfhbegabdenhihpplcjhpfdcgnalc?hl=zh-CN&gl=CN)
- **手动安装**: 下载下面的 `extension.zip` 文件或查看 [安装指南](https://github.com/xixu-me/Xget-Now?tab=readme-ov-file#-%E5%AE%89%E8%A3%85) 获取详细说明
## 📁 可用文件
- `extension.zip` - 适用于所有基于 Chromium 的浏览器(Chrome、Edge、Brave、Opera 等)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 检查发布结果
run: |
echo "📊 发布结果摘要:"
echo "================================"
if [ "${{ steps.chrome-publish.outcome }}" = "success" ]; then
echo "✅ Chrome 应用商店: 发布成功"
elif [ "${{ steps.chrome-publish.outcome }}" = "failure" ]; then
echo "❌ Chrome 应用商店: 发布失败"
else
echo "⚠️ Chrome 应用商店: 已跳过(缺少密钥)"
fi
if [ "${{ steps.edge-publish.outcome }}" = "success" ]; then
echo "✅ Microsoft Edge 加载项: 发布成功"
elif [ "${{ steps.edge-publish.outcome }}" = "failure" ]; then
echo "❌ Microsoft Edge 加载项: 发布失败"
else
echo "⚠️ Microsoft Edge 加载项: 已跳过(缺少密钥)"
fi
echo "✅ GitHub 发布: 已创建扩展文件"
echo "================================"
- name: 通知成功
run: |
echo "🎉 成功发布 Xget Now ${{ steps.version.outputs.version }} 到多个商店!"
echo "🔗 Chrome 应用商店: https://chrome.google.com/webstore/detail/${{ secrets.CHROME_EXTENSION_ID }}"
echo "🔗 Microsoft Edge 加载项: 查看发布页面获取手动安装文件"
echo "📦 GitHub 发布: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version.outputs.version }}"