Skip to content

Commit

Permalink
rework for amxxpawn
Browse files Browse the repository at this point in the history
  • Loading branch information
wopox1337 committed Jun 13, 2023
1 parent 047c881 commit 6596020
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 70 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/dev_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Setup SourcePawn Compiler
- name: Setup AMXXPawn Compiler
uses: ./
with:
version: "1.12.x"
version: "1.10.x"

- name: Verify compiler
run: |
which spcomp
which amxxpc
echo $includePath
ls -l $scriptingPath
cat $(which spcomp)
spcomp __tests__/compile.sp
cat $(which amxxpc)
amxxpc __tests__/compile.sma
14 changes: 7 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Setup SourcePawn Compiler
uses: rumblefrog/setup-sp@master
- name: Setup AMXXPawn Compiler
uses: wopox1337/setup-amxxpawn@master
with:
version: "1.12.x"
version: "1.10.x"

- name: Verify compiler
run: |
which spcomp
which amxxpc
echo $includePath
ls -l $scriptingPath
cat $(which spcomp)
spcomp __tests__/compile.sp
cat $(which amxxpc)
amxxpc __tests__/compile.sma
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Setup SourcePawn Action
# Setup AMXXPawn Action

![](https://github.com/rumblefrog/setup-sp/workflows/Main%20Workflow/badge.svg)
![](https://github.com/wopox1337/setup-amxxpawn/workflows/Main%20Workflow/badge.svg)

This action sets-up, cache and adds sourcemod scripting directory to the path
This action sets-up, cache and adds amxmodx scripting directory to the path

# Usage

See [action.yml](https://github.com/rumblefrog/setup-sp/blob/master/action.yml)
See [action.yml](https://github.com/wopox1337/setup-amxxpawn/blob/master/action.yml)

## Basic:

```yaml
steps:
- uses: actions/checkout@v3

- uses: rumblefrog/setup-sp@master
- uses: wopox1337/setup-amxxpawn@master
with:
version: '1.12.x'
version: '1.10.x'

- run: spcomp -iAnotherIncludeDirectory plugin.sp -o output/plugin.smx
- run: amxxpc -iAnotherIncludeDirectory plugin.sma -o output/plugin.amxx
```

## Matrix:
Expand All @@ -29,41 +29,41 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
sm-version: [ '1.11.x', '1.12.x', '1.11.6467', '>= 1.11.6478']
amxx-version: [ '1.9.x', '1.10.x', '1.10.5467', '>= 1.10.5455']

name: SM version ${{ matrix.sm-version }}
name: AMXX version ${{ matrix.amxx-version }}
steps:
- uses: actions/checkout@v3

- name: Setup SP
uses: rumblefrog/setup-sp@master
- name: Setup AMXX
uses: wopox1337/setup-amxxpawn@master
with:
version: ${{ matrix.sm-version }}
version: ${{ matrix.amxx-version }}

- run: spcomp -iAnotherIncludeDirectory plugin.sp -o output/plugin.smx
- run: amxxpc -iAnotherIncludeDirectory plugin.sma -o output/plugin.amxx
```

## Extract the version of the .sp file:
## Extract the version of the .sma file:

```yaml
jobs:
build:
runs-on: ubuntu-latest

name: SM version ${{ matrix.sm-version }}
name: AMXX version ${{ matrix.amxx-version }}
steps:
- uses: actions/checkout@v1

- name: Setup SP
id: setup_sp
uses: rumblefrog/setup-sp@master
- name: Setup AMXX
id: setup_amxx
uses: wopox1337/setup-amxxpawn@master
with:
version: '1.10.x'
version-file: ./plugin.sp
version-file: ./plugin.sma

- run: |
spcomp -iAnotherIncludeDirectory plugin.sp -o output/plugin.smx
echo Plugin version ${{ steps.setup_sp.outputs.plugin-version }}
amxxpc -iAnotherIncludeDirectory plugin.sma -o output/plugin.amxx
echo Plugin version ${{ steps.setup_amxx.outputs.plugin-version }}
```

A complete workflow example can be found [here](https://github.com/Sarrus1/DiscordWebhookAPI/blob/master/.github/workflows/master.yml).
8 changes: 8 additions & 0 deletions __tests__/compile.sma
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <amxmodx>

#pragma semicolon 1

public plugin_init()
{
server_print("Hello, World!");
}
9 changes: 0 additions & 9 deletions __tests__/compile.sp

This file was deleted.

14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'Setup SourcePawn Compiler'
name: 'Setup AMXXPawn Compiler'
author: 'rumblefrog'
description: 'Install and setup SourcePawn compiler'
description: 'Install and setup AMXXPawn compiler'
inputs:
version:
description: 'Version of SP compiler'
description: 'Version of AMXX compiler'
required: true
default: '1.10.x'
version-file:
Expand All @@ -14,15 +14,15 @@ inputs:
description: 'Name of the define for the version of the plugin if you are using one'
required: false
default: ''
no-spcomp-proxy:
description: 'Whether spcomp should not be proxied to fix relative include path'
no-amxxpc-proxy:
description: 'Whether amxxpc should not be proxied to fix relative include path'
required: false
default: 'false'
outputs:
version:
description: 'Version of the SP compiler used'
description: 'Version of the AMXX compiler used'
version-file:
description: 'Version of the .sp file'
description: 'Version of the .sma file'
runs:
using: 'node16'
main: 'lib/index.js'
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { join as pathJoin } from 'path';
import { getVersions } from './utils/scraper';
import { Version } from './structures/versioning';

const CACHE_KEY = 'sourcepawn';
const CACHE_KEY = 'amxxpawn';
let versions: { [x: string]: Version | { toEndpoint: () => string; }; };

export async function installCompiler(range: string): Promise<string> {
versions = await getVersions();

let version = maxSatisfying(Object.keys(versions), range);
let version = maxSatisfying(Object.keys(versions), range);

if (version === null) {
throw new Error(`Unable to find a version matching ${range}`);
Expand All @@ -26,26 +26,26 @@ export async function installCompiler(range: string): Promise<string> {
}

// Workaround for https://github.com/rumblefrog/setup-sp/issues/5
// We use a proxy script to call the original spcomp64 and include the path to the compiler
if (
// We use a proxy script to call the original amxxpc64 and include the path to the compiler
/* if (
!(
getBooleanInput('no-spcomp-proxy', { required: false })
|| process.env.NO_SPCOMP_PROXY
getBooleanInput('no-amxxpc-proxy', { required: false })
|| process.env.NO_AMXXPC_PROXY
) &&
process.platform == 'linux' && !existsSync(pathJoin(cache, 'spcomp64_original'))
process.platform == 'linux' && !existsSync(pathJoin(cache, 'amxxpc64_original'))
) {
await rename(pathJoin(cache, 'spcomp64'), pathJoin(cache, 'spcomp64_original'));
await rename(pathJoin(cache, 'spcomp'), pathJoin(cache, 'spcomp_original'));
await rename(pathJoin(cache, 'amxxpc64'), pathJoin(cache, 'amxxpc64_original'));
await rename(pathJoin(cache, 'amxxpc'), pathJoin(cache, 'amxxpc_original'));
const proxy_script = `
#!/bin/bash
${pathJoin(cache, 'spcomp64_original')} -i${pathJoin(cache, 'include')} $@
${pathJoin(cache, 'amxxpc64_original')} -i${pathJoin(cache, 'include')} $@
`;
await writeFile(pathJoin(cache, 'spcomp'), proxy_script, { mode: 0o755 });
await writeFile(pathJoin(cache, 'spcomp64'), proxy_script, { mode: 0o755 });
await writeFile(pathJoin(cache, 'amxxpc'), proxy_script, { mode: 0o755 });
await writeFile(pathJoin(cache, 'amxxpc64'), proxy_script, { mode: 0o755 });
}

*/
addPath(cache);
exportVariable('scriptingPath', pathJoin(cache));
exportVariable('includePath', pathJoin(cache, 'include'));
Expand All @@ -55,7 +55,7 @@ export async function installCompiler(range: string): Promise<string> {

async function downloadCompiler(version: string) {
const spPath = await downloadTool(versions[version].toEndpoint());

let extracted: string;

if (process.platform === 'linux') {
Expand All @@ -64,7 +64,7 @@ async function downloadCompiler(version: string) {
extracted = await extractZip(spPath);
}

const spRoot = pathJoin(extracted, 'addons', 'sourcemod', 'scripting');
const spRoot = pathJoin(extracted, 'addons', 'amxmodx', 'scripting');

return await cacheDir(spRoot, CACHE_KEY, version);
}
2 changes: 1 addition & 1 deletion src/structures/versioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ export class Version {
}

public toEndpoint(): string {
return `${ENDPOINT}${this.major}.${this.minor}/sourcemod-${this.major}.${this.minor}.0-git${this.build}-${this.platform}.${this.archiveExt}`;
return `${ENDPOINT}${this.major}.${this.minor}/amxmodx-${this.major}.${this.minor}.0-git${this.build}-base-${this.platform}.${this.archiveExt}`;
}
}
4 changes: 2 additions & 2 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const ENDPOINT: string = 'https://www.sourcemod.net/smdrop/';
export const ENDPOINT: string = 'https://www.amxmodx.org/amxxdrop/';
export const MM_REGEX: RegExp = /href="(.*?)"/g;
export const BUILD_REGEX: RegExp = /href="sourcemod-[0-9]+.[0-9]+.[0-9]+-git([0-9]+)-(linux|windows|mac).(.*?)"/g;
export const BUILD_REGEX: RegExp = /href="amxmodx-[0-9]+.[0-9]+.[0-9]+-git([0-9]+)-base-(linux|windows|mac).(.*?)"/g;
3 changes: 2 additions & 1 deletion src/utils/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Platform, Version, Versions, parsePlatform } from '../structures/versio
import { HttpClient } from 'typed-rest-client/HttpClient';
import to from 'await-to-js';

const client = new HttpClient('setup-sp');
const client = new HttpClient('setup-amxxpawn');

export async function getVersions(): Promise<Versions> {
const [ err, res ] = await to(client.get(ENDPOINT));
Expand Down Expand Up @@ -37,6 +37,7 @@ export async function getVersions(): Promise<Versions> {
split[0],
split[1],
));

}

await Promise.all(promises);
Expand Down

0 comments on commit 6596020

Please sign in to comment.