mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-08 20:46:44 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fb5f9e190 |
20
CHANGELOG.md
20
CHANGELOG.md
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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
|
## [3.2.5] - 2025-08-09
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-mirror",
|
"name": "gitea-mirror",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "3.2.5",
|
"version": "3.2.6",
|
||||||
"engines": {
|
"engines": {
|
||||||
"bun": ">=1.2.9"
|
"bun": ">=1.2.9"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -429,6 +429,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
//mirror releases
|
//mirror releases
|
||||||
|
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
||||||
if (config.giteaConfig?.mirrorReleases) {
|
if (config.giteaConfig?.mirrorReleases) {
|
||||||
await mirrorGitHubReleasesToGitea({
|
await mirrorGitHubReleasesToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -442,6 +443,8 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
const shouldMirrorIssues = config.giteaConfig?.mirrorIssues &&
|
const shouldMirrorIssues = config.giteaConfig?.mirrorIssues &&
|
||||||
!(repository.isStarred && config.githubConfig?.skipStarredIssues);
|
!(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) {
|
if (shouldMirrorIssues) {
|
||||||
await mirrorGitRepoIssuesToGitea({
|
await mirrorGitRepoIssuesToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -452,6 +455,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror pull requests if enabled
|
// Mirror pull requests if enabled
|
||||||
|
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
||||||
if (config.giteaConfig?.mirrorPullRequests) {
|
if (config.giteaConfig?.mirrorPullRequests) {
|
||||||
await mirrorGitRepoPullRequestsToGitea({
|
await mirrorGitRepoPullRequestsToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -462,6 +466,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror labels if enabled (and not already done via issues)
|
// 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) {
|
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
||||||
await mirrorGitRepoLabelsToGitea({
|
await mirrorGitRepoLabelsToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -472,6 +477,7 @@ export const mirrorGithubRepoToGitea = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror milestones if enabled
|
// Mirror milestones if enabled
|
||||||
|
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
||||||
if (config.giteaConfig?.mirrorMilestones) {
|
if (config.giteaConfig?.mirrorMilestones) {
|
||||||
await mirrorGitRepoMilestonesToGitea({
|
await mirrorGitRepoMilestonesToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -683,6 +689,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
);
|
);
|
||||||
|
|
||||||
//mirror releases
|
//mirror releases
|
||||||
|
console.log(`[Metadata] Release mirroring check: mirrorReleases=${config.giteaConfig?.mirrorReleases}`);
|
||||||
if (config.giteaConfig?.mirrorReleases) {
|
if (config.giteaConfig?.mirrorReleases) {
|
||||||
await mirrorGitHubReleasesToGitea({
|
await mirrorGitHubReleasesToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -706,6 +713,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror pull requests if enabled
|
// Mirror pull requests if enabled
|
||||||
|
console.log(`[Metadata] Pull request mirroring check: mirrorPullRequests=${config.giteaConfig?.mirrorPullRequests}`);
|
||||||
if (config.giteaConfig?.mirrorPullRequests) {
|
if (config.giteaConfig?.mirrorPullRequests) {
|
||||||
await mirrorGitRepoPullRequestsToGitea({
|
await mirrorGitRepoPullRequestsToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -716,6 +724,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror labels if enabled (and not already done via issues)
|
// 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) {
|
if (config.giteaConfig?.mirrorLabels && !shouldMirrorIssues) {
|
||||||
await mirrorGitRepoLabelsToGitea({
|
await mirrorGitRepoLabelsToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -726,6 +735,7 @@ export async function mirrorGitHubRepoToGiteaOrg({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mirror milestones if enabled
|
// Mirror milestones if enabled
|
||||||
|
console.log(`[Metadata] Milestone mirroring check: mirrorMilestones=${config.giteaConfig?.mirrorMilestones}`);
|
||||||
if (config.giteaConfig?.mirrorMilestones) {
|
if (config.giteaConfig?.mirrorMilestones) {
|
||||||
await mirrorGitRepoMilestonesToGitea({
|
await mirrorGitRepoMilestonesToGitea({
|
||||||
config,
|
config,
|
||||||
@@ -1350,7 +1360,8 @@ export async function mirrorGitHubReleasesToGitea({
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await httpPost(
|
// Create the release
|
||||||
|
const createReleaseResponse = await httpPost(
|
||||||
`${config.giteaConfig.url}/api/v1/repos/${repoOwner}/${repository.name}/releases`,
|
`${config.giteaConfig.url}/api/v1/repos/${repoOwner}/${repository.name}/releases`,
|
||||||
{
|
{
|
||||||
tag_name: release.tag_name,
|
tag_name: release.tag_name,
|
||||||
@@ -1364,6 +1375,56 @@ export async function mirrorGitHubReleasesToGitea({
|
|||||||
Authorization: `token ${decryptedConfig.giteaConfig.token}`,
|
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++;
|
mirroredCount++;
|
||||||
console.log(`[Releases] Successfully mirrored release: ${release.tag_name}`);
|
console.log(`[Releases] Successfully mirrored release: ${release.tag_name}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user