Update API Bindings #1581
This file contains hidden or 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: Update API Bindings | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Commit Tag' | |
| schedule: | |
| - cron: "0 0 * * *" | |
| jobs: | |
| download: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| nwnx_sha_short: ${{ steps.revision.outputs.NWNX_SHA_SHORT }} | |
| nwn_build: ${{ steps.version.outputs.NWN_BUILD }} | |
| nwn_build_revision: ${{ steps.version.outputs.NWN_BUILD_REVISION }} | |
| nwn_build_postfix: ${{ steps.version.outputs.NWN_BUILD_POSTFIX }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| path: "./repo" | |
| - name: Download Tools | |
| run: | | |
| wget https://github.com/niv/neverwinter.nim/releases/download/2.0.1/neverwinter.linux.amd64.zip && \ | |
| unzip neverwinter.linux.amd64.zip | |
| - name: Load Environment Info | |
| id: "dotenv" | |
| uses: falti/dotenv-action@v1 | |
| with: | |
| path: "./repo/.env" | |
| - 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-7)" >> $GITHUB_OUTPUT | |
| - name: Checkout NWNX | |
| uses: actions/checkout@v4 | |
| with: | |
| path: "./nwnx" | |
| repository: "nwnxee/unified" | |
| ref: ${{ steps.revision.outputs.NWNX_SHA }} | |
| - 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: Extract Server Image | |
| id: "nwn_extract" | |
| uses: shrink/actions-docker-extract@v3 | |
| with: | |
| image: nwnxee/unified:${{ steps.revision.outputs.NWNX_SHA_SHORT }} | |
| path: /nwn | |
| - name: Unpack Key File | |
| run: | | |
| ./nwn_key_unpack ${{ steps.nwn_extract.outputs.destination }}/nwn/data/data/nwn_base.key ${GITHUB_WORKSPACE}/nwn | |
| - name: Copy Scripts | |
| run: | | |
| mkdir -p ${GITHUB_WORKSPACE}/scripts/nwn | |
| mkdir -p ${GITHUB_WORKSPACE}/scripts/nwnx | |
| find ${GITHUB_WORKSPACE}/nwn -name 'nwscript.nss' -type f -exec cp -v '{}' ${GITHUB_WORKSPACE}/scripts/nwn \; | |
| find ${GITHUB_WORKSPACE}/nwnx/Plugins -name '*.nss' -type f -exec cp -v '{}' ${GITHUB_WORKSPACE}/scripts/nwnx \; | |
| test -e ${GITHUB_WORKSPACE}/scripts/nwn/nwscript.nss | |
| - name: Upload Scripts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nss_source | |
| path: ./scripts | |
| build: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: docker://nwndotnet/nss2csharp:latest | |
| needs: [download] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| path: ./repo | |
| ssh-key: ${{ secrets.API_PUSH_KEY }} | |
| persist-credentials: true | |
| - name: Download Scripts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nss_source | |
| path: ./scripts | |
| - name: Convert | |
| run: | | |
| su -c "rm -fv ${GITHUB_WORKSPACE}/repo/NWN.Core/src/NWNX/Plugins/*" | |
| dotnet /app/Nss2CSharp.dll "${GITHUB_WORKSPACE}/scripts/nwn" "${GITHUB_WORKSPACE}/repo/NWN.Core/src/NWN" "${GITHUB_WORKSPACE}/scripts/nwnx" "${GITHUB_WORKSPACE}/repo/NWN.Core/src/NWNX/Plugins" | |
| if [ -z "$(ls -A ${GITHUB_WORKSPACE}/repo/NWN.Core/src/NWNX/Plugins)" ]; then | |
| exit 1 | |
| fi | |
| - 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: Commit Changes | |
| run: | | |
| cd ${GITHUB_WORKSPACE}/repo | |
| git config user.name jhett12321 | |
| git config user.email 10942655+jhett12321@users.noreply.github.com | |
| git add -A NWN.Core/src/NWN/NWScript.cs NWN.Core/src/NWNX/Plugins/ | |
| git diff-index --quiet HEAD NWN.Core/src/NWN/NWScript.cs NWN.Core/src/NWNX/Plugins/ || | |
| git commit -m "Update APIs (NWNX: ${{ needs.download.outputs.nwnx_sha_short }}, NWN: ${{ needs.download.outputs.nwn_build }}.${{ needs.download.outputs.nwn_build_revision }}-${{ needs.download.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; |