Update API Bindings #638
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: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Commit Tag' | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
container: | |
image: docker://nwnxee/builder:latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
path: "./repo" | |
ssh-key: ${{ secrets.DEPLOY_KEY }} | |
persist-credentials: true | |
- name: Load Environment Info | |
id: "dotenv" | |
uses: falti/[email protected] | |
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 ::set-output name=nwnx_sha::$( echo $NWNX_SHA ) | |
echo ::set-output name=nwnx_sha_short::$( echo $NWNX_SHA | cut -c1-8 ) | |
- name: Checkout NWNX | |
uses: actions/checkout@v2 | |
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/src/main/API/* | |
cp -av ${GITHUB_WORKSPACE}/nwnx/Plugins/SWIG/SWIG_DotNET/out/*.cs ${GITHUB_WORKSPACE}/repo/src/main/API | |
if [ -z "$(ls -A ${GITHUB_WORKSPACE}/repo/src/main/API)" ]; then | |
exit 1 | |
fi | |
ls -la ${GITHUB_WORKSPACE}/repo/src/main/API | |
- 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: 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: Commit Changes | |
run: | | |
cd ${GITHUB_WORKSPACE}/repo | |
git config user.name jhett12321 | |
git config user.email [email protected] | |
git add -A src/main/API/ | |
git diff-index --quiet HEAD 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; |