Skip to content

Commit

Permalink
refactor actions
Browse files Browse the repository at this point in the history
 - add ability to automatically create a draft release
 - change windows to windows-latest
 - unify "Unzip CLI" and "Add CLI to Path"
 - remove out folder
 - prevent unnecessary files from generating on windows
 - leave resources in platform-specific artifacts
 - unify "Package MacOS" and "Package Windows"
 - use steps outputs instead of env variables for storing version/hash
  • Loading branch information
cgytrus committed Aug 1, 2023
1 parent c643dfa commit 8f5559f
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 75 deletions.
117 changes: 58 additions & 59 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ name: Build Binaries

on:
workflow_dispatch:
inputs:
draft:
description: Create a draft release
required: false
type: boolean
default: false
push:
branches:
- '**' # every branch
Expand All @@ -15,21 +21,21 @@ jobs:
config:
- name: "Windows"
os_identifier: "win"
os: windows-2019
os: windows-latest
prefixes: ''
extra_flags: '-T host=x86 -A win32 -DGEODE_DEBUG=On'
out_paths: './bin/nightly/Geode.pdb ./bin/nightly/Geode.dll ./bin/nightly/GeodeUpdater.exe ./bin/nightly/Geode.lib ./bin/nightly/XInput9_1_0.dll'
cli_cmd: ''
package_cmd: 'makensis -WX -V3 ./installer/windows/installer.nsi'
installer_path: './installer/windows/geode-installer-win.exe'

- name: "macOS"
os_identifier: "mac"
os: macos-latest
prefixes: 'PATH="/usr/local/opt/ccache/libexec:$PATH"'
extra_flags: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DGEODE_DEBUG=On -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13"
out_paths: './bin/nightly/Geode.dylib ./bin/nightly/GeodeBootstrapper.dylib ./loader/include/link/libfmod.dylib'
cli_cmd: 'chmod +x $GITHUB_WORKSPACE/cli/geode'
installer_path: './out/geode-installer-mac.pkg'
package_cmd: './installer/mac/package.sh ./bin/nightly ./installer/mac/geode-installer-mac.pkg'
installer_path: './installer/mac/geode-installer-mac.pkg'

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
Expand Down Expand Up @@ -57,23 +63,20 @@ jobs:
fileName: "*-${{ matrix.config.os_identifier }}.zip"
tarBall: false
zipBall: false
out-file-path: "cli"
out-file-path: "cli"

- name: Unzip CLI
- name: Setup CLI
run: |
7z x "${{ github.workspace }}/cli/*-${{ matrix.config.os_identifier }}.zip" -o"${{ github.workspace }}/cli"
- name: Add CLI to Path
run: |
${{ matrix.config.cli_cmd }}
echo "${{ github.workspace }}/cli" >> $GITHUB_PATH
- name: Configure CMake
run: >
${{ matrix.config.prefixes }} cmake -B
${{ github.workspace }}/build
${{ matrix.config.extra_flags }}
-DCLI_PATH="${{ github.workspace }}/cli"
${{ matrix.config.prefixes }} cmake -B
${{ github.workspace }}/build
${{ matrix.config.extra_flags }}
-DCLI_PATH="${{ github.workspace }}/cli"
-D CMAKE_C_COMPILER_LAUNCHER=ccache
-D CMAKE_CXX_COMPILER_LAUNCHER=ccache
Expand All @@ -82,46 +85,19 @@ jobs:
cd build
cmake --build . --config RelWithDebInfo --parallel
- name: Move to output folder
shell: bash
working-directory: ${{ github.workspace }}
run: |
mkdir ./out
mv ${{ matrix.config.out_paths }} ./out
- name: Delete resource cache file
run: |
rm ./bin/nightly/resources/.geode_cache
- name: Upload resources
uses: actions/upload-artifact@v2
with:
name: resources
path: ./bin/nightly/resources
if: matrix.config.os_identifier == 'win'
run: rm ./bin/nightly/resources/.geode_cache

- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: geode-${{ matrix.config.os_identifier }}
path: ./out
path: ./bin/nightly

