Skip to content

Commit 15e0328

Browse files
authored
ci : limit write permission to only the release step + fixes (#13392)
* ci : limit write permission to only the release step * fix win cuda file name * fix license file copy on multi-config generators
1 parent f05a6d7 commit 15e0328

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
env:
18-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
1918
GGML_NLOOP: 3
2019
GGML_N_THREADS: 1
2120
LLAMA_LOG_COLORS: 1

.github/workflows/release.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
1717
cancel-in-progress: true
1818

19-
# Fine-grant permission
20-
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
21-
permissions:
22-
contents: write # for creating release
23-
2419
env:
2520
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
2621
CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
@@ -416,28 +411,27 @@ jobs:
416411
CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
417412
run: |
418413
cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
419-
7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
414+
7z a llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
420415
421416
- name: Upload artifacts
422417
uses: actions/upload-artifact@v4
423418
with:
424-
path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
425-
name: llama-bin-win-cu${{ matrix.cuda }}-x64.zip
419+
path: llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip
420+
name: llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
426421

427422
- name: Copy and pack Cuda runtime
428-
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
429423
run: |
430424
echo "Cuda install location: ${{ env.CUDA_PATH }}"
431425
$dst='.\build\bin\cudart\'
432426
robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
433427
robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
434-
7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
428+
7z a cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip $dst\*
435429
436430
- name: Upload Cuda runtime
437431
uses: actions/upload-artifact@v4
438432
with:
439-
path: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
440-
name: cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
433+
path: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
434+
name: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
441435

442436
windows-sycl:
443437
runs-on: windows-latest
@@ -646,6 +640,11 @@ jobs:
646640
release:
647641
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
648642

643+
# Fine-grant permission
644+
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
645+
permissions:
646+
contents: write # for creating release
647+
649648
runs-on: ubuntu-latest
650649

651650
needs:

CMakeLists.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,3 @@ configure_file(cmake/llama.pc.in
252252

253253
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/llama.pc"
254254
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
255-
256-
#
257-
# copy the license files
258-
#
259-
260-
# Check if running in GitHub Actions
261-
if(DEFINED ENV{GITHUB_ACTIONS} AND "$ENV{GITHUB_ACTIONS}" STREQUAL "true")
262-
message(STATUS "Running inside GitHub Actions - copying license files")
263-
264-
# Copy all files from licenses/ to build/bin/
265-
file(GLOB LICENSE_FILES "${CMAKE_SOURCE_DIR}/licenses/*")
266-
foreach(LICENSE_FILE ${LICENSE_FILES})
267-
get_filename_component(FILENAME ${LICENSE_FILE} NAME)
268-
configure_file(${LICENSE_FILE} "${CMAKE_BINARY_DIR}/bin/${FILENAME}" COPYONLY)
269-
endforeach()
270-
endif()
271-

common/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,27 @@ endif ()
144144
target_include_directories(${TARGET} PUBLIC .)
145145
target_compile_features (${TARGET} PUBLIC cxx_std_17)
146146
target_link_libraries (${TARGET} PRIVATE ${LLAMA_COMMON_EXTRA_LIBS} PUBLIC llama Threads::Threads)
147+
148+
149+
#
150+
# copy the license files
151+
#
152+
153+
# Check if running in GitHub Actions
154+
if (DEFINED ENV{GITHUB_ACTIONS} AND "$ENV{GITHUB_ACTIONS}" STREQUAL "true")
155+
message(STATUS "Running inside GitHub Actions - copying license files")
156+
157+
# Copy all files from licenses/ to build/bin/
158+
file(GLOB LICENSE_FILES "${CMAKE_SOURCE_DIR}/licenses/*")
159+
foreach(LICENSE_FILE ${LICENSE_FILES})
160+
get_filename_component(FILENAME ${LICENSE_FILE} NAME)
161+
add_custom_command(
162+
POST_BUILD
163+
TARGET ${TARGET}
164+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
165+
"${LICENSE_FILE}"
166+
"$<TARGET_FILE_DIR:llama>/${FILENAME}"
167+
COMMENT "Copying ${FILENAME} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
168+
message(STATUS "Copying ${LICENSE_FILE} to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FILENAME}")
169+
endforeach()
170+
endif()

0 commit comments

Comments
 (0)