diff --git a/.github/actions/vcpkg-cache/action.yml b/.github/actions/vcpkg-cache/action.yml new file mode 100644 index 0000000..2134f9c --- /dev/null +++ b/.github/actions/vcpkg-cache/action.yml @@ -0,0 +1,41 @@ +name: 'Setup vcpkg cache' +inputs: + vcpkg-root-path: + description: 'Path where to install vcpkg' + required: true + type: string +runs: + using: "composite" + steps: + - name: Install vcpkg + shell: bash + run: | + echo "Installing vcpkg" + + echo "VCPKG_INSTALLATION_ROOT=${{ inputs.vcpkg-root-path }}" >> $GITHUB_ENV + echo "PATH=${{ inputs.vcpkg-root-path }}:$PATH" >> $GITHUB_ENV + echo "VCPKG_DEFAULT_BINARY_CACHE=${{ inputs.vcpkg-root-path }}/.cache" >> $GITHUB_ENV + which vcpkg + + git clone https://github.com/microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh --disableMetrics + mkdir ${{ inputs.vcpkg-root-path }}/.cache + + - name: Env + shell: bash + run: | + echo "Vcpkg is installed at: $VCPKG_INSTALLATION_ROOT" + #echo "======================" + #env|sort + + # Cache vcpkg + - name: Cache vcpkg + id: cache-vcpkg + uses: actions/cache@v4 + with: + path: | + ${{ inputs.vcpkg-root-path }}/.cache + key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-vcpkg- diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e325364..0ef0407 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,16 +3,17 @@ run-name: Build No.${{ github.run_number }} on behalf of ${{ github.actor }} on: workflow_dispatch: - #pull_request: - # types: [opened, reopened, synchronize] + pull_request: + types: [opened, reopened, synchronize] push: branches: [main] jobs: build: - env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + + env: + VCPKG_INSTALLATION_ROOT: ${{ github.workspace }}/vcpkg runs-on: ${{ matrix.os }} strategy: @@ -28,7 +29,7 @@ jobs: if: ${{ matrix.platform == 'linux' }} run: | gcc --version - sudo apt-get update + #sudo apt-get update - name: Install Windows Prerequisites if: ${{ matrix.platform == 'windows' }} @@ -38,17 +39,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Export GitHub Actions cache environment variables - uses: actions/github-script@v7 + - name: Setup cache + uses: ./.github/actions/vcpkg-cache with: - debug: true - script: | - core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); - core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - - name: vcpkg install - run: | - vcpkg install + vcpkg-root-path: ${{ env.VCPKG_INSTALLATION_ROOT }} - name: Configure project run: |