A3Antistasi / A3-Antistasi

A3-Antistasi is the new official Antistasi version
https://a3antistasi.enjin.com/
MIT License
79 stars 337 forks source link

Add build script and Travis CI #150

Open anpage opened 6 years ago

anpage commented 6 years ago

Relevant to issue #138, this pull request implements a Bash script to build the three variants of the mission as well as a Travis CI configuration for automated builds. This allows for easy automated release deployment as demonstrated by my fork with changes for my friends' private server.

It is currently missing the deployment section of the config because it is highly specific to the github repository. Here is an example snippet for the maintainers to use and here is the link to the Travis CI docs on the subject:

deploy:
  provider: releases
  api_key:
    secure: [encrypted API key]
  file_glob: true
  file: build/*
  skip_cleanup: true
  on:
    repo: A3Antistasi/A3-Antistasi
    tags: true

This runs automated builds for every commit and uploads the PBOs to GitHub for release every time a commit is tagged. These builds take advantage of my own dockerized version of Mikero's PBO tools, but I highly encourage you to fork it and use your own.

One last thing: makepbo has an option to check for errors in an addon before building the PBO, but I have that disabled as this process strips out some required files. I'm going to look into being more specific with its parameters to do error checking while still including everything. This would allow Travis CI to serve its usual purpose: automated testing. If something is broken, it'll be able to report it through GitHub and email.

zalexki commented 6 years ago

Hey @anpage thanks a lot for your contribution !

Never used travisCI but if they offer a free version we'll use it ! Very nice that you could use makepbo it never worked for me. (the mission wasn't loading, maybe due to this error checking your talking about).

Imma gonna wait your feedback if you can find how to fix this i'd like to get some tests during the build of the PBO.

anpage commented 6 years ago

Thanks for taking a look at this, @zalexki

Never used travisCI but if they offer a free version we'll use it !

Yep! Their services are free to any public repo on GitHub. You only have to pay if your project isn't open source.

Very nice that you could use makepbo it never worked for me. (the mission wasn't loading, maybe due to this error checking your talking about).

Yeah, I ran into that. The mission wouldn't boot at all until I configured it to leave all files intact. Full disclosure though: I've only tested the mission as it is built from the Windows version of makepbo. I haven't deployed a PBO built by the Linux version yet.

Imma gonna wait your feedback if you can find how to fix this i'd like to get some tests during the build of the PBO.

Sure thing. I think I'd also like to refine the build script a bit too so that it loops over an array of template names instead of using copy-pasted boilerplate code. It evolved from a .bat file I was using to build it on my Windows machine before I moved to using Docker.

zalexki commented 6 years ago

Yeah, I ran into that. The mission wouldn't boot at all until I configured it to leave all files intact. Full disclosure though: I've only tested the mission as it is built from the Windows version of makepbo. I haven't deployed a PBO built by the Linux version yet.

hum :/ had same issue, ok on windows, not on linux. if you still have the same issue, i've tried with https://www.npmjs.com/package/gulp-armapbo which is working when you don't use the compression.

anpage commented 6 years ago

I'll do some testing and if I can't make any progress with makepbo, I don't mind switching to the gulp plugin. I'll let you know what I find.

anpage commented 6 years ago

Just a quick update: I finally got around to upgrading my server to the new version of Arma 3 and I upgraded the mission file too while I was at it. The PBO built using the Linux version of makepbo (using Travis CI, the exact file in my fork's releases) works just fine, so it seems to be a viable way to do automated builds.

I'll work on enabling error checking next.

anpage commented 6 years ago

I've added some commits that revise the build script as planned and re-enable rapifying the mission file.

I tested this on my own server and everything seemed to work fine. I also tried compressing the PBO, but the mission wouldn't initialize, so I left it off.

wriley commented 5 years ago

In the build.sh script shouldn't the template files be copied after the main files? Othewise you're overwriting the map specific files with generic.

I'm using this version based on what you did and it seems to work

#!/usr/bin/env bash

# Make build folder
if [ -d "build" ]; then rm -rf build; fi
mkdir -p build

MISSIONS=(A3-AATemplate.Altis A3-AA-BLUFORTemplate.Altis A3-WotPTemplate.Tanoa A3-ArmiaKrajowaTemplate.chernarus_summer)

for MISSION in ${MISSIONS[@]}; do
    echo "Building ${MISSION}..."
    mkdir -p build/${MISSION}
    cp -r A3-Antistasi/* build/${MISSION}
    cp -rf A3-Antistasi/Templates/${MISSION}/* build/${MISSION}/
    rm -rf build/${MISSION}/Templates/*/

    OUTPUT=$(makepbo -PN build/${MISSION} build/${MISSION}.pbo 2>&1)
    RET=$?

    if [[ $RET -ne 0 ]]; then
        echo "Error: makepbo returned $RET"
        echo "$OUTPUT"
        exit 1
    fi

    rm -rf build/${MISSION}
done
Jonathan-Rosewood commented 5 years ago

@anpage what about SQF/HPP/IMG minification, enabling mod support (like a RHS), some finnaly cleanup and building PDO file?