# Make these a script
- name: Package MacOS
run: |
cp -R ./bin/nightly/resources ./out/resources
./installer/mac/package.sh ./out ./out/geode-installer-mac.pkg
if: matrix.config.os_identifier == 'mac'

- name: Package Windows
run: |
cp -R ./bin/nightly/resources ./out/resources
iwr -useb https://aka.ms/vs/17/release/vc_redist.x86.exe -outfile './installer/windows/VC_redist.x86.exe'
makensis -WX -V3 ./installer/windows/installer.nsi
mv ./installer/windows/GeodeInstaller.exe ./installer/windows/geode-installer-win.exe
if: matrix.config.os_identifier == 'win'
- name: Package
run: ${{ matrix.config.package_cmd }}

- name: Publish Installers
- name: Publish Installer
uses: actions/upload-artifact@v2
with:
name: geode-installer-${{ matrix.config.os_identifier }}
Expand All @@ -133,35 +109,37 @@ jobs:
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v2

- name: Declare commit hash

- name: Declare version and commit hash
id: ref
shell: bash
run: |
echo "SHA_SHORT=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
echo "version=$(cat ${{ github.workspace }}/VERSION | xargs)" >> $GITHUB_OUTPUT
echo "hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ${{ github.workspace }}

- name: Move installers
run: |
mv geode-installer-mac/geode-installer-mac.pkg geode-installer-${{ env.SHA_SHORT }}-mac.pkg
mv geode-installer-win/geode-installer-win.exe geode-installer-${{ env.SHA_SHORT }}-win.exe
mv geode-installer-mac/geode-installer-mac.pkg geode-installer-${{ steps.ref.outputs.hash }}-mac.pkg
mv geode-installer-win/geode-installer-win.exe geode-installer-${{ steps.ref.outputs.hash }}-win.exe
- name: Zip MacOS artifacts
uses: vimtor/action-zip@v1
with:
files: geode-mac/Geode.dylib geode-mac/GeodeBootstrapper.dylib
dest: geode-${{ env.SHA_SHORT }}-mac.zip
dest: geode-${{ steps.ref.outputs.hash }}-mac.zip

- name: Zip Windows artifacts
uses: vimtor/action-zip@v1
with:
files: geode-win/XInput9_1_0.dll geode-win/Geode.dll geode-win/GeodeUpdater.exe geode-win/Geode.lib
dest: geode-${{ env.SHA_SHORT }}-win.zip
- name: Update Nightly Release
dest: geode-${{ steps.ref.outputs.hash }}-win.zip

- name: Update Nightly release
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -173,7 +151,28 @@ jobs:
body: |
Dev release of Geode. Will not install the resources automatically, so you should use the installers to install them.
files: |
./geode-${{ env.SHA_SHORT }}-mac.zip
./geode-${{ env.SHA_SHORT }}-win.zip
./geode-installer-${{ env.SHA_SHORT }}-mac.pkg
./geode-installer-${{ env.SHA_SHORT }}-win.exe
./geode-${{ steps.ref.outputs.hash }}-mac.zip
./geode-${{ steps.ref.outputs.hash }}-win.zip
./geode-installer-${{ steps.ref.outputs.hash }}-mac.pkg
./geode-installer-${{ steps.ref.outputs.hash }}-win.exe
- name: Create draft release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ inputs.draft }}
with:
tag_name: v${{ steps.ref.outputs.version }}
name: Geode v${{ steps.ref.outputs.version }}
body: |
TODO before publishing:
- mark if pre-release
- add changelog
- remove this
draft: true
files: |
./geode-${{ steps.ref.outputs.version }}-mac.zip
./geode-${{ steps.ref.outputs.version }}-win.zip
./geode-installer-${{ steps.ref.outputs.version }}-mac.pkg
./geode-installer-${{ steps.ref.outputs.version }}-win.exe
4 changes: 4 additions & 0 deletions installer/windows/dl-vcr.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if(Test-path VC_redist.x86.exe -PathType leaf) {
Return
}
Invoke-WebRequest -useb https://aka.ms/vs/17/release/vc_redist.x86.exe -outfile VC_redist.x86.exe
7 changes: 4 additions & 3 deletions installer/windows/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

