Skip to content

Commit

Permalink
Merge pull request #5 from Silver-Ore-Team/ci
Browse files Browse the repository at this point in the history
Add GitHub Actions
  • Loading branch information
muczc1wek authored Oct 2, 2024
2 parents 8cd3374 + 736e95a commit cdaf774
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 0 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 "[email protected]"
git remote set-url origin [email protected]: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
18 changes: 18 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ target_compile_options(zMultilogue PRIVATE
/external:I ${CMAKE_BINARY_DIR}/_deps
)


install(FILES $<TARGET_RUNTIME_DLLS:${CMAKE_PROJECT_NAME}> "${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 $<TARGET_RUNTIME_DLLS:${CMAKE_PROJECT_NAME}> "${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")
33 changes: 33 additions & 0 deletions set-version.ps1
Original file line number Diff line number Diff line change
@@ -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
Binary file added vdf/GothicVDFS.exe
Binary file not shown.
43 changes: 43 additions & 0 deletions vdf/License.txt
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions vdf/script.vs.in
Original file line number Diff line number Diff line change
@@ -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]
2 changes: 2 additions & 0 deletions vdf/vdf.cmake
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit cdaf774

Please sign in to comment.