Latest with inputs, P8 download and extractions

This commit is contained in:
Dagen Brock 2020-03-04 13:01:09 -06:00
parent 3d999cd3db
commit 2f38947dd8
8 changed files with 4761 additions and 28 deletions

2
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: [digarok]
custom: ["https://paypal.me/dagenbrock"]

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules

View File

@ -4,15 +4,22 @@ A Github Action for installing Cadius and allowing you to manipulate ProDOS disk
# Example usage # Example usage
``` ```
workflow "All pushes" { # This will install Cadius on your Github Runner machine
on = "push" - name: Install Cadius
resolves = ["Make a Disk"] uses: digarok/cadius-action@node
} with:
include_prodos: true
action "Make a Disk" {
uses = "digarok/cadius-action@master" # Now you can use it to create a new bootable ProDOS disk
run = "cadius createvolume exampledsk.po exampledsk 140KB" - name: Create Boot Volume
} - run: |
cadius createvolume exampledsk.po exampledsk 140KB
cadius addfile exampledsk.po /exampledsk/ ./PRODOS.2.4.2/PRODOS
``` ```
# Arguments/Inputs
This action has one input: `include_prodos`. By setting this to true, it will download the latest release of ProDOS (2.4.2) and extract all of the files to a directory called `PRODOS.2.4.2`. This allows you to use those files, if needed, in subsequent steps. So you can create a bootable disk or even add `BASIC.SYSTEM` to launch into AppleSoft BASIC.
# About CADIUS
Cadius is a disk image program originally by the amazing French team, Brutal Deluxe. They are not involved with this Open Source version, but I do recommend you view [their site](http://brutaldeluxe.fr/products/crossdevtools/cadius/) for more information on Cadius and their other incredible tools and releases.

View File

@ -2,7 +2,7 @@ name: 'cadius-action'
description: 'Github Action to set up Cadius for ProDOS disk image manipulation' description: 'Github Action to set up Cadius for ProDOS disk image manipulation'
author: 'Dagen Brock' author: 'Dagen Brock'
inputs: inputs:
includeProdos: # change this include_prodos:
description: 'Download Prodos 2.4.2 files to allow you to create a bootable disk.' description: 'Download Prodos 2.4.2 files to allow you to create a bootable disk.'
default: 'true' default: 'true'
runs: runs:

4677
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
"name": "cadius-action", "name": "cadius-action",
"version": "0.0.0", "version": "0.0.0",
"license": "MIT", "license": "MIT",
"main": "dist/index.js",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"pack": "ncc build dist/index.js" "pack": "ncc build dist/index.js"

View File

@ -1,6 +1,6 @@
import * as os from 'os'; import * as os from 'os';
import * as util from 'util'; import * as util from 'util';
import * as path from 'path'; import * as fs from 'fs';
import * as toolCache from '@actions/tool-cache'; import * as toolCache from '@actions/tool-cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
@ -9,13 +9,11 @@ function getDownloadURL(version: string): string {
switch (os.type()) { switch (os.type()) {
case 'Linux': case 'Linux':
return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-ubuntu-latest-%s.zip', version, version); return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-ubuntu-latest-%s.zip', version, version);
case 'Darwin': case 'Darwin':
return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-macos-latest-%s.zip', version, version); return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-macos-latest-%s.zip', version, version);
case 'Windows_NT': case 'Windows_NT':
default: default:
return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-windows-latest-%s.zip', version, version); return util.format('https://github.com/digarok/cadius/releases/download/%s/cadius-windows-latest-%s.zip', version, version);
} }
} }
@ -29,18 +27,80 @@ async function downloadCadius(version: string) {
console.log(exception) console.log(exception)
throw new Error(util.format("Failed to download Cadius from location ", getDownloadURL(version))); throw new Error(util.format("Failed to download Cadius from location ", getDownloadURL(version)));
} }
const extractedPath = await toolCache.extractZip(downloadPath); const extractedPath = await toolCache.extractZip(downloadPath);
cachedToolpath = await toolCache.cacheDir(path.join(extractedPath, 'cadius'), 'cadius', version); cachedToolpath = await toolCache.cacheDir(extractedPath, 'cadius', version);
}
core.addPath(cachedToolpath)
return cachedToolpath
}
async function downloadProdos(cadiusPath: string) {
// get real exe location (is this needed?)
let cadiusExe = util.format('%s/cadius', cadiusPath)
if (os.type() == 'Windows_NT') {
cadiusExe = util.format('%s/Cadius.exe', cadiusPath)
} }
core.addPath(cachedToolpath) // something is wrong with the mirrors cert so we'll just use http
let downloadP8URL = 'http://mirrors.apple2.org.za/ftp.apple.asimov.net/images/masters/prodos/ProDOS_2_4_2.dsk'
let downloadD2PURL = 'https://raw.githubusercontent.com/digarok/dsk2po/master/dsk2po.py'
let p8DownloadPath;
let d2pDownloadPath;
try {
p8DownloadPath = await toolCache.downloadTool(downloadP8URL);
} catch (exception) {
console.log(exception);
throw new Error(util.format("Failed to download ProDOS from location ", downloadP8URL));
}
console.log(util.format("Downloaded file: ", p8DownloadPath));
// move it so it's in the user workspace in any future steps
let p8DskPath = './ProDOS_2_4_2.dsk'
fs.renameSync(p8DownloadPath, p8DskPath);
try {
d2pDownloadPath = await toolCache.downloadTool(downloadD2PURL);
} catch (exception) {
console.log(exception);
throw new Error(util.format("Failed to download dsk2po.py from location ", downloadD2PURL));
}
console.log(util.format("Downloaded file: ", d2pDownloadPath));
// Now we need to a) convert the image and b) extract the volume file locally
try {
const spawn = require("child_process").spawn;
const spawnSync = require("child_process").spawnSync;
spawnSync('python3',[d2pDownloadPath, p8DskPath]);
const cadiusProcess = spawnSync(cadiusExe, ['extractvolume', 'ProDOS_2_4_2.po', '.'],{ encoding : 'utf8' })
console.log(cadiusProcess.stdout);
} catch (exception) {
console.log(exception);
console.log("Unagle to complete ProDOS download and extraction.");
}
} }
async function run() { async function run() {
let version = core.getInput('version', { 'required': true }); let version = core.getInput('version');
await downloadCadius(version); if (!version) {
version = '0.0.0'; // default
}
let includeProdos = false;
let inputIncludeProdos = core.getInput('include_prodos');
if (inputIncludeProdos.toLowerCase() == "true" || inputIncludeProdos == "") {
includeProdos = true; // default
}
console.log(`INPUTS - version '${version}'`);
console.log(`INPUTS - includeProdos '${includeProdos}'`);
let cadiusPath = await downloadCadius(version);
console.log(`Cadius version: '${version}' has been downloaded and added to path`); console.log(`Cadius version: '${version}' has been downloaded and added to path`);
if (includeProdos) {
await downloadProdos(cadiusPath);
console.log(`ProDOS download and extraction completed`);
}
} }
run().catch(core.setFailed); run().catch(core.setFailed);

View File

@ -4,7 +4,7 @@
// "incremental": true, /* Enable incremental compilation */ // "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
//"lib": ["es6"], /* Specify library files to be included in the compilation. */ "lib": ["es6"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */ // "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */ // "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
@ -16,7 +16,7 @@
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */ // "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */ "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */ // "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */