fix(ci): remove redundant icon generation and enhance Gitea release script
Build and Release / Build & Release DEB Package (push) Successful in 3m8s
Build and Release / Build & Release DEB Package (push) Successful in 3m8s
This commit is contained in:
@@ -34,10 +34,6 @@ jobs:
|
|||||||
npm ci || npm install
|
npm ci || npm install
|
||||||
npm run rebuild
|
npm run rebuild
|
||||||
|
|
||||||
- name: Generate App Icons
|
|
||||||
run: |
|
|
||||||
python3 scripts/generate-icon.py
|
|
||||||
|
|
||||||
- name: Package Linux DEB
|
- name: Package Linux DEB
|
||||||
run: |
|
run: |
|
||||||
npm run package:deb
|
npm run package:deb
|
||||||
|
|||||||
@@ -34,10 +34,6 @@ jobs:
|
|||||||
npm ci || npm install
|
npm ci || npm install
|
||||||
npm run rebuild
|
npm run rebuild
|
||||||
|
|
||||||
- name: Generate App Icons
|
|
||||||
run: |
|
|
||||||
python3 scripts/generate-icon.py
|
|
||||||
|
|
||||||
- name: Package Linux DEB
|
- name: Package Linux DEB
|
||||||
run: |
|
run: |
|
||||||
npm run package:deb
|
npm run package:deb
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ async function main() {
|
|||||||
const serverUrl = process.env.GITHUB_SERVER_URL || process.env.GITEA_SERVER_URL || 'https://git.zzzjy.cloud';
|
const serverUrl = process.env.GITHUB_SERVER_URL || process.env.GITEA_SERVER_URL || 'https://git.zzzjy.cloud';
|
||||||
const token = process.env.GITHUB_TOKEN || process.env.GITEA_TOKEN;
|
const token = process.env.GITHUB_TOKEN || process.env.GITEA_TOKEN;
|
||||||
const repo = process.env.GITHUB_REPOSITORY || 'zzzjy/hatty';
|
const repo = process.env.GITHUB_REPOSITORY || 'zzzjy/hatty';
|
||||||
const tag = process.env.GITHUB_REF_NAME || 'v1.0.0';
|
let tag = process.env.GITHUB_REF_NAME || 'v1.0.0';
|
||||||
|
|
||||||
|
// 规范化 tag 名称(移除可能的 refs/tags/ 前缀)
|
||||||
|
tag = tag.replace(/^refs\/tags\//, '');
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
console.error('Error: GITHUB_TOKEN or GITEA_TOKEN is required.');
|
console.error('Error: GITHUB_TOKEN or GITEA_TOKEN is required.');
|
||||||
@@ -19,7 +22,7 @@ async function main() {
|
|||||||
|
|
||||||
// 1. 检查或创建 Release
|
// 1. 检查或创建 Release
|
||||||
let releaseId = null;
|
let releaseId = null;
|
||||||
const tagCheckRes = await fetch(`${apiBase}/releases/tags/${tag}`, {
|
const tagCheckRes = await fetch(`${apiBase}/releases/tags/${encodeURIComponent(tag)}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `token ${token}`,
|
Authorization: `token ${token}`,
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
@@ -72,6 +75,30 @@ async function main() {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查已存在的附件,若同名则先删除以支持重试
|
||||||
|
try {
|
||||||
|
const assetsRes = await fetch(`${apiBase}/releases/${releaseId}/assets`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `token ${token}`,
|
||||||
|
Accept: 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (assetsRes.ok) {
|
||||||
|
const existingAssets = await assetsRes.json();
|
||||||
|
for (const asset of existingAssets) {
|
||||||
|
if (files.includes(asset.name)) {
|
||||||
|
console.log(`Deleting existing asset ${asset.name} (id: ${asset.id}) to replace...`);
|
||||||
|
await fetch(`${apiBase}/releases/${releaseId}/assets/${asset.id}`, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: { Authorization: `token ${token}` },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Checking existing assets notice:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
// 3. 上传安装包到 Release 附件
|
// 3. 上传安装包到 Release 附件
|
||||||
for (const fileName of files) {
|
for (const fileName of files) {
|
||||||
const filePath = path.join(distDir, fileName);
|
const filePath = path.join(distDir, fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user