-
Notifications
You must be signed in to change notification settings - Fork 7
129 lines (110 loc) · 4.77 KB
/
update-api.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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-20.04
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 [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;