Update API Bindings #1321
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: Update API Bindings | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Commit Tag' | |
jobs: | |
download: | |
runs-on: ubuntu-20.04 | |
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@v2 | |
with: | |
path: ./repo | |
- name: Download Tools | |
run: | | |
wget https://github.com/niv/neverwinter.nim/releases/download/1.5.9/neverwinter.linux.amd64.zip && \ | |
unzip neverwinter.linux.amd64.zip | |
- name: Load Environment Info | |
id: "dotenv" | |
uses: falti/[email protected] | |
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 ::set-output name=nwnx_sha::$( echo $NWNX_SHA ) | |
echo ::set-output name=nwnx_sha_short::$( echo $NWNX_SHA | cut -c1-7 ) | |
- name: Checkout NWNX | |
uses: actions/checkout@v2 | |
with: | |
repository: "nwnxee/unified" | |
path: "./nwnx" | |
ref: ${{ steps.revision.outputs.nwnx_sha }} | |
- name: Load Game Version | |
id: "version" | |
run: | | |
echo "::set-output name=nwn_build::$(grep 'set(TARGET_NWN_BUILD ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" | |
echo "::set-output name=nwn_build_revision::$(grep 'set(TARGET_NWN_BUILD_REVISION ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" | |
echo "::set-output name=nwn_build_postfix::$(grep 'set(TARGET_NWN_BUILD_POSTFIX ' ./nwnx/CMakeLists.txt | cut -d' ' -f2 | sed 's/)//')" | |
- 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-20.04 | |
container: | |
image: docker://nwndotnet/nss2csharp:latest | |
needs: [download] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
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/src/NWNX/Plugins/*" | |
dotnet /app/Nss2CSharp.dll "${GITHUB_WORKSPACE}/scripts/nwn" "${GITHUB_WORKSPACE}/repo/src/NWN" "${GITHUB_WORKSPACE}/scripts/nwnx" "${GITHUB_WORKSPACE}/repo/src/NWNX/Plugins" | |
if [ -z "$(ls -A ${GITHUB_WORKSPACE}/repo/src/NWNX/Plugins)" ]; then | |
exit 1 | |
fi | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: 7.0.x | |
- 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 [email protected] | |
git add -A src/NWN/NWScript.cs src/NWNX/Plugins/ | |
git diff-index --quiet HEAD src/NWN/NWScript.cs 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; |