Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,33 @@ jobs:
run: |
Compress-Archive -Path application/dist/win-unpacked/* -Destination application/dist/OpenGameInstaller-Portable.zip

- name: Generate Windows blockmaps
if: matrix.os == 'windows-latest' && steps.check_changes.outputs.has_application_changes == 'true'
run: |
bun run .github/workflows/js/generate-blockmaps.mjs application/dist/OpenGameInstaller-Portable.zip updater/dist/OpenGameInstaller-Setup.exe

- name: Generate Linux blockmaps
if: matrix.os == 'ubuntu-latest' && steps.check_changes.outputs.has_application_changes == 'true'
run: |
bun run .github/workflows/js/generate-blockmaps.mjs updater/dist/OpenGameInstaller-Setup.AppImage application/dist/OpenGameInstaller-linux-pt.AppImage

- name: What's in the folders? (Windows)
if: steps.check_changes.outputs.has_application_changes == 'true'
shell: bash
run: |
ls -la application/dist/
ls -la updater/dist/

- name: Upload Windows Assets as Artifacts
if: matrix.os == 'windows-latest' && steps.check_changes.outputs.has_application_changes == 'true'
uses: actions/upload-artifact@v4
with:
name: windows-assets
path: |
application/dist/OpenGameInstaller-Portable.zip
application/dist/OpenGameInstaller-Portable.zip.blockmap
updater/dist/OpenGameInstaller-Setup.exe
updater/dist/OpenGameInstaller-Setup.exe.blockmap

- name: Upload Linux Assets as Artifacts
if: matrix.os == 'ubuntu-latest' && steps.check_changes.outputs.has_application_changes == 'true'
Expand All @@ -85,7 +104,9 @@ jobs:
name: linux-assets
path: |
updater/dist/OpenGameInstaller-Setup.AppImage
updater/dist/OpenGameInstaller-Setup.AppImage.blockmap
application/dist/OpenGameInstaller-linux-pt.AppImage
application/dist/OpenGameInstaller-linux-pt.AppImage.blockmap
release:
permissions:
contents: write
Expand Down Expand Up @@ -169,6 +190,7 @@ jobs:
run: |
mkdir -p assets-flat
find assets -type f -name "*.zip" -exec cp {} assets-flat/ \;
find assets -type f -name "*.blockmap" -exec cp {} assets-flat/ \;
find assets -type f -name "*.exe" -exec cp {} assets-flat/ \;
find assets -type f -name "*.AppImage" -exec cp {} assets-flat/ \;
ls -la assets-flat/
Expand Down Expand Up @@ -197,6 +219,10 @@ jobs:
prerelease: true
files: |
assets-flat/OpenGameInstaller-Portable.zip
assets-flat/OpenGameInstaller-Portable.zip.blockmap
assets-flat/OpenGameInstaller-Setup.exe
assets-flat/OpenGameInstaller-Setup.exe.blockmap
assets-flat/OpenGameInstaller-Setup.AppImage
assets-flat/OpenGameInstaller-Setup.AppImage.blockmap
assets-flat/OpenGameInstaller-linux-pt.AppImage
assets-flat/OpenGameInstaller-linux-pt.AppImage.blockmap
6 changes: 5 additions & 1 deletion .github/workflows/js/check-application-changes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ function checkApplicationChanges() {
file.startsWith('application/')
);

if (hasChanges) {
const hasWorkflowChanges = changedFiles.some((file) =>
file.startsWith('.github/workflows/')
);

if (hasChanges || hasWorkflowChanges) {
setOutput('has_application_changes', 'true');
console.log('Found changes in application directory');
} else {
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/js/generate-blockmaps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { existsSync } from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { spawn } from 'node:child_process';

const require = createRequire(import.meta.url);

function resolveAppBuilderPath() {
const searchPaths = [
process.cwd(),
path.join(process.cwd(), 'node_modules'),
path.join(process.cwd(), 'application'),
path.join(process.cwd(), 'application', 'node_modules'),
path.join(process.cwd(), 'updater'),
path.join(process.cwd(), 'updater', 'node_modules'),
];

for (const searchPath of searchPaths) {
try {
const modulePath = require.resolve('app-builder-bin', {
paths: [searchPath],
});
return require(modulePath).appBuilderPath;
} catch {
// Try the next candidate path.
}
}

throw new Error(
'Unable to resolve app-builder-bin. Ensure dependencies are installed before generating blockmaps.'
);
}

const appBuilderPath = resolveAppBuilderPath();

function runAppBuilder(args) {
return new Promise((resolve, reject) => {
const child = spawn(appBuilderPath, args, { stdio: 'inherit' });
child.on('exit', (code) => {
if (code === 0) {
resolve();
return;
}
reject(new Error(`app-builder exited with code ${code}`));
});
child.on('error', reject);
});
}

async function main() {
const args = process.argv.slice(2);
if (args.length === 0) {
console.error('Usage: bun run .github/workflows/js/generate-blockmaps.mjs <file> [file...]');
process.exit(1);
}

for (const artifact of args) {
const artifactPath = path.resolve(artifact);
const blockmapPath = `${artifactPath}.blockmap`;

if (!existsSync(artifactPath)) {
console.error(`Artifact not found: ${artifactPath}`);
process.exit(1);
}

console.log(`Generating blockmap: ${blockmapPath}`);
await runAppBuilder(['blockmap', '--input', artifactPath, '--output', blockmapPath]);
}
}

await main();
Loading