diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..14b502b0e8 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +name: publish + +on: + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + version: + # actions run ID + description: 'Please input release version' + # Default value if no value is explicitly provided + default: '' + # Input has to be provided for the workflow to run + required: false +jobs: + publish: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + + - name: Make package + id: make_pkg + + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + shell: pwsh + run: | + .\build.ps1 -p win32 -xc '-DAX_WITH_LZ4=ON,-DAX_WITH_CARES=ON,-DAX_WITH_YAML_CPP=ON,-DAX_WITH_KCP=ON,-DAX_WITH_OBOE=ON' -c + .\tools\ci\make-pkg.ps1 -version "${{ github.event.inputs.version }}" + ls + + - name: Publish to github release page + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ steps.make_pkg.outputs.release_tag }} + name: ${{ steps.make_pkg.outputs.release_tag }} + files: ${{ steps.make_pkg.outputs.release_pkg }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_REPOSITORY: simdsoft/axmol \ No newline at end of file diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index d0e2343568..de7e1725df 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -195,10 +195,19 @@ function(ax_add_3rd source_dir) set(${OPTION_KEY} "${OPTION_VALUE}" CACHE BOOL "" FORCE) endforeach() + set(binary_dir "") + if(IS_ABSOLUTE ${source_dir}) + string(LENGTH "${_AX_ROOT}/cache/" _offset) + string(LENGTH ${source_dir} _len) + math(EXPR _len "${_len} - ${_offset}" OUTPUT_FORMAT DECIMAL) + string(SUBSTRING ${source_dir} ${_offset} ${_len} _path) + set(binary_dir "${ENGINE_BINARY_PATH}/thirdparty/${_path}") + endif() + if (opt_EXCLUDE_FROM_ALL) - add_subdirectory(${source_dir} EXCLUDE_FROM_ALL) + add_subdirectory(${source_dir} ${binary_dir} EXCLUDE_FROM_ALL) else() - add_subdirectory(${source_dir}) + add_subdirectory(${source_dir} ${binary_dir}) endif() if(NOT opt_TARGETS) # if opt_TARGETS not specified use source_dir as target name diff --git a/tools/ci/make-pkg.ps1 b/tools/ci/make-pkg.ps1 new file mode 100644 index 0000000000..0f6a8361e4 --- /dev/null +++ b/tools/ci/make-pkg.ps1 @@ -0,0 +1,71 @@ +param( + $version = $null +) +$AX_ROOT = (Resolve-Path $PSScriptRoot/../../).Path + +if(!$version) { + $axver_file = (Resolve-Path $AX_ROOT/core/axmolver.h.in).Path + $axver_content = $(Get-Content -Path $axver_file) + function parse_axver($part) { + return ($axver_content | Select-String "#define AX_VERSION_$part").Line.Split(' ')[2] + } + function get_full_version() { + $axver = "$(parse_axver 'MAJOR').$(parse_axver 'MINOR').$(parse_axver 'PATCH')" + + $git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source + if($git_prog) { + Write-Host "Found git: $git_prog" + $branchName = $(git -C $AX_ROOT branch --show-current) + if ($branchName -eq 'dev') { + $commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD) + $axver += "-$commitHash" + } + } + return $axver + } + $version = get_full_version +} + +Push-Location $AX_ROOT + +# collection files +$excludes = @( + '.xs' + '.vs' + '.vscode' + 'build_*' + 'build' + '.github' + 'tmp' + 'temp' + 'tools' + '*.zip' + 'out' +) + +$axmol_files = Get-ChildItem $AX_ROOT -Exclude $excludes + +# $tools_files = Get-ChildItem $(Join-Path $AX_ROOT 'tools') -Exclude 'external' +# $axmol_files += $tools_files + +# $tools_external_files = Get-ChildItem $(Join-Path $AX_ROOT 'tools/external') -Exclude '*.zip' +# $axmol_files += $tools_external_files + +$pkg_file_name = "axmol-$version.zip" +$pkg_file_path = $(Join-Path $AX_ROOT $pkg_file_name) + +$compress = @{ + Path = $axmol_files + CompressionLevel = "Optimal" + DestinationPath = $pkg_file_path +} + +Write-Host "Creating package $pkg_file_path ..." +Compress-Archive @compress -PassThru + +Pop-Location + +if($env:GITHUB_ACTIONS -eq 'true') { + echo "release_tag=v$version" >> ${env:GITHUB_OUTPUT} + echo "release_pkg=$pkg_file_name" >> ${env:GITHUB_OUTPUT} +}