2828 const fs = require('fs');
2929 const https = require('https');
3030 const path = require('path');
31+ const { execSync } = require('child_process');
3132
3233 // Constants
3334 const MODRINTH_PROJECT_ID = process.env.MODRINTH_PROJECT_ID;
@@ -147,8 +148,8 @@ jobs:
147148 const isPrerelease = version.version_type === 'alpha' || version.version_type === 'beta';
148149 const releaseData = {
149150 tag_name: version.version_number,
150- name: version.name,
151- body: `${version.changelog}\n\nImported from Modrinth`,
151+ name: version.name || `Version ${version.version_number}` ,
152+ body: `${version.changelog || 'No changelog provided.' }\n\nImported from Modrinth (published: ${new Date(version.date_published).toLocaleDateString()}) `,
152153 draft: false,
153154 prerelease: isPrerelease
154155 };
@@ -196,9 +197,6 @@ jobs:
196197 });
197198 }
198199
199- // Add missing execSync function
200- const { execSync } = require('child_process');
201-
202200 // Upload asset to GitHub release
203201 function uploadAsset(uploadUrl, filePath, fileName) {
204202 return new Promise((resolve, reject) => {
@@ -257,17 +255,17 @@ jobs:
257255 const modrinthVersions = await getModrinthVersions();
258256 console.log(`Found ${modrinthVersions.length} versions on Modrinth.`);
259257
260- // Find versions that don't exist on GitHub
261- const newVersions = modrinthVersions.filter(version =>
262- !existingTags.includes(version.version_number)
263- );
258+ // Find versions that don't exist on GitHub and sort by date (oldest first)
259+ const newVersions = modrinthVersions
260+ .filter(version => !existingTags.includes(version.version_number) )
261+ .sort((a, b) => new Date(a.date_published) - new Date(b.date_published) );
264262
265263 console.log(`Found ${newVersions.length} new versions to sync to GitHub.`);
266264
267265 // Create GitHub releases for new versions
268266 for (const version of newVersions) {
269267 try {
270- console.log(`Creating GitHub release for version ${version.version_number}...`);
268+ console.log(`Creating GitHub release for version ${version.version_number} (published ${new Date(version.date_published).toISOString()}) ...`);
271269 await createGitHubRelease(version);
272270 console.log(`Successfully created GitHub release for version ${version.version_number}.`);
273271 } catch (err) {
@@ -286,17 +284,8 @@ jobs:
286284 syncModrinthToGitHub();
287285 EOF
288286
289- - name : Extract Modrinth Project ID
290- run : |
291- MODRINTH_ID=$(grep -oP '(?<=modrinth_id=).*' gradle.properties || echo "")
292- if [ -z "$MODRINTH_ID" ]; then
293- echo "Couldn't find Modrinth ID in gradle.properties. Please specify it manually in the workflow file."
294- MODRINTH_ID="9tQwxSFr"
295- fi
296- echo "MODRINTH_PROJECT_ID=$MODRINTH_ID" >> $GITHUB_ENV
297-
298287 - name : Run sync script
299288 env :
300289 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
301- MODRINTH_PROJECT_ID : ${{ env.MODRINTH_PROJECT_ID }}
290+ MODRINTH_PROJECT_ID : " 9tQwxSFr "
302291 run : node sync-modrinth.js
0 commit comments