1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Merge pull request from tenacityteam/emabrey/vcpkg-setapikey-poc

Enable Nuget caching locally

Signed-off-by: Emily Mabrey <emabrey@tenacityaudio.org>
Reference-to: https://github.com/tenacityteam/tenacity/pull/629
This commit is contained in:
Emily Mabrey 2021-09-21 19:52:47 -04:00 committed by GitHub
commit cf6ce76ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 26 deletions

View File

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

3
.gitignore vendored
View File

@ -219,3 +219,6 @@ vcpkg_installed
# Flatpak
!packaging/**
# Prevent accidentally uploading complete local PAT
nuget.config

View File

@ -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" )
@ -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()

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="defaultPushSource" value="https://nuget.pkg.github.com/tenacityteam/index.json" />
</config>
<packageSources>
<add key="tenacityteam_github_auto" value="https://nuget.pkg.github.com/tenacityteam/index.json" />
</packageSources>
<packageSourceCredentials>
<tenacityteam_github_auto>
<add key="Username" value="tenacityteamci" />
<add key="Password" value="Z2hwX1pkWG9YZnR4RFRWMjBVakFtSUwyTXc5NWtja2hibzBobWlZeg==" />
</tenacityteam_github_auto>
</packageSourceCredentials>
<apikeys>
<add key="https://nuget.pkg.github.com/tenacityteam/index.json" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAUqERagW7+Eu+K0Mct8Lx1QAAAAACAAAAAAAQZgAAAAEAACAAAABgLxr6r/iMxsCDAsoK6EMR0pQlfBfLa2ETAzyCYf8eGgAAAAAOgAAAAAIAACAAAAD+yqdTYe/0Sy9Gmwn5sdaXDh1Bb2I7e9MRDX5HnS1mDDAAAAAU2YvFeiD/IhDcj84qHDE2QUcGsiVCRWecyHvUuedqqMxp5fHj65ZsXj5TPpuYafhAAAAAzx0UqJezLSUsHGwGwctzQvrz0CDNdbUHYXyAI/GGh6lbGv0k3yGJTpF9LFoUvOGQz1mvneSE0NHZAjkMGLuMAw==" />
</apikeys>
</configuration>

6
nuget.config.in Normal file
View File

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