Skip to content

Update API Bindings #792

Update API Bindings

Update API Bindings #792

Workflow file for this run

name: Update API Bindings
on:
workflow_dispatch:
inputs:
tag:
description: 'Commit Tag'
schedule:
- cron: "0 0 * * *"
jobs:
build:
runs-on: ubuntu-latest
container:
image: docker://nwnxee/builder:latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: "./repo"
ssh-key: ${{ secrets.DEPLOY_KEY }}
persist-credentials: true
- name: Load Environment Info
id: "dotenv"
uses: falti/dotenv-action@v1
with:
path: "./repo/.env"
- name: Install Dependencies
run: |
apt-get update && apt-get install curl jq -y
- name: Load Revisions
id: "revision"
run: |
NWNX_SHA=$(curl -u "u:${{github.token}}" https://api.github.com/repos/nwnxee/unified/git/ref/tags/${{ steps.dotenv.outputs.nwnx_tag }} | jq .object.sha | tr -d '"')
echo "NWNX_SHA=$NWNX_SHA" >> $GITHUB_OUTPUT
echo "NWNX_SHA_SHORT=$(echo $NWNX_SHA | cut -c1-8)" >> $GITHUB_OUTPUT
- name: Checkout NWNX
uses: actions/checkout@v4
with:
path: "./nwnx"
repository: "nwnxee/unified"
ref: ${{ steps.revision.outputs.NWNX_SHA }}
- name: Configure CMake
working-directory: ./nwnx
run: |
mkdir build-nwnx && cd build-nwnx && cmake ..
- name: Build
working-directory: ./nwnx/build-nwnx
run: |
cmake --build . --target SWIG_DotNET_swig_compilation -j 4
- name: Copy generated proxy classes
run: |
rm -f ${GITHUB_WORKSPACE}/repo/NWN.Native/src/main/API/*
cp -av ${GITHUB_WORKSPACE}/nwnx/Plugins/SWIG/SWIG_DotNET/out/*.cs ${GITHUB_WORKSPACE}/repo/NWN.Native/src/main/API
if [ -z "$(ls -A ${GITHUB_WORKSPACE}/repo/NWN.Native/src/main/API)" ]; then
exit 1
fi
ls -la ${GITHUB_WORKSPACE}/repo/NWN.Native/src/main/API
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: ./repo/global.json
- name: Test Build
run: |
cd ${GITHUB_WORKSPACE}/repo
dotnet build --configuration Release
- name: Load Game Version
id: "version"
run: |
echo "NWN_BUILD=$(grep 'set(TARGET_NWN_BUILD ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" >> $GITHUB_OUTPUT
echo "NWN_BUILD_REVISION=$(grep 'set(TARGET_NWN_BUILD_REVISION ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" >> $GITHUB_OUTPUT
echo "NWN_BUILD_POSTFIX=$(grep 'set(TARGET_NWN_BUILD_POSTFIX ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" >> $GITHUB_OUTPUT
- name: Commit Changes
run: |
cd ${GITHUB_WORKSPACE}/repo
git config user.name jhett12321
git config user.email [email protected]
git add -A NWN.Native/src/main/API/
git diff-index --quiet HEAD NWN.Native/src/main/API/ ||
git commit -m "Update APIs (NWNX: ${{ steps.revision.outputs.NWNX_SHA_SHORT }}, NWN: ${{ steps.version.outputs.NWN_BUILD }}.${{ steps.version.outputs.NWN_BUILD_REVISION }}-${{ steps.version.outputs.NWN_BUILD_POSTFIX }})." &&
if [ ${{ github.event.inputs.tag }} != '' ]; then git tag ${{ github.event.inputs.tag }} && git push --atomic origin ${{ github.ref }} ${{ github.event.inputs.tag }}; else git push; fi;