diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a9760e4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,98 @@ +name: Build CMake Project +on: + workflow_call: + secrets: + SSH_KEY: + required: false + description: SSH private key for pushing version changes + inputs: + cmake-preset: + required: true + type: string + upload-artifact-dll: + required: false + type: string + default: false + upload-artifact-vdf: + required: false + type: string + default: false + msvc-toolkit: + required: false + type: string + default: 14.4 + project-version: + required: false + type: string + default: false + push-version-commit: + required: false + type: boolean + default: false + push-version-branch: + required: false + type: string + default: main +jobs: + build: + name: MSVC / Windows 2022 + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: TheMrMilchmann/setup-msvc-dev@v3 + with: + arch: x86 + toolset: ${{ inputs.msvc-toolkit }} + export-path-to-vcvarsall: VCVARSALL + - name: CMake Setup + uses: lukka/get-cmake@latest + - uses: actions/checkout@v4 + with: + submodules: recursive + persist-credentials: false + - name: Set project version + if: ${{ inputs.project-version != 'false' }} + run: powershell ./set-version.ps1 ${{ inputs.project-version }} + - name: Setup token for branch rules bypass + uses: webfactory/ssh-agent@v0.9.0 + if: ${{ inputs.push-version-commit == true }} + with: + ssh-private-key: ${{ secrets.SSH_KEY }} + - name: Commit version change + if: ${{ inputs.push-version-commit == true }} + run: | + New-Item -ItemType Directory -Force -Path ~/.ssh + ssh-keyscan github.com >> ~/.ssh/known_hosts + git config --global user.name "Nekobot" + git config --global user.email "nekobot-service.noreply@silveroreteam.pl" + git remote set-url origin git@github.com:Silver-Ore-Team/zMultilogue.git + git fetch --all + git checkout ${{ inputs.push-version-branch }} + $changes = $(git status -s) + if ($changes) { + git add CMakeLists.txt + git commit -m "[skip ci] set project version to ${{ inputs.project-version }}" + git push origin ${{ inputs.push-version-branch }} + } else { + echo "No changes to commit" + } + - name: CMake Configure + run: cmake --preset ${{ inputs.cmake-preset }} + - name: Ninja Build + run: ninja -C out/build/${{ inputs.cmake-preset }} -j 20 + - name: CMake Install + run: cmake --install out/build/${{ inputs.cmake-preset }} --prefix out/install/${{ inputs.cmake-preset }} + - name: Archive DLL + if: ${{ inputs.upload-artifact-dll != 'false' }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.upload-artifact-dll }} + path: out/install/${{ inputs.cmake-preset }}/bin/*.dll + - name: Archive VDF + uses: actions/upload-artifact@v4 + if: ${{ inputs.upload-artifact-vdf != 'false' }} + with: + name: ${{ inputs.upload-artifact-vdf }} + path: out/install/${{ inputs.cmake-preset }}/*.vdf \ No newline at end of file diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml new file mode 100644 index 0000000..da245a3 --- /dev/null +++ b/.github/workflows/on-push.yml @@ -0,0 +1,18 @@ +name: On Push +permissions: write-all +on: + pull_request: + branches: [ "main"] + push: + branches: [ "main", "ci"] + paths-ignore: + - 'README.md' + - 'docs/**' +jobs: + build-release: + name: Build Release + uses: ./.github/workflows/build.yml + with: + cmake-preset: x86-release + upload-artifact-dll: release-dll + upload-artifact-vdf: release-vdf \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1e5021c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release +permissions: write-all +on: + push: + tags: + - 'v*' +jobs: + build-release: + name: Build Release + uses: ./.github/workflows/build.yml + secrets: + SSH_KEY: ${{ secrets.NEKOBOCIK_SSH_KEY }} + with: + cmake-preset: x86-release + upload-artifact-dll: release-dll + upload-artifact-vdf: release-vdf + project-version: ${{ github.ref_name }} + push-version-commit: true + publish: + name: Publish Release + runs-on: windows-2022 + needs: + - build-release + steps: + - name: Download Release DLL + uses: actions/download-artifact@v4 + with: + name: release-dll + path: out/install/x86-release/bin/ + - name: Download Release VDF + uses: actions/download-artifact@v4 + with: + name: release-vdf + path: out/install/x86-release/ + - name: Prepare Release Files + id: prepare-release + shell: powershell + env: + GITHUB_REF: ${{ github.ref_name }} + run: | + $tag = $env:GITHUB_REF -replace '^refs/tags/', '' + Compress-Archive out/install/x86-release/bin/* zMultilogue-${tag}.zip + Copy-Item out/install/x86-release/zMultilogue.vdf zMultilogue-${tag}.vdf + $prerelease = if (-not ($tag -match '^v?(\d+\.\d+\.\d+)$')) { 'true' } else { 'false' } + echo "prerelease=${prerelease}" >> $env:GITHUB_OUTPUT + - name: Release + uses: softprops/action-gh-release@v2 + with: + token: ${{ github.token }} + generate_release_notes: true + fail_on_unmatched_files: true + draft: true + prerelease: ${{ steps.prepare-release.outputs.prerelease }} + files: | + zMultilogue-*.zip + zMultilogue-*.vdf \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e33f8c6..ac3a2b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,3 +38,18 @@ target_compile_options(zMultilogue PRIVATE /external:I ${CMAKE_BINARY_DIR}/_deps ) + +install(FILES $ "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.dll" TYPE BIN) + +configure_file("${CMAKE_SOURCE_DIR}/vdf/script.vs.in" "${CMAKE_BINARY_DIR}/script.vs") + +install(FILES $ "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}.dll" TYPE BIN) +install(FILES "${CMAKE_BINARY_DIR}/script.vs" DESTINATION "${CMAKE_INSTALL_PREFIX}") +install(SCRIPT "${CMAKE_SOURCE_DIR}/vdf/vdf.cmake") +install(CODE "execute_process(COMMAND ${CMAKE_SOURCE_DIR}/vdf/GothicVDFS.exe /B \"${CMAKE_INSTALL_PREFIX}/script.vs\" WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")") + +string(REPLACE "build" "install" INSTALL_DIR "${CMAKE_BINARY_DIR}") +add_custom_target(${CMAKE_PROJECT_NAME}_vdf ALL + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${INSTALL_DIR} + DEPENDS ${CMAKE_PROJECT_NAME} + COMMENT "Run install to build VDF") \ No newline at end of file diff --git a/set-version.ps1 b/set-version.ps1 new file mode 100644 index 0000000..a02eb6f --- /dev/null +++ b/set-version.ps1 @@ -0,0 +1,33 @@ +$version = $args[0] + +if ($version -match 'rollback') { + if (Test-Path ./CMakeLists.txt.bak -PathType Leaf) { + Remove-Item CMakeLists.txt -Force + Move-Item CMakeLists.txt.bak CMakeLists.txt + Write-Host "CMakeLists.txt.bak does not exist. Cannot rollback." + } else { + Write-Host "CMakeLists.txt.bak does not exist. Cannot rollback." + exit 2 + } + exit 0 +} + +if (-not ($version -match '^v?(\d+\.\d+\.\d+)(-[a-z0-9]+)?')) { + Write-Host "Version must follow format: 1.2.3 or v1.2.3 or 1.2.3-alpha" + Write-Host "Usage: set-version.ps1 [version]" + exit 1 +} + +if (Test-Path ./CMakeLists.txt.bak -PathType Leaf) { + Write-Host "CMakeLists.txt.bak exists. Delete this file to set new version." + exit 3 +} + +$version = $version -replace '^v', '' +$cmakeVersion = $version -replace '-[a-z0-9]+$', '' +Write-Host "Setting version to $version" + +Copy-Item CMakeLists.txt CMakeLists.txt.bak +$cmake = (Get-Content -Path ./CMakeLists.txt) -replace 'set\(PROJECT_VERSION "[^"]*"\)', "set(PROJECT_VERSION ""$version"")" +$cmake = (Get-Content -Path ./CMakeLists.txt) -replace 'set\(PROJECT_VERSION_CMAKE "[^"]*"\)', "set(PROJECT_VERSION_CMAKE ""$cmakeVersion"")" +$cmake | Set-Content -Path ./CMakeLists.txt \ No newline at end of file diff --git a/vdf/GothicVDFS.exe b/vdf/GothicVDFS.exe new file mode 100644 index 0000000..414902e Binary files /dev/null and b/vdf/GothicVDFS.exe differ diff --git a/vdf/License.txt b/vdf/License.txt new file mode 100644 index 0000000..96227a4 --- /dev/null +++ b/vdf/License.txt @@ -0,0 +1,43 @@ + +GothicVDFS 2.6 (mod) +=================== + +What for... +ŻŻŻŻŻŻŻŻŻŻŻ +This tool is intended to view, extract, and build +Virtual Disk File System (VDFS) volumes for Gothic II. + +Usage +ŻŻŻŻŻ +This simple program is self-explanatory - just use it. + +Legal Stuff +ŻŻŻŻŻŻŻŻŻŻŻ +Copyright (c) 2001-2003, Nico Bendlin +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +Note: VDFS is Copyright (c) 1994-2002, Peter Sabath / TRIACOM Software GmbH diff --git a/vdf/script.vs.in b/vdf/script.vs.in new file mode 100644 index 0000000..52d7785 --- /dev/null +++ b/vdf/script.vs.in @@ -0,0 +1,8 @@ +[BEGINVDF] +Comment=zMultilogue v${CMAKE_PROJECT_VERSION}%%Nhttps://github.com/Silver-Ore-Team/zMultilogue%%N2024 Silver Ore Team +BaseDir=vdf +VDFName=zMultilogue.vdf +[FILES] +System\Autorun\*.dll +System\*.dll +[ENDVDF] \ No newline at end of file diff --git a/vdf/vdf.cmake b/vdf/vdf.cmake new file mode 100644 index 0000000..bb2cf55 --- /dev/null +++ b/vdf/vdf.cmake @@ -0,0 +1,2 @@ +file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") +file(COPY "${CMAKE_INSTALL_PREFIX}/bin/zMultilogue.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/vdf/System/Autorun") \ No newline at end of file