App version fixes #114
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pawn Compiler | |
on: | |
push: | |
branches: [master] | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
types: [opened, reopened, synchronize] | |
release: | |
types: [published] | |
tags: | |
- "v*.*.*" | |
jobs: | |
build: | |
name: "Build" | |
runs-on: ubuntu-latest | |
outputs: | |
sha: ${{ steps.declare_sha.outputs.sha }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Declare SHA & package name | |
id: declare_sha | |
shell: bash | |
run: | | |
SHA=$(git rev-parse --short HEAD) | |
echo "COMMIT_SHA=${SHA}" >> $GITHUB_ENV | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
- name: Updating app version (only pull requests) | |
if: | | |
github.event_name == 'pull_request' | |
shell: bash | |
run: | | |
chmod +x ${GITHUB_WORKSPACE}/version/appversion_pr.sh | |
${GITHUB_WORKSPACE}/version/appversion_pr.sh ${GITHUB_WORKSPACE} ${{ github.event.pull_request.number }} | |
- name: Updating app version (non pull requests) | |
if: | | |
github.event_name != 'pull_request' | |
shell: bash | |
run: | | |
chmod +x ${GITHUB_WORKSPACE}/version/appversion.sh | |
${GITHUB_WORKSPACE}/version/appversion.sh ${GITHUB_WORKSPACE} | |
- name: Moving app version files | |
run: | | |
mv -f version/version.inc addons/amxmodx/scripting/include/mm_incs/ | |
mv -f version/multimod_manager_version.inc addons/amxmodx/scripting/include/ | |
- name: Setup AMXXPawn Compiler | |
uses: wopox1337/setup-amxxpawn@master | |
with: | |
version: "1.10.5461" | |
- name: Setup ReAPI includes | |
env: | |
REPO: "s1lentq/reapi" | |
run: | | |
mkdir -p dep/reapi | |
cd dep/reapi | |
curl \ | |
--silent \ | |
https://api.github.com/repos/$REPO/releases/latest | \ | |
grep "browser_download_url" | \ | |
grep -Eo 'https://[^\"]*' | \ | |
xargs wget | |
7z x *.zip | |
echo "REAPI_INCLUDE_PATH=$(pwd)/addons/amxmodx/scripting/include" >> $GITHUB_ENV | |
- name: Compile AMXX plugins | |
working-directory: addons/amxmodx/scripting/ | |
env: | |
REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }} | |
run: | | |
cat include/mm_incs/version.inc | |
mkdir ../plugins/ | |
for sourcefile in *.sma; | |
do | |
amxxfile="`echo $sourcefile | sed -e 's/\.sma$/.amxx/'`" | |
echo -n "Compiling $sourcefile ... " | |
amxxpc $(basename $sourcefile) -o"../plugins/$(basename $amxxfile)" -i"include" -i"$REAPI_INCLUDE" | |
done | |
- name: Moving files to publish | |
run: | | |
mkdir publish | |
cp -f addons/amxmodx/scripting/include/mm_incs/version.inc publish/appversion.inc | |
mv addons/ -t publish/ | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: MultiModManagerCS-${{ env.COMMIT_SHA }} | |
path: publish/* | |
publish: | |
name: "Publish" | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Deploying resources artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: MultiModManagerCS-${{ needs.build.outputs.sha }} | |
- name: Reading appversion.inc | |
run: | | |
if [ -e appversion.inc ]; then | |
APP_VERSION=$(cat appversion.inc | grep -wi '#define MM_VERSION_STRD' | sed -e 's/#define MM_VERSION_STRD[ \t\r\n\v\f]\+\(.*\)/\1/i' -e 's/\r//g') | |
if [ $? -ne 0 ]; then | |
APP_VERSION="" | |
else | |
# Remove quotes | |
APP_VERSION=$(echo $APP_VERSION | xargs) | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
fi | |
fi | |
rm -f appversion.inc | |
- name: Packaging binaries | |
id: packaging-job | |
if: | | |
github.event_name == 'release' && | |
github.event.action == 'published' && | |
startsWith(github.ref, 'refs/tags/') | |
run: | | |
7z a -mm=Deflate -mfb=258 -mpass=15 -r MultiModManagerCS-v${{ env.APP_VERSION }}.zip addons/ | |
- name: Publish artifacts | |
uses: softprops/action-gh-release@v2 | |
id: publish-job | |
if: | | |
startsWith(github.ref, 'refs/tags/') && | |
steps.packaging-job.outcome == 'success' | |
with: | |
files: | | |
*.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |