vcpkg Update #53
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: vcpkg Update | |
concurrency: | |
group: vcpkg-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
workflow_dispatch: | |
schedule: | |
# Weekly on Friday at 2:00 a.m. | |
- cron: '0 2 * * 5' | |
jobs: | |
vcpkg-packages: | |
# Checks for new vcpkg version and tries to build the update package versions | |
# On success it updates the vcpkg_ref file so the main builds use the cache | |
# with the latest version. | |
strategy: | |
matrix: | |
arch: [x64, x86] | |
name: Build vcpkg packages for ${{ matrix.arch }} | |
runs-on: windows-2022 | |
env: | |
VCPKG_ROOT: C:\vcpkg | |
VCPKG_TARGET_TRIPLET: ${{ matrix.arch }}-windows-static | |
outputs: | |
result-x64: ${{ steps.build.outputs.result-x64 }} | |
result-x86: ${{ steps.build.outputs.result-x86 }} | |
vcpkg_ref: ${{ steps.prepare.outputs.vcpkg_ref }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Get vcpkg version | |
id: prepare | |
run: | | |
pushd ${{ env.VCPKG_ROOT }} | |
HEAD=$(git rev-parse --short HEAD) | |
popd | |
echo "Current HEAD is $HEAD" | |
echo "vcpkg_key=${{ hashFiles( './install-dependencies.sh' ) }}-${HEAD}" >> $GITHUB_OUTPUT | |
# Test newest toolset | |
toolset=$(curl https://raw.githubusercontent.com/actions/runner-images/main/images/windows/toolsets/toolset-2022.json | \ | |
jq '.visualStudio.workloads[] | capture("Component\\.VC\\.(?<v>[0-9]+\\.[0-9]+)(\\.[0-9]+){2}\\.x86\\.x64") | .v' | \ | |
sort -u | tail -n 1 | tr -d '"') | |
echo "Current toolset is ${toolset}" | |
echo "toolset=${toolset}" >> $GITHUB_OUTPUT | |
echo "vcpkg_ref=\"$HEAD ${toolset}\"" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Check whether cache exists | |
id: lookup | |
uses: actions/cache@v4 | |
with: | |
# Explicit path here because env is overridden by msvc-dev-cmd | |
path: C:\vcpkg\installed | |
key: | | |
${{ steps.prepare.outputs.vcpkg_key }}-${{ matrix.arch }} | |
- name: Building packages | |
if: steps.lookup.outputs.cache-hit != 'true' | |
run: | | |
./install-dependencies.sh vcpkg --triplet=${{ env.VCPKG_TARGET_TRIPLET }} | |
shell: bash | |
- name: Configure MSVC development console | |
if: steps.lookup.outputs.cache-hit != 'true' | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: ${{ matrix.arch }} | |
toolset: ${{ steps.prepare.outputs.toolset }} | |
- name: Compiler | |
id: build | |
if: steps.lookup.outputs.cache-hit != 'true' | |
env: | |
VCPKG_ROOT: C:\vcpkg | |
run: | | |
mkdir $env:GITHUB_WORKSPACE\build | |
cd $env:GITHUB_WORKSPACE\build | |
cmake.exe -G "NMake Makefiles" .. -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DOPTION_BUILD_WEBSITE_TOOLS=OFF -DOPTION_BUILD_TESTS=ON -DOPTION_ASAN=OFF -DOPTION_BUILD_CODECHECK=OFF -DOPTION_BUILD_WINSTATIC=ON -DOPTION_USE_GLBINDING=ON -DOPTION_FORCE_EMBEDDED_MINIZIP=ON | |
nmake | |
echo "result-${{ matrix.arch }}=true" >> $env:GITHUB_OUTPUT | |
update: | |
needs: vcpkg-packages | |
if: ${{ github.repository == 'widelands/widelands' && needs.vcpkg-packages.outputs.result-x64 && needs.vcpkg-packages.outputs.result-x86 }} | |
name: Commit new version | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
persist-credentials: false | |
- name: Update vcpkg_ref | |
run: | | |
echo "Updating to ${{ needs.vcpkg-packages.outputs.vcpkg_ref }}" | |
echo "${{ needs.vcpkg-packages.outputs.vcpkg_ref }}" > .github/scripts/vcpkg_ref | |
if [ -n "$(git status -s)" ]; then | |
git config --global user.name "The Widelands Build Bot" | |
git config --global user.email "[email protected]" | |
git add .github/scripts/vcpkg_ref | |
git commit -m "Update vcpkg version" | |
git push "https://bunnybot:${{ secrets.WIDELANDS_FORMAT_TOKEN }}@github.com/${{ github.repository }}.git" master | |
fi | |
shell: bash |