From 2e84f0c03ff559251fd1f4c85574bcc6c538ef00 Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Wed, 15 Sep 2021 21:17:40 -0400 Subject: [PATCH 1/4] Remove nuget.config Modify cmake_build workflow to no longer remove automatically Remove nuget.config file from repository Signed-off-by: Emily Mabrey --- .github/workflows/cmake_build.yml | 1 - nuget.config | 24 ------------------------ 2 files changed, 25 deletions(-) delete mode 100644 nuget.config diff --git a/.github/workflows/cmake_build.yml b/.github/workflows/cmake_build.yml index abf194ec1..2cf84dd68 100644 --- a/.github/workflows/cmake_build.yml +++ b/.github/workflows/cmake_build.yml @@ -200,7 +200,6 @@ jobs: - name: "Authenticate CI to Github Packages" if: github.repository_owner == 'tenacityteam' run: | - rm ./nuget.config nuget sources add -Name tenacityteam_github_auto -Source https://nuget.pkg.github.com/tenacityteam/index.json -Username tenacityteam -Password ${{ secrets.GITHUB_TOKEN }} -StorePasswordInClearText -ForceEnglishOutput -NonInteractive nuget setapikey ${{ secrets.GITHUB_TOKEN }} -Source tenacityteam_github_auto -ForceEnglishOutput -NonInteractive echo "VCPKG_BINARY_SOURCES=clear;nuget,tenacityteam_github_auto,readwrite;" >> ${GITHUB_ENV} diff --git a/nuget.config b/nuget.config deleted file mode 100644 index f086ec78d..000000000 --- a/nuget.config +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - From 70eca6b9aa501fbea73f356e55844581f7a6a109 Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Wed, 15 Sep 2021 21:21:37 -0400 Subject: [PATCH 2/4] Add nuget.config to .gitignore Prevent leaking PAT in a place where GH can see it and revoke it Signed-off-by: Emily Mabrey --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ca58ea661..de18975d4 100644 --- a/.gitignore +++ b/.gitignore @@ -219,3 +219,6 @@ vcpkg_installed # Flatpak !packaging/** + +# Prevent accidentally uploading complete local PAT +nuget.config From 0f861b97b0b1514fa0f212086d74fbfc1f96e127 Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Wed, 15 Sep 2021 21:59:13 -0400 Subject: [PATCH 3/4] Add automatic local nuget config CMake now automatically generates `nuget.config` with a read-only PAT Signed-off-by: Emily Mabrey --- CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ nuget.config.in | 6 ++++++ 2 files changed, 36 insertions(+) create mode 100644 nuget.config.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 7da780ddf..134f5ee64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/nuget.config.in b/nuget.config.in new file mode 100644 index 000000000..f985ec7c0 --- /dev/null +++ b/nuget.config.in @@ -0,0 +1,6 @@ + + + + + + From 7085e096cb6692053d655f36d99d75af848dfee8 Mon Sep 17 00:00:00 2001 From: Emily Mabrey Date: Mon, 20 Sep 2021 23:28:35 -0400 Subject: [PATCH 4/4] Resume using default vcpkg binary source This change prevents requring vcpkg downloads twice Signed-off-by: Emily Mabrey --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 134f5ee64..8ea797684 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ if( VCPKG ) set( ENV{VCPKG_DISABLE_METRICS} true ) if( NOT DEFINED ENV{VCPKG_BINARY_SOURCES} ) - set( ENV{VCPKG_BINARY_SOURCES} "clear;nuget,tenacityteam_github_auto,read;" ) + set( ENV{VCPKG_BINARY_SOURCES} "clear;default;nuget,tenacityteam_github_auto,read;" ) endif() set( ENV{VCPKG_FEATURE_FLAGS} "-compilertracking,manifests,registries,versions" )