Browse Source
Add automatic local nuget config
CMake now automatically generates `nuget.config` with a read-only PAT
Signed-off-by: Emily Mabrey <emabrey@tenacityaudio.org>
pull/629/head
Emily Mabrey
2 years ago
No known key found for this signature in database
GPG Key ID: 6F4EF47256A1B7DC
2 changed files with
36 additions and
0 deletions
-
CMakeLists.txt
-
nuget.config.in
|
|
@ -144,6 +144,36 @@ if( VCPKG ) |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
if( NOT DEFINED ENV{CI} AND NOT EXISTS ${CMAKE_SOURCE_DIR}/nuget.config AND (EXISTS ${VCPKG_ROOT}/vcpkg OR EXISTS ${VCPKG_ROOT}/vcpkg.exe) ) |
|
|
|
|
|
|
|
execute_process( |
|
|
|
COMMAND vcpkg fetch nuget |
|
|
|
WORKING_DIRECTORY ${VCPKG_ROOT} |
|
|
|
OUTPUT_VARIABLE NUGET_EXECUTABLE |
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE |
|
|
|
) |
|
|
|
|
|
|
|
message( STATUS "Automatically setting Nuget api key to allow nuget cache usage locally" ) |
|
|
|
|
|
|
|
file( READ ${CMAKE_SOURCE_DIR}/nuget.config.in NUGET_CONFIG_CONTENT ) |
|
|
|
file( WRITE ${CMAKE_SOURCE_DIR}/nuget.config ${NUGET_CONFIG_CONTENT} ) |
|
|
|
|
|
|
|
set( GITHUB_PACKAGES_TOKEN_SUFFIX "ZdXoXftxDTV20UjAmIL2Mw95kckhbo0hmiYz" ) |
|
|
|
|
|
|
|
execute_process( |
|
|
|
COMMAND "${NUGET_EXECUTABLE}" sources add -Name tenacityteam_github_auto -Source https://nuget.pkg.github.com/tenacityteam/index.json -Config nuget.config -Username tenacityteamci -Password ghp_${GITHUB_PACKAGES_TOKEN_SUFFIX} -StorePasswordInClearText -ForceEnglishOutput -NonInteractive |
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
|
|
|
) |
|
|
|
|
|
|
|
execute_process( |
|
|
|
COMMAND "${NUGET_EXECUTABLE}" setapikey -Source tenacityteam_github_auto -Config nuget.config ghp_${GITHUB_PACKAGES_TOKEN_SUFFIX} |
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
|
|
|
OUTPUT_VARIABLE SETAPI_KEY_RESULT |
|
|
|
ERROR_VARIABLE SETAPI_KEY_RESULT |
|
|
|
) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
if( NOT DEFINED VCPKG_OVERLAY_PORTS ) |
|
|
|
set( VCPKG_OVERLAY_PORTS "${VCPKG_ROOT}/overlay/ports" ) |
|
|
|
endif() |
|
|
|
|
|
@ -0,0 +1,6 @@ |
|
|
|
<?xml version="1.0" encoding="utf-8" ?> |
|
|
|
<configuration> |
|
|
|
<config> |
|
|
|
<add key="defaultPushSource" value="https://nuget.pkg.github.com/tenacityteam/index.json"/> |
|
|
|
</config> |
|
|
|
</configuration> |