Skip to content

Commit

Permalink
New version control
Browse files Browse the repository at this point in the history
  • Loading branch information
FEDERICOMB96 committed Jul 23, 2024
1 parent a92b207 commit 7431cf6
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 37 deletions.
74 changes: 70 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.declare_sha.outputs.sha }}
semver: ${{ steps.declare_sha.outputs.semver }}

steps:
- name: Checkout
Expand Down Expand Up @@ -54,11 +53,78 @@ jobs:
xargs wget
7z x *.zip
echo "REAPI_INCLUDE_PATH=$(pwd)/addons/amxmodx/scripting/include" >> $GITHUB_ENV
- name: Updating app version
working-directory: version/
run: |
VERSION_FILE=version.h
APPVERSION_FILE=../addons/amxmodx/scripting/include/mm_incs/version.inc
APPVERSION_FILE_NATIVES=../addons/amxmodx/scripting/include/multimod_manager_version.inc
GIT_DIR=../
BRANCH_NAME=master
MAJOR=$(cat "$VERSION_FILE" | grep -wi 'MM_VERSION_MAJOR' | sed -e 's/.*MM_VERSION_MAJOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAJOR" = "" ]; then
MAJOR=0
fi
MINOR=$(cat "$VERSION_FILE" | grep -wi 'MM_VERSION_MINOR' | sed -e 's/.*MM_VERSION_MINOR.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MINOR" = "" ]; then
MINOR=0
fi
MAINTENANCE=$(cat "$VERSION_FILE" | grep -i 'MM_VERSION_MAINTENANCE' | sed -e 's/.*MM_VERSION_MAINTENANCE.*[^0-9]\([0-9][0-9]*\).*/\1/i' -e 's/\r//g')
if [ $? -ne 0 -o "$MAINTENANCE" = "" ]; then
MAINTENANCE=0
fi
COMMIT_COUNT=$(git -C "$GIT_DIR/" rev-list --count $BRANCH_NAME)
if [ $? -ne 0 -o "$COMMIT_COUNT" = "" ]; then
COMMIT_COUNT=0
fi
NEW_VERSION_INC="$MAJOR$MINOR$MAINTENANCE$COMMIT_COUNT"
NEW_VERSION="$MAJOR.$MINOR.$MAINTENANCE.$COMMIT_COUNT"
echo "NEW_VERSION_INC=${NEW_VERSION_INC}" >> $GITHUB_ENV
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
echo Updating $APPVERSION_FILE, new version is '"'$NEW_VERSION'"'
echo -e "#if defined _mm_version_included_\r" > $APPVERSION_FILE
echo -e " #endinput\r" >> $APPVERSION_FILE
echo -e "#endif\r" >> $APPVERSION_FILE
echo -e "#define _mm_version_included_\r" >> $APPVERSION_FILE
echo -e "\r" >> $APPVERSION_FILE
echo -e "// MultiMod Manager version\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION $NEW_VERSION_INC\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MAJOR $MAJOR\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MINOR $MINOR\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_MAINTENANCE $MAINTENANCE\r" >> $APPVERSION_FILE
echo -e "#define MM_VERSION_COMMIT $COMMIT_COUNT\r" >> $APPVERSION_FILE
echo -e "\r" >> $APPVERSION_FILE
echo -e "#define PLUGIN_VERSION fmt("v%d.%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, MM_VERSION_COMMIT)" >> $APPVERSION_FILE
echo Updating $APPVERSION_FILE_NATIVES, new version is '"'$NEW_VERSION'"'
echo -e "#if defined _multimod_manager_version_included_\r" > $APPVERSION_FILE_NATIVES
echo -e " #endinput\r" >> $APPVERSION_FILE_NATIVES
echo -e "#endif\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define _multimod_manager_version_included_\r" >> $APPVERSION_FILE_NATIVES
echo -e "\r" >> $APPVERSION_FILE_NATIVES
echo -e "// MultiMod Manager version\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION $NEW_VERSION_INC\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MAJOR $MAJOR\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MINOR $MINOR\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_MAINTENANCE $MAINTENANCE\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_VERSION_COMMIT $COMMIT_COUNT\r" >> $APPVERSION_FILE_NATIVES
echo -e "\r" >> $APPVERSION_FILE_NATIVES
echo -e "#define MM_NATIVES_API_VER fmt("v%d.%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, MM_VERSION_COMMIT)" >> $APPVERSION_FILE_NATIVES
- name: Compile AMXX plugins
working-directory: addons/amxmodx/scripting/
env:
REAPI_INCLUDE: ${{env.REAPI_INCLUDE_PATH}}
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }}
run: |
mkdir ../plugins/
for sourcefile in *.sma;
Expand Down Expand Up @@ -88,7 +154,7 @@ jobs:
- name: Deploying resources artifacts
uses: actions/download-artifact@v4
with:
name: MultiModManagerCS-${{needs.build.outputs.sha}}
name: MultiModManagerCS-${{ needs.build.outputs.sha }}