; settings
Name "Geode"
OutFile "GeodeInstaller.exe"
OutFile "geode-installer-win.exe"
Unicode true
InstallDir "$PROGRAMFILES32\Steam\steamapps\common\Geometry Dash\" ; set default path to the most common one
XPStyle on
Expand Down Expand Up @@ -191,7 +191,7 @@

; actual code

!define BINDIR ..\..\out
!define BINDIR ..\..\bin\nightly

; installer

Expand Down Expand Up @@ -316,9 +316,10 @@ Function .onVerifyInstDir
Return
FunctionEnd

; download vc redist in compile-time
!execute "pwsh -nol -noni -nop dl-vcr.ps1"
Section "Visual Studio Runtime"
SetOutPath $INSTDIR
; needs to be downloaded from https://aka.ms/vs/17/release/vc_redist.x86.exe before compiling installer
File VC_redist.x86.exe
ExecWait "$INSTDIR\VC_redist.x86.exe /install /quiet /norestart"
Delete "$INSTDIR\VC_redist.x86.exe"
Expand Down
17 changes: 10 additions & 7 deletions loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
make_directory("${GEODE_BIN_PATH}/nightly")

# Prevent SDK from activating a loader build
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
set_target_properties(${PROJECT_NAME} PROPERTIES
PREFIX ""
OUTPUT_NAME "Geode"
# i'm going to say a slur that not a single soul has uttered in the last 200 years
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
Expand Down Expand Up @@ -194,7 +194,7 @@ if (NOT GEODE_DISABLE_PRECOMPILED_HEADERS)
endif()

# Create launcher
if (APPLE)
if (APPLE)
set_target_properties(geode-loader PROPERTIES
SYSTEM_NAME MacOS
OSX_DEPLOYMENT_TARGET 10.9
Expand All @@ -205,18 +205,21 @@ if (APPLE)

if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR GEODE_TARGET_PLATFORM STREQUAL "iOS")
add_custom_command(TARGET geode-loader
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -id \"/Library/MobileSubstrate/DynamicLibraries/Geode.dylib\"
$<TARGET_FILE:geode-loader>)
POST_BUILD COMMAND
${CMAKE_INSTALL_NAME_TOOL} -id \"/Library/MobileSubstrate/DynamicLibraries/Geode.dylib\"
$<TARGET_FILE:geode-loader>)
endif()
elseif (WIN32)
add_subdirectory(launcher/windows)

target_link_libraries(${PROJECT_NAME} dbghelp)

# disable warnings about CCNode::setID
if (MSVC)
# disable warnings about CCNode::setID
target_link_options(${PROJECT_NAME} PUBLIC /ignore:4217)

# disable outputting .exp file
target_link_options(${PROJECT_NAME} PRIVATE /NOEXP)
endif()
endif()

Expand Down
14 changes: 8 additions & 6 deletions loader/launcher/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ cmake_minimum_required(VERSION 3.3.0)
add_library(ProxyLoader SHARED proxyLoader.c)
target_compile_features(ProxyLoader PUBLIC cxx_std_17)
set_target_properties(ProxyLoader PROPERTIES
PREFIX ""
PREFIX ""
OUTPUT_NAME "XInput9_1_0"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
Expand All @@ -27,10 +25,8 @@ target_link_libraries(ProxyLoader PRIVATE fake-geode-loader)
add_executable(Updater Updater.cpp)
target_compile_features(Updater PUBLIC cxx_std_17)
set_target_properties(Updater PROPERTIES
PREFIX ""
PREFIX ""
OUTPUT_NAME "GeodeUpdater"
RUNTIME_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${GEODE_BIN_PATH}/nightly"
Expand All @@ -45,3 +41,9 @@ set_target_properties(Updater PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${GEODE_BIN_PATH}/nightly"
)
target_link_libraries(Updater PUBLIC ghc_filesystem)

if (MSVC)
target_link_options(fake-geode-loader PRIVATE /NOIMPLIB /NOEXP /DEBUG:NONE)
target_link_options(ProxyLoader PRIVATE /NOIMPLIB /NOEXP /DEBUG:NONE)
target_link_options(Updater PRIVATE /DEBUG:NONE)
endif()

0 comments on commit 8f5559f

Please sign in to comment.