From 2886ae473e547f9071bcadcb1fa480efe249c2e0 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 18:29:26 +0100 Subject: [PATCH 01/12] Add a basic build workflow (#99) --- .github/workflows/build.yml | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..48b773c6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,61 @@ +# Copyright (c) FAForever +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: Build + +on: + workflow_dispatch: + workflow_call: + +jobs: + build: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: MINGW32 + + - name: Install MinGW + run: | + pacman --noconfirm -S mingw-w64-i686-gcc + + - uses: actions/checkout@v4 + + - name: Download Patcher + run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o BinaryPatcher.exe + + - name: Download Baseline + run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe + + - name: Patch Binary + run: | + # + echo '#define gitsha "'${GITHUB_SHA::7}'"' > workflow.cpp + ./BinaryPatcher.exe + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: "ForgedAlliance_${{ github.sha }}" + path: | + ForgedAlliance_exxt.exe From a4a51c6a0e45d2bb9d879bcab677372790e21b7b Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 21:54:13 +0100 Subject: [PATCH 02/12] Run the build workflow on pull requests --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 48b773c6..4e4c72d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,8 @@ name: Build on: + pull_request: + branches: "master" workflow_dispatch: workflow_call: From 0cdf44cfd2f2e2d4176c7054edc82b1615739c22 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:02:03 +0100 Subject: [PATCH 03/12] Remove the old test workflow --- .github/workflows/test.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index b37075b5..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Test -on: - workflow_dispatch: - -jobs: - build: - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - steps: - - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW32 - - - name: Install MinGW - run: | - pacman --noconfirm -S mingw-w64-i686-gcc - - - uses: actions/checkout@v4 - - - name: Download Patcher - run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o FaP.exe - - - name: Download Baseline - run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe - - - name: Patch Binary - run: ./FaP.exe From 30ed8fcd7ceaf37c1d68d2d430a0d407ba541ce3 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:02:16 +0100 Subject: [PATCH 04/12] Run the build workflow on the master branch --- .github/workflows/build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e4c72d9..6e057b5e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,9 +18,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -name: Build +# Responsible for creating a build. The build process succeeding is a test +# on itself. If it succeeds, then we know that the executable can be run +# and everything that remains are possible run-time errors :). + +name: Build and test on: + push: + branches: "master" pull_request: branches: "master" workflow_dispatch: From f1df9fa7732b931b1892b166a62df0370f44754a Mon Sep 17 00:00:00 2001 From: Artur <32177740+RutreD@users.noreply.github.com> Date: Sun, 10 Nov 2024 23:18:17 +0200 Subject: [PATCH 05/12] Add the ability to bind the side mouse buttons (#96) Supports the buttons that are identified with `XButton1` and `XButton2` --- README.md | 3 ++ hooks/OnWindowMessage.cpp | 3 ++ section/OnWindowMessage.cpp | 62 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 hooks/OnWindowMessage.cpp create mode 100644 section/OnWindowMessage.cpp diff --git a/README.md b/README.md index 9adf1034..a178e08e 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,9 @@ These don't matter except for other assembly patches - section/xact_3d_fix.cpp - Improvements to lua messages - hooks/LuaMessages.cpp +- Adds the ability to bind the side mouse buttons (XButton1 and XButton2) + - hooks/OnWindowMessage.cpp + - section/OnWindowMessage.cpp ## Gameplay - Change tick intel update interval from every 30 ticks to every 1 tick diff --git a/hooks/OnWindowMessage.cpp b/hooks/OnWindowMessage.cpp new file mode 100644 index 00000000..b1a05ea0 --- /dev/null +++ b/hooks/OnWindowMessage.cpp @@ -0,0 +1,3 @@ +#include "../define.h" +asm(".section h0; .set h0,0x00430C0E;" + "call " QU(OnWindowMessage) ";"); diff --git a/section/OnWindowMessage.cpp b/section/OnWindowMessage.cpp new file mode 100644 index 00000000..60dcc170 --- /dev/null +++ b/section/OnWindowMessage.cpp @@ -0,0 +1,62 @@ +#include "include/global.h" + +struct KeyEventInfo +{ + unsigned long repeatCount : 16; + unsigned long scanCode : 8; + unsigned long isExtended : 1; + unsigned long reserved : 4; + unsigned long contextCode : 1; + unsigned long previousState : 1; + unsigned long transitionState : 1; + + inline unsigned long ToULong() const + { + return repeatCount | + (scanCode << 16) | + (isExtended << 24) | + (reserved << 25) | + (contextCode << 29) | + (previousState << 30) | + (transitionState << 31); + } +}; +static_assert(sizeof(KeyEventInfo) == 4); + +int __thiscall wxWindow__MSWWindowProc(void *this_, unsigned int uMsg, unsigned int wParam, unsigned long lParam) asm("0x0096D110"); + +int __thiscall OnWindowMessage(void *this_, unsigned int uMsg, unsigned int wParam, unsigned long lParam) +{ + switch (uMsg) + { + case 0x020B: /*WM_XBUTTONDOWN*/ + uMsg = 0x0100; /*WM_KEYDOWN*/ + wParam = (((wParam) >> 16) & 0xFFFF) + 4; // VK_XBUTTON(1 or 2) + lParam = KeyEventInfo{ + .repeatCount = 1, + .scanCode = 0xFF, + .isExtended = 0, + .reserved = 0, + .contextCode = 0, + .previousState = 0, + .transitionState = 0} + .ToULong(); + break; + case 0x020C: /*WM_XBUTTONUP*/ + uMsg = 0x0101; /*WM_KEYUP*/ + wParam = (((wParam) >> 16) & 0xFFFF) + 4; // VK_XBUTTON(1 or 2) + lParam = KeyEventInfo{ + .repeatCount = 1, + .scanCode = 0xFF, + .isExtended = 0, + .reserved = 0, + .contextCode = 0, + .previousState = 1, + .transitionState = 1} + .ToULong(); + break; + default: + break; + } + return wxWindow__MSWWindowProc(this_, uMsg, wParam, lParam); +} \ No newline at end of file From 627a7e7bfbe4c7b70954b431a6b2e6bb9a205b90 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:21:46 +0100 Subject: [PATCH 06/12] Add documentation --- .github/workflows/build.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6e057b5e..e56eae4d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +name: Build and test + # Responsible for creating a build. The build process succeeding is a test # on itself. If it succeeds, then we know that the executable can be run # and everything that remains are possible run-time errors :). -name: Build and test - on: push: branches: "master" @@ -49,18 +49,24 @@ jobs: - uses: actions/checkout@v4 - - name: Download Patcher + - name: Download patcher run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o BinaryPatcher.exe + # This is the baseline binary that all executable patches rely on. - name: Download Baseline run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe - - name: Patch Binary + # Allows us to determine what executable is running as we play the game. + - name: Add commit hash to patch files run: | - # echo '#define gitsha "'${GITHUB_SHA::7}'"' > workflow.cpp + + # Patches the binary by applying all the assembly patches. + - name: Patch the binary + run: | ./BinaryPatcher.exe + # Allows us to retrieve, test and/or release the patched binary. - name: Upload artifact uses: actions/upload-artifact@v4 with: From cd5435da88b448390b095e3d32ce4c12e1e68fd5 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:29:20 +0100 Subject: [PATCH 07/12] Re-use the build workflow when uploading --- .github/workflows/upload.yml | 67 +++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml index 0ec45f25..48015c66 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/upload.yml @@ -1,52 +1,63 @@ -name: Upload +# Copyright (c) FAForever +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: Upload and release on: workflow_dispatch: inputs: modName: - description: 'modName' + description: "modName" required: true - default: 'fafdevelop' + default: "fafdevelop" type: choice options: - - fafdevelop - - fafbeta + - fafdevelop + - fafbeta jobs: build: + name: Patch the binary + uses: ./.github/workflows/build.yml + release: environment: deploy - runs-on: windows-latest + runs-on: linux-latest defaults: run: - shell: msys2 {0} + shell: bash steps: - - uses: msys2/setup-msys2@v2 + # Retrieve the patched binary + - name: Download artifact of patched binary + uses: actions/download-artifact@v4 with: - msystem: MINGW32 - - - name: Install MinGW - run: | - pacman --noconfirm -S mingw-w64-i686-gcc - - - uses: actions/checkout@v4 - - - name: Download Patcher - run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o FaP.exe - - - name: Download Baseline - run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe - - - name: Patch Binary - run: | - echo '#define gitsha "'${GITHUB_SHA::7}'"' > workflow.cpp - ./FaP.exe + name: "ForgedAlliance_${{ github.sha }}" + path: . - - name: Post file + # Upload the patched binary to the FAForever server + - name: Upload to server run: curl -f -X "POST" "https://api.faforever.com/exe/upload" -F "modName=${{ github.event.inputs.modName }}" -F "apiKey=${{ secrets.apiKey }}" -F "file=@ForgedAlliance_exxt.exe" - - name: Create Release + # Upon succesful upload, create a release in the repository + - name: Create a Release id: create_release uses: ncipollo/release-action@v1 env: From 81a2d90b24e129e969e2e698d2f5d3348d2780c2 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:48:46 +0100 Subject: [PATCH 08/12] Add the build workflow as a requirement --- .github/workflows/upload.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml index 48015c66..150fae7c 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/upload.yml @@ -37,6 +37,7 @@ jobs: name: Patch the binary uses: ./.github/workflows/build.yml release: + needs: build environment: deploy runs-on: linux-latest defaults: From 13a813485f4395cbfb0452e4d9e2e4c5aaa13dbd Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Sun, 10 Nov 2024 22:50:39 +0100 Subject: [PATCH 09/12] Also run on Windows --- .github/workflows/upload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml index 150fae7c..a646e053 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/upload.yml @@ -39,7 +39,7 @@ jobs: release: needs: build environment: deploy - runs-on: linux-latest + runs-on: windows-latest defaults: run: shell: bash From f9e957b2d8dffa7954dbbdf5ed2bae41cd76bbdd Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Mon, 11 Nov 2024 18:47:39 +0100 Subject: [PATCH 10/12] Remove the use of artifacts --- .../workflows/{upload.yml => c/release.yml} | 41 ++++++++++++++----- .github/workflows/{build.yml => c/test.yml} | 23 ++++------- 2 files changed, 39 insertions(+), 25 deletions(-) rename .github/workflows/{upload.yml => c/release.yml} (63%) rename .github/workflows/{build.yml => c/test.yml} (80%) diff --git a/.github/workflows/upload.yml b/.github/workflows/c/release.yml similarity index 63% rename from .github/workflows/upload.yml rename to .github/workflows/c/release.yml index a646e053..645678f3 100644 --- a/.github/workflows/upload.yml +++ b/.github/workflows/c/release.yml @@ -18,7 +18,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -name: Upload and release +name: Release - C + +# Note: due to piracy concerns we should at no point upload the executable as +# an artifact. We do not want the lua-compatible executable available to the +# public without verification that they own the game. This verification is +# done via the client. on: workflow_dispatch: @@ -33,23 +38,39 @@ on: - fafbeta jobs: - build: - name: Patch the binary - uses: ./.github/workflows/build.yml release: - needs: build environment: deploy runs-on: windows-latest defaults: run: shell: bash steps: - # Retrieve the patched binary - - name: Download artifact of patched binary - uses: actions/download-artifact@v4 + - uses: msys2/setup-msys2@v2 with: - name: "ForgedAlliance_${{ github.sha }}" - path: . + msystem: MINGW32 + + - name: Install MinGW + run: | + pacman --noconfirm -S mingw-w64-i686-gcc + + - uses: actions/checkout@v4 + + - name: Download patcher + run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o BinaryPatcher.exe + + # This is the baseline binary that all executable patches rely on. + - name: Download Baseline + run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe + + # Allows us to determine what executable is running as we play the game. + - name: Add commit hash to patch files + run: | + echo '#define gitsha "'${GITHUB_SHA::7}'"' > workflow.cpp + + # Patches the binary by applying all the assembly patches. Produces a new executable called "ForgedAlliance_exxt.exe". + - name: Patch the binary + run: | + ./BinaryPatcher.exe # Upload the patched binary to the FAForever server - name: Upload to server diff --git a/.github/workflows/build.yml b/.github/workflows/c/test.yml similarity index 80% rename from .github/workflows/build.yml rename to .github/workflows/c/test.yml index e56eae4d..6e7b21d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/c/test.yml @@ -18,14 +18,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -name: Build and test +name: Test - C -# Responsible for creating a build. The build process succeeding is a test -# on itself. If it succeeds, then we know that the executable can be run -# and everything that remains are possible run-time errors :). +# Note: due to piracy concerns we should at no point upload the executable as +# an artifact. We do not want the lua-compatible executable available to the +# public without verification that they own the game. This verification is +# done via the client. on: - push: + push: branches: "master" pull_request: branches: "master" @@ -33,7 +34,7 @@ on: workflow_call: jobs: - build: + test: runs-on: windows-latest defaults: run: @@ -52,7 +53,7 @@ jobs: - name: Download patcher run: curl -L "https://github.com/FAForever/FA_Patcher/releases/latest/download/FaP.exe" -o BinaryPatcher.exe - # This is the baseline binary that all executable patches rely on. + # This is the baseline binary that all executable patches rely on. - name: Download Baseline run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe @@ -65,11 +66,3 @@ jobs: - name: Patch the binary run: | ./BinaryPatcher.exe - - # Allows us to retrieve, test and/or release the patched binary. - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: "ForgedAlliance_${{ github.sha }}" - path: | - ForgedAlliance_exxt.exe From 4f32a89b2a045a23403221007b0703e6826aaa83 Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Mon, 11 Nov 2024 18:47:47 +0100 Subject: [PATCH 11/12] Add python workflows --- .github/workflows/python/release.yml | 90 ++++++++++++++++++++++++++++ .github/workflows/python/test.yml | 68 +++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 .github/workflows/python/release.yml create mode 100644 .github/workflows/python/test.yml diff --git a/.github/workflows/python/release.yml b/.github/workflows/python/release.yml new file mode 100644 index 00000000..82370687 --- /dev/null +++ b/.github/workflows/python/release.yml @@ -0,0 +1,90 @@ +# Copyright (c) FAForever +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: Release - Python + +# Note: due to piracy concerns we should at no point upload the executable as +# an artifact. We do not want the lua-compatible executable available to the +# public without verification that they own the game. This verification is +# done via the client. + +on: + workflow_dispatch: + inputs: + modName: + description: "modName" + required: true + default: "fafdevelop" + type: choice + options: + - fafdevelop + - fafbeta + +jobs: + release: + runs-on: windows-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install MinGW i686 + run: choco install mingw --x86 -y --no-progress + + - name: Add mingw32 to path + run: echo C:/ProgramData/mingw64/mingw32/bin/ >> $env:GITHUB_PATH + + - name: Install python requirements + run: | + git clone https://github.com/FAForever/fa-python-binary-patcher.git + pip install -r ./fa-python-binary-patcher/requirements.txt + + - name: Download base executable + run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe + + # This is the practical test - if it patches, then we're good + - name: Patch base executable + run: | + echo "#define gitsha \"${{ github.sha }}\"" > workflow.cpp + mkdir build + python ./fa-python-binary-patcher/main.py "$(pwd)" clang++ ld g++ + + # Upload the patched binary to the FAForever server + - name: Upload to server + run: curl -f -X "POST" + "https://api.faforever.com/exe/upload" -F "modName=${{ github.event.inputs.modName }}" -F "apiKey=${{ secrets.apiKey }}" + -F "file=@ForgedAlliance_exxt.exe" + + # Upon succesful upload, create a release in the repository + - name: Create a Release + id: create_release + uses: ncipollo/release-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + commit: ${{ github.sha }} + tag: ${{ github.event.inputs.modName }}_${{ github.sha }} + token: ${{ secrets.GITHUB_TOKEN }} + generateReleaseNotes: true diff --git a/.github/workflows/python/test.yml b/.github/workflows/python/test.yml new file mode 100644 index 00000000..ca06bc3c --- /dev/null +++ b/.github/workflows/python/test.yml @@ -0,0 +1,68 @@ +# Copyright (c) FAForever +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +name: Test - Python + +# Note: due to piracy concerns we should at no point upload the executable as +# an artifact. We do not want the lua-compatible executable available to the +# public without verification that they own the game. This verification is +# done via the client. + +on: + push: + branches: "master" + pull_request: + branches: "master" + workflow_dispatch: + workflow_call: + +jobs: + test: + runs-on: windows-latest + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install MinGW i686 + run: choco install mingw --x86 -y --no-progress + + - name: Add mingw32 to path + run: echo C:/ProgramData/mingw64/mingw32/bin/ >> $env:GITHUB_PATH + + - name: Install python requirements + run: | + git clone https://github.com/FAForever/fa-python-binary-patcher.git + pip install -r ./fa-python-binary-patcher/requirements.txt + + - name: Download base executable + run: curl -L "https://content.faforever.com/build/ForgedAlliance_base.exe" -o ForgedAlliance_base.exe + + # This is the practical test - if it patches, then we're good + - name: Patch base executable + run: | + echo "#define gitsha \"${{ github.sha }}\"" > workflow.cpp + mkdir build + python ./fa-python-binary-patcher/main.py "$(pwd)" clang++ ld g++ From 5287c3ea8afb0fce04788cfd8770216dd5f8205a Mon Sep 17 00:00:00 2001 From: "(Jip) Willem Wijnia" Date: Mon, 11 Nov 2024 18:49:31 +0100 Subject: [PATCH 12/12] Move workflows into the `workflows` folder --- .github/workflows/{c/release.yml => release-c.yml} | 0 .github/workflows/{python/release.yml => release-python.yml} | 0 .github/workflows/{c/test.yml => test-c.yml} | 0 .github/workflows/{python/test.yml => test-python.yml} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{c/release.yml => release-c.yml} (100%) rename .github/workflows/{python/release.yml => release-python.yml} (100%) rename .github/workflows/{c/test.yml => test-c.yml} (100%) rename .github/workflows/{python/test.yml => test-python.yml} (100%) diff --git a/.github/workflows/c/release.yml b/.github/workflows/release-c.yml similarity index 100% rename from .github/workflows/c/release.yml rename to .github/workflows/release-c.yml diff --git a/.github/workflows/python/release.yml b/.github/workflows/release-python.yml similarity index 100% rename from .github/workflows/python/release.yml rename to .github/workflows/release-python.yml diff --git a/.github/workflows/c/test.yml b/.github/workflows/test-c.yml similarity index 100% rename from .github/workflows/c/test.yml rename to .github/workflows/test-c.yml diff --git a/.github/workflows/python/test.yml b/.github/workflows/test-python.yml similarity index 100% rename from .github/workflows/python/test.yml rename to .github/workflows/test-python.yml