Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ jobs:
haxe-version: ${{ matrix.haxe }}
cache-dependency-path: 'test-workflow/${{ matrix.lib_hxml }}'

- run: neko -version
- run: haxe -version

- run: haxelib install test-workflow/${{ matrix.lib_hxml }} --always
Expand Down
37 changes: 31 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function main() {
try {
const inputVersion = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('haxe-version');
const cacheDependencyPath = _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('cache-dependency-path');
const nightly = /^(\d{4}-\d{2}-\d{2}_[\w.-]+_\w+)|latest$/.test(inputVersion);
const nightly = /^(\d{4}-\d{2}-\d{2}_[\w./-]+_\w+)|latest$/.test(inputVersion);
const version = nightly ? inputVersion : semver__WEBPACK_IMPORTED_MODULE_1__.valid(semver__WEBPACK_IMPORTED_MODULE_1__.clean(inputVersion));
if (version) {
await (0,_setup__WEBPACK_IMPORTED_MODULE_2__/* .setup */ .c)(version, nightly, cacheDependencyPath);
Expand Down Expand Up @@ -187,20 +187,28 @@ class Asset {
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0/neko-2.4.0-win64.zip
class NekoAsset extends Asset {
force32;
static resolveFromHaxeVersion(version) {
static resolveFromHaxeVersion(version, nightly) {
const env = new Env();
if (nightly) {
return new NekoAsset('latest', true, false, env);
}
// Haxe older than 4.3 has issues with mbedtls 3 in neko 2.4
const nekoVer = version.startsWith('3.') || (version.startsWith('4.') && version < '4.3.') ? '2.3.0'
: '2.4.0';
const env = new Env();
// Haxe 3 on windows has 32 bit haxelib, which requires 32 bit neko
const force32 = version.startsWith('3.') && env.platform === 'win';
return new NekoAsset(nekoVer, force32, env);
return new NekoAsset(nekoVer, false, force32, env);
}
constructor(version, force32, env = new Env()) {
nightly = false;
constructor(version, nightly, force32, env = new Env()) {
super('neko', version, env);
this.force32 = force32;
this.nightly = nightly;
}
get downloadUrl() {
if (this.nightly) {
return `https://build.haxe.org/builds/neko/${this.nightlyTarget}/neko_${this.version}${this.fileExt}`;
}
const tag = `v${this.version.replace(/\./g, '-')}`;
return super.makeDownloadUrl(`/neko/releases/download/${tag}/${this.fileNameWithoutExt}${this.fileExt}`);
}
Expand All @@ -213,6 +221,23 @@ class NekoAsset extends Asset {
}
return `${this.env.platform}${this.env.arch}`;
}
get nightlyTarget() {
const plat = this.env.platform;
switch (plat) {
case 'osx': {
return 'mac-universal';
}
case 'linux': {
return 'linux64';
}
case 'win': {
return 'windows64';
}
default: {
throw new Error(`${plat} not supported`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
}
}
get fileNameWithoutExt() {
return `neko-${this.version}-${this.target}`;
}
Expand Down Expand Up @@ -366,7 +391,7 @@ async function saveHaxelib() {

const env = new Env();
async function setup(version, nightly, cacheDependencyPath) {
const neko = NekoAsset.resolveFromHaxeVersion(version); // Haxelib requires Neko
const neko = NekoAsset.resolveFromHaxeVersion(version, nightly); // Haxelib requires Neko
const nekoPath = await neko.setup();
lib_core.addPath(nekoPath);
lib_core.exportVariable('NEKOPATH', nekoPath);
Expand Down
41 changes: 37 additions & 4 deletions src/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,34 @@ abstract class Asset {
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0/neko-2.4.0-osx-universal.tar.gz
// * NOTE https://github.com/HaxeFoundation/neko/releases/download/v2-4-0/neko-2.4.0-win64.zip
export class NekoAsset extends Asset {
static resolveFromHaxeVersion(version: string) {
static resolveFromHaxeVersion(version: string, nightly: boolean) {
const env = new Env();

if (nightly) {
return new NekoAsset('latest', true, false, env);
}

// Haxe older than 4.3 has issues with mbedtls 3 in neko 2.4
const nekoVer = version.startsWith('3.') || (version.startsWith('4.') && version < '4.3.') ? '2.3.0'
: '2.4.0';
const env = new Env();
// Haxe 3 on windows has 32 bit haxelib, which requires 32 bit neko
const force32 = version.startsWith('3.') && env.platform === 'win';

return new NekoAsset(nekoVer, force32, env);
return new NekoAsset(nekoVer, false, force32, env);
}

constructor(version: string, protected readonly force32: boolean, env = new Env()) {
nightly = false;

constructor(version: string, nightly: boolean, protected readonly force32: boolean, env = new Env()) {
super('neko', version, env);
this.nightly = nightly;
}

get downloadUrl() {
if (this.nightly) {
return `https://build.haxe.org/builds/neko/${this.nightlyTarget}/neko_${this.version}${this.fileExt}`;
}

const tag = `v${this.version.replace(/\./g, '-')}`;
return super.makeDownloadUrl(
`/neko/releases/download/${tag}/${this.fileNameWithoutExt}${this.fileExt}`,
Expand All @@ -173,6 +185,27 @@ export class NekoAsset extends Asset {
return `${this.env.platform}${this.env.arch}`;
}

get nightlyTarget() {
const plat = this.env.platform;
switch (plat) {
case 'osx': {
return 'mac-universal';
}

case 'linux': {
return 'linux64';
}

case 'win': {
return 'windows64';
}

default: {
throw new Error(`${plat} not supported`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
}
}

get fileNameWithoutExt() {
return `neko-${this.version}-${this.target}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function main(): Promise<void> {
try {
const inputVersion = core.getInput('haxe-version');
const cacheDependencyPath = core.getInput('cache-dependency-path');
const nightly = /^(\d{4}-\d{2}-\d{2}_[\w.-]+_\w+)|latest$/.test(inputVersion);
const nightly = /^(\d{4}-\d{2}-\d{2}_[\w./-]+_\w+)|latest$/.test(inputVersion);
const version = nightly ? inputVersion : semver.valid(semver.clean(inputVersion));
if (version) {
await setup(version, nightly, cacheDependencyPath);
Expand Down
2 changes: 1 addition & 1 deletion src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { restoreHaxelib, createHaxelibKey } from './haxelib';
const env = new Env();

export async function setup(version: string, nightly: boolean, cacheDependencyPath: string) {
const neko = NekoAsset.resolveFromHaxeVersion(version); // Haxelib requires Neko
const neko = NekoAsset.resolveFromHaxeVersion(version, nightly); // Haxelib requires Neko
const nekoPath = await neko.setup();
core.addPath(nekoPath);
core.exportVariable('NEKOPATH', nekoPath);
Expand Down