diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fcde5d3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,118 @@ +name: CI + +on: + push: + branches: [main] + paths-ignore: + - "**.md" + + pull_request: + types: [opened, reopened, synchronize] + release: + types: [published] + +jobs: + build: + name: "Build" + runs-on: ubuntu-24.04 + outputs: + COMMIT_SHA: ${{ steps.declare_sha.outputs.COMMIT_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_OUTPUT + + - name: Setup latest ReAPI includes + env: + REPO: "rehlds/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: Setup AMXXPawn Compiler + uses: wopox1337/setup-amxxpawn@master + with: + version: '1.9.x' + + - name: Compile plugins + working-directory: scripting/ + env: + REAPI_INCLUDE: ${{ env.REAPI_INCLUDE_PATH }} + run: | + compile() { + sourcefile=$1 + amxxfile="$(echo $sourcefile | sed -e 's/\.sma$/.amxx/')" + output_path="../plugins/$amxxfile" + + mkdir -p $(dirname $output_path) + + echo -n "Compiling $sourcefile ... " + amxxpc $sourcefile -o"$output_path" \ + -i"include" \ + -i"$REAPI_INCLUDE" + } + export -f compile + + find * -type f -name "*.sma" -exec bash -c 'compile "$0"' {} \; + + - name: Directory + run: | + rm -rf ./dep + + - name: Deploy artifact + uses: actions/upload-artifact@v4 + with: + name: stab_info-${{ steps.declare_sha.outputs.COMMIT_SHA }}-dev + path: ./* + + publish: + name: "Publish release" + runs-on: ubuntu-24.04 + 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 + with: + name: stab_info-${{ needs.build.outputs.COMMIT_SHA }}-dev + + - name: Packaging binaries + id: packaging + run: 7z a -mm=Deflate -mfb=258 -mpass=15 -r stab_info-${{ github.event.release.tag_name }}.zip ./ + + - name: Publish artifacts + uses: softprops/action-gh-release@v2 + id: publish-job + if: | + startsWith(github.ref, 'refs/tags/') && + steps.packaging.outcome == 'success' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + *.zip + *.amxx +