Skip to content

rm dbg

rm dbg #33

Workflow file for this run

name: CI
on:
push:
branches: [master, feature/**, fix/**]
paths-ignore:
- "**.md"
pull_request:
types: [opened, reopened, synchronize]
release:
types: [published]
env:
PACKAGE_NAME: VipModular
STORE_README: 0
PLUGINS_INI_GENERATE: 1
PLUGINS_INI_POSTFIX: vipm
DEPS_LIST: |
AmxxModularEcosystem/ParamsController@1.3.0
AmxxModularEcosystem/CommandAliases@1.0.1
jobs:
build:
name: "Build"
runs-on: ubuntu-latest
outputs:
COMMIT_SHA: ${{ steps.declare_sha.outputs.COMMIT_SHA }}
SEMVER: ${{ steps.declare_sha.outputs.SEMVER }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- name: Parse SemVer string (release)
id: semver_parser
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
uses: booxmedialtd/ws-action-parse-semver@v1.4.7
with:
input_string: ${{ github.ref }}
version_extractor_regex: 'refs\/tags\/(.*)$'
- name: Declare SHA & package name
id: declare_sha
shell: bash
run: |
SHA=$(git rev-parse --short HEAD)
echo "COMMIT_SHA=$SHA" >> $GITHUB_OUTPUT
echo "SEMVER=${{ steps.semver_parser.outputs.fullversion }}" >> $GITHUB_OUTPUT
- name: Setup latest ReAPI includes
env:
REPO: "rehlds/ReAPI"
OUTPUT_VAR_NAME: REAPI_INCLUDE_PATH
run: |
mkdir -p dep/reapi
cd dep/reapi
curl \
--silent \
https://api.github.com/repos/$REPO/releases/latest | \
jq .assets[0].browser_download_url -r | \
xargs wget
7z x *.zip
echo "${OUTPUT_VAR_NAME}=$(pwd)/addons/amxmodx/scripting/include" >> $GITHUB_ENV
- name: Setup deps includes
env:
DEPS_LIST: ${{ env.DEPS_LIST }}
OUTPUT_VAR_NAME: DEPS_COMPILER_ARGS
run: |
handleDep() {
REPO="${1%%@*}"
TAG="${1#*@}"
TAG="${TAG%%:*}"
OVERRIDE_INCLUDE_PATH=`echo $1 | grep -Po '(?<=:).+'`
if [ -z "$REPO" ]; then
echo "No repo provided"
exit 1
fi
INIT_PWD=$(pwd)
mkdir -p dep/${REPO}
cd dep/${REPO}
if [ -z "$" ]; then
TAG=`curl --silent https://api.github.com/repos/${REPO}/releases/latest | jq .tag_name -r`
fi
wget https://github.com/${REPO}/archive/refs/tags/${TAG}.zip -q > /dev/null
7z x ${TAG}.zip > /dev/null
REPO_NAME=`echo "${REPO}" | grep -Po '(?<=\/).+'`
INCLUDE_PATH="$(pwd)/${REPO_NAME}-${TAG}/${OVERRIDE_INCLUDE_PATH:-amxmodx/scripting/include}"
echo "-i\"${INCLUDE_PATH}\""
cd $INIT_PWD
}
# Собираем все аргументы в локальную переменную
DEPS_COMPILER_ARGS=""
deps=$(echo ${DEPS_LIST} | tr ";" "\n")
echo "deps: ${deps}"
echo "-"
echo "-"
for dep in $deps
do
# Вызываем функцию, но перенаправляем её вывод в локальную переменную
path_arg=$(handleDep "$dep")
DEPS_COMPILER_ARGS="${DEPS_COMPILER_ARGS} ${path_arg}"
done
# Записываем финальную переменную
echo "Final ${OUTPUT_VAR_NAME}: ${DEPS_COMPILER_ARGS}"
echo "${OUTPUT_VAR_NAME}=${DEPS_COMPILER_ARGS}" >> $GITHUB_ENV
- name: Setup AMXXPawn Compiler
uses: wopox1337/setup-amxxpawn@v1.1.0
with:
version: "1.10.5428"
- name: Compile plugins
working-directory: amxmodx/scripting/
env:
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }}
PLUGINS_INI_GENERATE: ${{ env.PLUGINS_INI_GENERATE }}
PLUGINS_INI_POSTFIX: ${{ env.PLUGINS_INI_POSTFIX }}
DEPS_COMPILER_ARGS: ${{ env.DEPS_COMPILER_ARGS }}
run: |
compile() {
sourcefile=$1
amxxfile="$(echo $sourcefile | sed -e 's/\.sma$/.amxx/')"
output_path="../plugins/$amxxfile"
mkdir -p $(dirname $output_path)
echo "Compiling $sourcefile ... "
echo "amxxpc $sourcefile -o\"$output_path\" -i\"include\" -i\"$REAPI_INCLUDE\" $DEPS_COMPILER_ARGS GITHUB_ACTIONS_USED=1"
amxxpc $sourcefile -o"$output_path" \
-i"include" \
-i"$REAPI_INCLUDE" \
$DEPS_COMPILER_ARGS \
GITHUB_ACTIONS_USED=1
if [ ! -z "${PLUGINS_INI_GENERATE}" ]; then
plugin_ini_path="../configs/plugins-${PLUGINS_INI_POSTFIX}.ini"
touch $plugin_ini_path
echo $amxxfile >> $plugin_ini_path
fi
}
export -f compile
find . -type f -name "*.sma" -exec bash -c 'compile "$0"' {} \;
- name: Move files
env:
STORE_README: ${{ env.STORE_README }}
run: |
mkdir -p publish/${{ env.PACKAGE_NAME }}/addons
mv amxmodx/ publish/${{ env.PACKAGE_NAME }}/addons
if [ ! -z "${STORE_README}" ]; then
mv README.md publish/
fi
- name: Deploy artifact
uses: actions/upload-artifact@v4.3.1
with:
name: ${{ env.PACKAGE_NAME }}-${{ steps.declare_sha.outputs.COMMIT_SHA }}-dev
path: publish/*
publish:
name: "Publish release"
runs-on: ubuntu-latest
needs: [build]
if: |
github.event_name == 'release' &&
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
steps:
- name: Download artifact
uses: actions/download-artifact@v4.1.4
with:
name: ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.COMMIT_SHA }}-dev
- name: Packaging binaries
id: packaging
run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r ${{ env.PACKAGE_NAME }}-${{ needs.build.outputs.SEMVER }}.zip
- name: Publish artifacts
uses: softprops/action-gh-release@v2.0.4
id: publish-job
if: |
startsWith(github.ref, 'refs/tags/') &&
steps.packaging.outcome == 'success'
with:
files: |
*.zip