Add publish ci [skip ci]

This commit is contained in:
halx99 2023-12-20 20:30:02 +08:00
parent 8902d48a5b
commit fa08bc89bb
3 changed files with 128 additions and 2 deletions

46
.github/workflows/publish.yml vendored Normal file
View File

@ -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

View File

@ -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

71
tools/ci/make-pkg.ps1 Normal file
View File

@ -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}
}