Create multiple workflows for different actions

This commit is contained in:
2026-09-10 14:08:13 +02:00
parent 7a59237d45
commit 1d7389f3e8
24 changed files with 2508 additions and 839 deletions
+30
View File
@@ -0,0 +1,30 @@
name: 'Scripting Compiler Action'
description: 'Runs the custom ScriptCompiler as a GitHub Action.'
inputs:
source-root:
description: 'The root directory of the source files to compile.'
required: true
default: 'src'
output-file:
description: 'The path to the output file for the compiled script.'
required: true
default: 'output/compiled.lua'
runs:
using: 'composite'
steps:
- name: Build action
run: |
npm ci
npm run build
shell: bash
working-directory: ${{ github.action_path }}
- name: Run compiler
run: node ${{ github.action_path }}/dist/index.js
shell: bash
working-directory: ${{ github.workspace }}
env:
INPUT_SOURCE-ROOT: ${{ inputs.source-root }}
INPUT_OUTPUT-FILE: ${{ inputs.output-file }}
+32
View File
@@ -0,0 +1,32 @@
const esbuild = require("esbuild");
const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');
async function main() {
const ctx = await esbuild.context({
entryPoints: [
'src/index.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/index.js',
external: ['@actions/core'],
logLevel: 'silent',
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});
+20
View File
@@ -0,0 +1,20 @@
{
"name": "gh-scripting-compiler",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "node esbuild.js",
"watch": "node esbuild.js --watch",
"package": "node esbuild.js --production"
},
"dependencies": {
"@actions/core": "3.0.1"
},
"devDependencies": {
"ts-node": "^10.9.2",
"typescript": "7.0.2",
"esbuild": "0.28.2"
}
}
+60
View File
@@ -0,0 +1,60 @@
import * as core from '@actions/core';
import { ScriptCompiler, ScriptCompilerOptions, CompilationError, ICompilationLogger } from 'dcs-script-compiler';
class Logger implements ICompilationLogger {
info(message: string): void {
core.info(message);
}
error(message: string): void {
core.error(message);
}
writeLine(message: string): void {
core.info(message);
}
}
async function run() {
try {
const sourceRoot = core.getInput('source-root');
if (!sourceRoot) {
core.setFailed('Source root is required.');
return;
}
const outputFile = core.getInput('output-file');
if (!outputFile) {
core.setFailed('Output file path is required.');
return;
}
const logger = new Logger();
const outputFileName = outputFile.split('/').pop() || 'compiled.lua';
const outputFolderPath = outputFile.substring(0, outputFile.lastIndexOf('/'));
const options: ScriptCompilerOptions = {
sourcePath: sourceRoot,
outputPath: outputFolderPath,
outputFileName: outputFileName,
minify: false,
onError: (error: CompilationError) => {
logger.error(`Error in file ${error.filePath} at line ${error.line}: ${error.message}`);
core.setFailed(`Compilation error in file ${error.filePath} at line ${error.line}: ${error.message}`);
}
}
const compiler = new ScriptCompiler(options, logger);
await compiler.compile(false);
core.info('Compilation completed successfully.');
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
} else {
core.setFailed('An unknown error occurred.');
}
}
}
run();
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
"paths": {
"dcs-script-compiler":[
"../compiler/src/ScriptCompiler.ts"
]
}
},
"include": [
"src/**/*.ts"
]
}
@@ -0,0 +1,30 @@
name: 'Install Lua Addon'
description: 'Installs DCS Lua addons and type definitions for scripting.'
inputs:
destination-path:
description: 'The destination path in the repository where lua-addons should be installed.'
required: true
default: 'lua-addons'
runs:
using: 'composite'
steps:
- name: Copy lua-addons
run: |
cp -r ../dutchies-dcs-scripting-tools/lua-addons ./lua-addons
shell: bash
working-directory: ${{ github.action_path }}
- name: Build action
run: |
npm ci
npm run build
shell: bash
working-directory: ${{ github.action_path }}
- name: Install lua-addons
run: node ${{ github.action_path }}/dist/index.js
shell: bash
working-directory: ${{ github.workspace }}
env:
INPUT_DESTINATION-PATH: ${{ inputs.destination-path }}
@@ -0,0 +1,32 @@
const esbuild = require("esbuild");
const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');
async function main() {
const ctx = await esbuild.context({
entryPoints: [
'src/index.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/index.js',
external: ['@actions/core'],
logLevel: 'silent',
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,18 @@
{
"name": "gh-lua-addon-installer",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "node esbuild.js",
"watch": "node esbuild.js --watch",
"package": "node esbuild.js --production"
},
"dependencies": {
"@actions/core": "1.10.1"
},
"devDependencies": {
"ts-node": "^10.9.2",
"typescript": "7.0.2",
"esbuild": "0.28.2"
}
}
@@ -0,0 +1,72 @@
import * as core from '@actions/core';
import * as fs from 'fs/promises';
import * as path from 'path';
import { existsSync } from 'fs';
async function copyDirectory(src: string, dest: string): Promise<void> {
await fs.mkdir(dest, { recursive: true });
const entries = await fs.readdir(src, { withFileTypes: true });
for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
await copyDirectory(srcPath, destPath);
} else {
await fs.copyFile(srcPath, destPath);
}
}
}
async function run() {
try {
const destinationPath = core.getInput('destination-path');
if (!destinationPath) {
core.setFailed('Destination path is required.');
return;
}
// Reference lua-addons relative to the dist directory
// __dirname is dist/, so lua-addons is one level up
const bundledAddonsDir = path.resolve(__dirname, '../lua-addons');
// Verify bundled addons directory exists
if (!existsSync(bundledAddonsDir)) {
core.setFailed(`Lua-addons directory not found at: ${bundledAddonsDir}`);
return;
}
// Get the workspace root and resolve destination path
const workspaceRoot = process.env.GITHUB_WORKSPACE || process.cwd();
const absoluteDestinationPath = path.join(workspaceRoot, destinationPath);
core.info(`Copying lua-addons to: ${absoluteDestinationPath}`);
// Create destination directory if it doesn't exist
await fs.mkdir(absoluteDestinationPath, { recursive: true });
// Copy all bundled addons to the destination
const addons = await fs.readdir(bundledAddonsDir, { withFileTypes: true });
for (const addon of addons) {
if (addon.isDirectory()) {
const sourceAddonDir = path.join(bundledAddonsDir, addon.name);
const destAddonDir = path.join(absoluteDestinationPath, addon.name);
core.info(`Installing addon: ${addon.name}`);
await copyDirectory(sourceAddonDir, destAddonDir);
core.info(`${addon.name} installed`);
}
}
core.info('Lua addons installation completed successfully.');
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
} else {
core.setFailed('An unknown error occurred');
}
}
}
run();
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"types": ["node"],
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": [
"src/**/*.ts"
]
}