Release v3.2.6 - Add release asset mirroring and metadata debugging

### Fixed
- Added missing release asset mirroring functionality (APK, ZIP, Binary files)
- Release assets (attachments) are now properly downloaded from GitHub and uploaded to Gitea
- Fixed missing metadata component configuration checks

### Added
- Full support for mirroring release assets/attachments
- Debug logging for metadata component configuration to help troubleshoot mirroring issues
- Download and upload progress logging for release assets

### Improved
- Enhanced release mirroring to include all associated binary files and attachments
- Better visibility into which metadata components are enabled/disabled
- More detailed logging during the release asset transfer process

Fixes #68

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Arunavo Ray
2025-08-09 19:23:23 +05:30
parent dacec93f55
commit 12aff869a3
3 changed files with 83 additions and 2 deletions

View File

@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [3.2.6] - 2025-08-09
### Fixed
- Added missing release asset mirroring functionality (APK, ZIP, Binary files)
- Release assets (attachments) are now properly downloaded from GitHub and uploaded to Gitea
- Fixed missing metadata component configuration checks
### Added
- Full support for mirroring release assets/attachments
- Debug logging for metadata component configuration to help troubleshoot mirroring issues
- Download and upload progress logging for release assets
### Improved
- Enhanced release mirroring to include all associated binary files and attachments
- Better visibility into which metadata components are enabled/disabled
- More detailed logging during the release asset transfer process
### Notes
This patch adds the missing functionality to mirror release assets (APK, ZIP, Binary files, etc.) that was reported in Issue #68. Previously only release metadata was being mirrored, now all attachments are properly transferred to Gitea.
## [3.2.5] - 2025-08-09
### Fixed

View File

@@ -1,7 +1,7 @@
{
"name": "gitea-mirror",
"type": "module",
"version": "3.2.5",
"version": "3.2.6",
"engines": {
"bun": ">=1.2.9"
},

View File

@@ -429,6 +429,7 @@ export const mirrorGithubRepoToGitea = async ({
);
//mirror releases
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
if (config.giteaConfig?.mirrorReleases) {
await mirrorGitHubReleasesToGitea({
config,
@@ -442,6 +443,8 @@ export const mirrorGithubRepoToGitea = async ({
const shouldMirrorIssues = config.giteaConfig?.mirrorIssues &&
!(repository.isStarred && config.githubConfig?.skipStarredIssues);
console.log(`[Metadata] Issue mirroring check: mirrorIssues=${config.giteaConfig?.mirrorIssues}, isStarred=${repository.isStarred}, skipStarredIssues=${config.githubConfig?.skipStarredIssues}, shouldMirrorIssues=${shouldMirrorIssues}`);
if (shouldMirrorIssues) {
await mirrorGitRepoIssuesToGitea({
config,
@@ -452,6 +455,7 @@ export const mirrorGithubRepoToGitea = async ({
}
// Mirror pull requests if enabled
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
if (config.giteaConfig?.mirrorPullRequests) {
await mirrorGitRepoPullRequestsToGitea({
config,
@@ -462,6 +466,7 @@ export const mirrorGithubRepoToGitea = async ({
}
// Mirror labels if enabled (and not already done via issues)
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
await mirrorGitRepoLabelsToGitea({
config,
@@ -472,6 +477,7 @@ export const mirrorGithubRepoToGitea = async ({
}
// Mirror milestones if enabled
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
if (config.giteaConfig?.mirrorMilestones) {
await mirrorGitRepoMilestonesToGitea({
config,
@@ -683,6 +689,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
);
//mirror releases
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
if (config.giteaConfig?.mirrorReleases) {
await mirrorGitHubReleasesToGitea({
config,
@@ -706,6 +713,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
}
// Mirror pull requests if enabled
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
if (config.giteaConfig?.mirrorPullRequests) {
await mirrorGitRepoPullRequestsToGitea({
config,
@@ -716,6 +724,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
}
// Mirror labels if enabled (and not already done via issues)
console.log(`[Metadata] Label mirroring check: mirrorLabels=${config.giteaConfig?.mirrorLabels}, shouldMirrorIssues=${shouldMirrorIssues}`);
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
await mirrorGitRepoLabelsToGitea({
config,
@@ -726,6 +735,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
}
// Mirror milestones if enabled
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
if (config.giteaConfig?.mirrorMilestones) {
await mirrorGitRepoMilestonesToGitea({
config,
@@ -1350,7 +1360,8 @@ export async function mirrorGitHubReleasesToGitea({
continue;
}
await httpPost(
// Create the release
const createReleaseResponse = await httpPost(
`${config.giteaConfig.url}/api/v1/repos/${repoOwner}/${repository.name}/releases`,
{
tag_name: release.tag_name,
@@ -1364,6 +1375,56 @@ export async function mirrorGitHubReleasesToGitea({
Authorization: `token ${decryptedConfig.giteaConfig.token}`,
}
);
// Mirror release assets if they exist
if (release.assets && release.assets.length > 0) {
console.log(`[Releases] Mirroring ${release.assets.length} assets for release ${release.tag_name}`);
for (const asset of release.assets) {
try {
// Download the asset from GitHub
console.log(`[Releases] Downloading asset: ${asset.name} (${asset.size} bytes)`);
const assetResponse = await fetch(asset.browser_download_url, {
headers: {
'Accept': 'application/octet-stream',
'Authorization': `token ${decryptedConfig.githubConfig.token}`,
},
});
if (!assetResponse.ok) {
console.error(`[Releases] Failed to download asset ${asset.name}: ${assetResponse.statusText}`);
continue;
}
const assetData = await assetResponse.arrayBuffer();
// Upload the asset to Gitea release
const formData = new FormData();
formData.append('attachment', new Blob([assetData]), asset.name);
const uploadResponse = await fetch(
`${config.giteaConfig.url}/api/v1/repos/${repoOwner}/${repository.name}/releases/${createReleaseResponse.data.id}/assets?name=${encodeURIComponent(asset.name)}`,
{
method: 'POST',
headers: {
'Authorization': `token ${decryptedConfig.giteaConfig.token}`,
},
body: formData,
}
);
if (uploadResponse.ok) {
console.log(`[Releases] Successfully uploaded asset: ${asset.name}`);
} else {
const errorText = await uploadResponse.text();
console.error(`[Releases] Failed to upload asset ${asset.name}: ${errorText}`);
}
} catch (assetError) {
console.error(`[Releases] Error processing asset ${asset.name}: ${assetError instanceof Error ? assetError.message : String(assetError)}`);
}
}
}
mirroredCount++;
console.log(`[Releases] Successfully mirrored release: ${release.tag_name}`);
} catch (error) {