mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
Attempt to get the correct PR commit hash (#10900)
* Attempt to get the correct PR commit hash * Add commit hash to flatpak * Use given hash if `git_commit_hash` env variable is present
This commit is contained in:
3
.github/workflows/build_all.yml
vendored
3
.github/workflows/build_all.yml
vendored
@@ -97,12 +97,15 @@ jobs:
|
|||||||
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
||||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
ver="PR-${{ github.event.number }}"
|
ver="PR-${{ github.event.number }}"
|
||||||
|
git_commit_hash="${{ github.event.pull_request.head.sha }}"
|
||||||
else
|
else
|
||||||
ver=V$ver_pure
|
ver=V$ver_pure
|
||||||
|
git_commit_hash=""
|
||||||
fi
|
fi
|
||||||
echo "ver=$ver" >> $GITHUB_ENV
|
echo "ver=$ver" >> $GITHUB_ENV
|
||||||
echo "ver_pure=$ver_pure" >> $GITHUB_ENV
|
echo "ver_pure=$ver_pure" >> $GITHUB_ENV
|
||||||
echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
||||||
|
echo "git_commit_hash=$git_commit_hash" >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
|
- uses: flathub-infra/flatpak-github-actions/flatpak-builder@master
|
||||||
with:
|
with:
|
||||||
|
|||||||
6
.github/workflows/build_orca.yml
vendored
6
.github/workflows/build_orca.yml
vendored
@@ -47,12 +47,15 @@ jobs:
|
|||||||
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
ver_pure=$(grep 'set(SoftFever_VERSION' version.inc | cut -d '"' -f2)
|
||||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
ver="PR-${{ github.event.number }}"
|
ver="PR-${{ github.event.number }}"
|
||||||
|
git_commit_hash="${{ github.event.pull_request.head.sha }}"
|
||||||
else
|
else
|
||||||
ver=V$ver_pure
|
ver=V$ver_pure
|
||||||
|
git_commit_hash=""
|
||||||
fi
|
fi
|
||||||
echo "ver=$ver" >> $GITHUB_ENV
|
echo "ver=$ver" >> $GITHUB_ENV
|
||||||
echo "ver_pure=$ver_pure" >> $GITHUB_ENV
|
echo "ver_pure=$ver_pure" >> $GITHUB_ENV
|
||||||
echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
echo "date=$(date +'%Y%m%d')" >> $GITHUB_ENV
|
||||||
|
echo "git_commit_hash=$git_commit_hash" >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Get the version and date on Windows
|
- name: Get the version and date on Windows
|
||||||
@@ -65,16 +68,19 @@ jobs:
|
|||||||
|
|
||||||
if ($eventName -eq 'pull_request') {
|
if ($eventName -eq 'pull_request') {
|
||||||
$ver = "PR" + $prNumber
|
$ver = "PR" + $prNumber
|
||||||
|
$git_commit_hash = "${{ github.event.pull_request.head.sha }}"
|
||||||
} else {
|
} else {
|
||||||
$versionContent = Get-Content version.inc -Raw
|
$versionContent = Get-Content version.inc -Raw
|
||||||
if ($versionContent -match 'set\(SoftFever_VERSION "(.*?)"\)') {
|
if ($versionContent -match 'set\(SoftFever_VERSION "(.*?)"\)') {
|
||||||
$ver = $matches[1]
|
$ver = $matches[1]
|
||||||
}
|
}
|
||||||
$ver = "V$ver"
|
$ver = "V$ver"
|
||||||
|
$git_commit_hash = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "ver=$ver" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
echo "ver=$ver" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
||||||
echo "date=$date" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
echo "date=$date" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
||||||
|
echo "git_commit_hash=$git_commit_hash" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
|
||||||
echo "date: ${{ env.date }} version: ${{ env.ver }}"
|
echo "date: ${{ env.date }} version: ${{ env.ver }}"
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
|
|||||||
@@ -69,14 +69,27 @@ endif()
|
|||||||
|
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||||
# Check current Git commit hash
|
if(DEFINED ENV{git_commit_hash} AND NOT "$ENV{git_commit_hash}" STREQUAL "")
|
||||||
execute_process(
|
message(STATUS "Specified git commit hash: $ENV{git_commit_hash}")
|
||||||
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
# Convert the given hash to short hash
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
execute_process(
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short "$ENV{git_commit_hash}"
|
||||||
)
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
||||||
|
else()
|
||||||
|
# Check current Git commit hash
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
add_definitions("-DGIT_COMMIT_HASH=\"${GIT_COMMIT_HASH}\"")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(DEFINED ENV{SLIC3R_STATIC})
|
if(DEFINED ENV{SLIC3R_STATIC})
|
||||||
|
|||||||
Reference in New Issue
Block a user