- name: Packaging binaries
id: packaging-job
Expand All @@ -97,7 +163,7 @@ jobs:
github.event.action == 'published' &&
startsWith(github.ref, 'refs/tags/')
run: |
7z a -mm=Deflate -mfb=258 -mpass=15 -r MultiModManagerCS-v${{needs.build.outputs.semver}}.zip addons/
7z a -mm=Deflate -mfb=258 -mpass=15 -r MultiModManagerCS-v${{ env.NEW_VERSION }}.zip addons/
- name: Publish artifacts
uses: softprops/action-gh-release@v2
Expand Down
20 changes: 20 additions & 0 deletions addons/amxmodx/scripting/include/mm_incs/checks.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#if defined _mm_checks_included_
#endinput
#endif
#define _mm_checks_included_

// Do NOT modify this file!

/**
* AMX Mod X version check
*/
#if AMXX_VERSION_NUM < 200
#error "Multimod Manager CS requires AMX Mod X 1.10 or higher. Download from: https://www.amxmodx.org/downloads-new.php?branch=master"
#endif

/**
* ReAPI version check
*/
#if REAPI_VERSION < 524300
#error "Multimod Manager CS requires ReAPI 5.24.300 or higher. Download from: https://github.com/s1lentq/reapi/releases/latest"
#endif
22 changes: 4 additions & 18 deletions addons/amxmodx/scripting/include/mm_incs/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,8 @@

// Do NOT modify this file!

/**
* AMX Mod X version check
*/
#if AMXX_VERSION_NUM < 200
#error "Multimod Manager CS requires AMX Mod X 1.10 or higher. Download from: https://www.amxmodx.org/downloads-new.php?branch=master"
#endif

/**
* ReAPI version check
*/
#if REAPI_VERSION < 524300
#error "Multimod Manager CS requires ReAPI 5.24.300 or higher. Download from: https://github.com/s1lentq/reapi/releases/latest"
#endif

#define MM_VERSION_MAJOR 2
#define MM_VERSION_MINOR 3
#define MM_VERSION_COMMIT 219
#define MM_VERSION_MAJOR 2
#define MM_VERSION_MINOR 3
#define MM_VERSION_MAINTENANCE 0

#define PLUGIN_VERSION fmt("v%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_COMMIT)
#define PLUGIN_VERSION fmt("v%d.%d.%d.(%s %s)", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, __DATE__, __TIME__)
17 changes: 17 additions & 0 deletions addons/amxmodx/scripting/include/multimod_manager_checks.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#if defined _multimod_manager_checks_included_
#endinput
#endif
#define _multimod_manager_checks_included_

// Do NOT modify this file!

/**
* AMX Mod X version check
*/
#if defined AMXX_VERSION_NUM
#if AMXX_VERSION_NUM < 200
#error "[API] Multimod Manager CS requires AMX Mod X 1.10 or higher. Download from: https://www.amxmodx.org/downloads-new.php?branch=master"
#endif
#else
#error "[API] Multimod Manager CS: please include multimod_manager_natives.inc after including amxmodx.inc."
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#endif
#define _multimod_manager_natives_included_

#include <multimod_manager_checks>
#include <multimod_manager_version>

/**
Expand Down
19 changes: 4 additions & 15 deletions addons/amxmodx/scripting/include/multimod_manager_version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,8 @@

// Do NOT modify this file!

/**
* AMX Mod X version check
*/
#if defined AMXX_VERSION_NUM
#if AMXX_VERSION_NUM < 200
#error "[API] Multimod Manager CS requires AMX Mod X 1.10 or higher. Download from: https://www.amxmodx.org/downloads-new.php?branch=master"
#endif
#else
#error "[API] Multimod Manager CS: please include multimod_manager_natives.inc after including amxmodx.inc."
#endif

#define MM_VERSION_MAJOR 2
#define MM_VERSION_MINOR 3
#define MM_VERSION_COMMIT 219
#define MM_VERSION_MAJOR 2
#define MM_VERSION_MINOR 3
#define MM_VERSION_MAINTENANCE 0

#define MM_NATIVES_API_VER fmt("v%d.%d.%d", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_COMMIT)
#define MM_NATIVES_API_VER fmt("v%d.%d.%d.(%s %s)", MM_VERSION_MAJOR, MM_VERSION_MINOR, MM_VERSION_MAINTENANCE, __DATE__, __TIME__)
1 change: 1 addition & 0 deletions addons/amxmodx/scripting/multimod_manager.sma
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <amxmisc>
#include <reapi>
#include <json>
#include "mm_incs/checks"
#include "mm_incs/version"
#include "mm_incs/defines"
#include "mm_incs/global"
Expand Down
8 changes: 8 additions & 0 deletions version/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Version declaration dependency file
*
*/

#define MM_VERSION_MAJOR 2
#define MM_VERSION_MINOR 3
#define MM_VERSION_MAINTENANCE 0

0 comments on commit 7431cf6

Please sign in to comment.