ci: unify vcpkg jobs

This commit is contained in:
Bruno Alexandre Rosa 2025-10-22 15:42:52 -03:00
parent e4d256790f
commit 5cca21b6c8

View file

@ -239,54 +239,64 @@ jobs:
GH_TOKEN: ${{github.token}} GH_TOKEN: ${{github.token}}
run: gh attestation verify ${{steps.build.outputs.path}} -R Cockatrice/Cockatrice run: gh attestation verify ${{steps.build.outputs.path}} -R Cockatrice/Cockatrice
build-macos: build-vcpkg:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- target: 13 - os: macOS
target: 13
runner: macos-15-intel
soc: Intel soc: Intel
os: macos-15-intel
xcode: "16.4" xcode: "16.4"
type: Release type: Release
make_package: 1 make_package: 1
override_target: 13 override_target: 13
- target: 14 - os: macOS
target: 14
runner: macos-14
soc: Apple soc: Apple
os: macos-14
xcode: "15.4" xcode: "15.4"
type: Release type: Release
make_package: 1 make_package: 1
- target: 15 - os: macOS
target: 15
runner: macos-15
soc: Apple soc: Apple
os: macos-15
xcode: "16.4" xcode: "16.4"
type: Release type: Release
make_package: 1 make_package: 1
- target: 15 - os: macOS
target: 15
runner: macos-15
soc: Apple soc: Apple
os: macos-15
xcode: "16.4" xcode: "16.4"
type: Debug type: Debug
name: macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} - os: Windows
target: 7
runner: windows-2022
make_package: 1
qt_version: 5.15.*
- os: Windows
target: 10
runner: windows-2022
make_package: 1
qt_version: 6.6.*
name: ${{ matrix.os }} ${{ matrix.target }}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }}
needs: configure needs: configure
runs-on: ${{matrix.os}} runs-on: ${{ matrix.runner }}
continue-on-error: ${{matrix.allow-failure == 'yes'}}
env: env:
# Common parameters for all macOS builds # Common parameters for all builds
QT_VERSION: 6.6.* QT_VERSION: ${{ matrix.qt_version || '6.6.*' }}
QT_ARCH: clang_64 QT_ARCH: ${{ matrix.os == 'macOS' && 'clang_64' || 'win64_msvc2019_64' }}
QT_MODULES: "qtimageformats qtmultimedia qtwebsockets" QT_MODULES: ${{ matrix.qt_version != '5.15.*' && 'qtimageformats qtmultimedia qtwebsockets' || '' }}
# Build-specific environment variables CACHE_QT: ${{ matrix.os != 'macOS' && 'true' || 'false' }} # qt caches take too much space for macOS (1.1Gi)
CCACHE_DIR: ${{github.workspace}}/.ccache/${{matrix.os}}-${{matrix.type}}
CCACHE_SIZE: 500M
DEVELOPER_DIR:
/Applications/Xcode_${{matrix.xcode}}.app/Contents/Developer
CMAKE_GENERATOR: 'Ninja'
steps: steps:
- name: Checkout - name: Checkout
@ -294,24 +304,31 @@ jobs:
with: with:
submodules: recursive submodules: recursive
- name: Add msbuild to PATH
if: matrix.os == 'Windows'
id: add-msbuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
# Using jianmingyong/ccache-action to setup ccache without using brew # Using jianmingyong/ccache-action to setup ccache without using brew
# It tries to download a binary of ccache from GitHub Release and falls back to building from source if it fails # It tries to download a binary of ccache from GitHub Release and falls back to building from source if it fails
- name: Setup ccache - name: Setup ccache
if: matrix.os == 'macOS'
uses: jianmingyong/ccache-action@v1 uses: jianmingyong/ccache-action@v1
with: with:
install-type: "binary" install-type: "binary"
ccache-key-prefix: ccache-${{matrix.os}}-${{matrix.soc}}-${{matrix.type}} ccache-key-prefix: ccache-${{ matrix.runner }}-${{ matrix.soc }}-${{ matrix.type }}
max-size: 500M
gh-token: ${{ secrets.GITHUB_TOKEN }} gh-token: ${{ secrets.GITHUB_TOKEN }}
# Using jurplel/install-qt-action to install Qt without using brew - name: Install Qt ${{ env.QT_VERSION }}
# qt build using vcpkg either just fails or takes too long to build
- name: Install Qt ${{env.QT_VERSION}}
uses: jurplel/install-qt-action@v4 uses: jurplel/install-qt-action@v4
with: with:
cache: false # qt caches take too much space for macOS (1.1Gi) version: ${{ env.QT_VERSION }}
version: ${{env.QT_VERSION}} arch: ${{ env.QT_ARCH }}
arch: ${{env.QT_ARCH}} modules: ${{ env.QT_MODULES }}
modules: ${{env.QT_MODULES}} cache: ${{ env.CACHE_QT }}
- name: Setup vcpkg cache - name: Setup vcpkg cache
id: vcpkg-cache id: vcpkg-cache
@ -319,25 +336,42 @@ jobs:
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
- name: Build on Xcode ${{matrix.xcode}} - name: Configure macOS
shell: bash if: matrix.os == 'macOS'
run: |
echo "PACKAGE_SUFFIX=-macOS${{ matrix.target }}${{ matrix.soc == 'Intel' && '_Intel' || '' }}${{ matrix.type == 'Debug' && '_Debug' || '' }}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ matrix.os }}${{ matrix.target }}${{ matrix.soc == 'Intel' && '_Intel' || '' }}${{ matrix.type == 'Debug' && '_Debug' || '' }}-package" >> $GITHUB_ENV
- name: Configure Windows
if: matrix.os == 'Windows'
shell: bash # needs to be bash to export environment variables via GITHUB_ENV
run: |
echo "PACKAGE_SUFFIX=-Win${{ matrix.target }}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ matrix.os }}${{ matrix.target }}-installer" >> $GITHUB_ENV
# uses environment variables, see compile.sh for more details
- name: Build Cockatrice
id: build id: build
shell: bash
env: env:
BUILDTYPE: '${{matrix.type}}' BUILDTYPE: '${{ matrix.type }}'
MAKE_PACKAGE: '${{matrix.make_package}}' MAKE_PACKAGE: '${{ matrix.make_package }}'
PACKAGE_SUFFIX: '-macOS${{matrix.target}}_${{matrix.soc}}' CMAKE_GENERATOR: ${{ matrix.os == 'macOS' && 'Ninja' || 'Visual Studio 17 2022' }}
CMAKE_GENERATOR_PLATFORM: ${{ matrix.os == 'Windows' && 'x64' || '' }}
USE_CCACHE: ${{ matrix.os == 'macOS' && '1' || '' }}
VCPKG_DISABLE_METRICS: 1
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
# macOS-specific environment variables, will be ignored on Windows
MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }} MACOS_CERTIFICATE: ${{ secrets.PROD_MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }} MACOS_CERTIFICATE_PWD: ${{ secrets.PROD_MACOS_CERTIFICATE_PWD }}
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }} MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }} MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
CMAKE_GENERATOR: '${{env.CMAKE_GENERATOR}}' DEVELOPER_DIR: '/Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer'
VCPKG_DISABLE_METRICS: 1
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
TARGET_MACOS_VERSION: ${{ matrix.override_target }} TARGET_MACOS_VERSION: ${{ matrix.override_target }}
run: .ci/compile.sh --server --test --ccache "$CCACHE_SIZE" --vcpkg run: .ci/compile.sh --server --test --vcpkg
- name: Sign app bundle - name: Sign app bundle
if: matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null) if: matrix.os == 'macOS' && matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null)
env: env:
MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }} MACOS_CERTIFICATE_NAME: ${{ secrets.PROD_MACOS_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }} MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
@ -345,11 +379,11 @@ jobs:
if [[ -n "$MACOS_CERTIFICATE_NAME" ]] if [[ -n "$MACOS_CERTIFICATE_NAME" ]]
then then
security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain security unlock-keychain -p "$MACOS_CI_KEYCHAIN_PWD" build.keychain
/usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose ${{steps.build.outputs.path}} /usr/bin/codesign --sign="$MACOS_CERTIFICATE_NAME" --entitlements=".ci/macos.entitlements" --options=runtime --force --deep --timestamp --verbose ${{ steps.build.outputs.path }}
fi fi
- name: Notarize app bundle - name: Notarize app bundle
if: matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null) if: matrix.os == 'macOS' && matrix.make_package && (github.ref == 'refs/heads/master' || needs.configure.outputs.tag != null)
env: env:
MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }} MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }} MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
@ -365,7 +399,7 @@ jobs:
# Therefore, we create a zip file containing our app bundle, so that we can send it to the # Therefore, we create a zip file containing our app bundle, so that we can send it to the
# notarization service # notarization service
echo "Creating temp notarization archive" echo "Creating temp notarization archive"
ditto -c -k --keepParent ${{steps.build.outputs.path}} "notarization.zip" ditto -c -k --keepParent ${{ steps.build.outputs.path }} "notarization.zip"
# Here we send the notarization request to the Apple's Notarization service, waiting for the result. # Here we send the notarization request to the Apple's Notarization service, waiting for the result.
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App # This typically takes a few seconds inside a CI environment, but it might take more depending on the App
@ -377,7 +411,7 @@ jobs:
# Finally, we need to "attach the staple" to our executable, which will allow our app to be # Finally, we need to "attach the staple" to our executable, which will allow our app to be
# validated by macOS even when an internet connection is not available. # validated by macOS even when an internet connection is not available.
echo "Attach staple" echo "Attach staple"
xcrun stapler staple ${{steps.build.outputs.path}} xcrun stapler staple ${{ steps.build.outputs.path }}
fi fi
- name: Upload artifact - name: Upload artifact
@ -385,109 +419,15 @@ jobs:
if: matrix.make_package if: matrix.make_package
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: macOS${{matrix.target}}${{ matrix.soc == 'Intel' && '_Intel' || '' }}${{ matrix.type == 'Debug' && '_Debug' || '' }}-package name: ${{ env.ARTIFACT_NAME }}
path: ${{steps.build.outputs.path}} path: ${{ steps.build.outputs.path }}
if-no-files-found: error
- name: Upload to release
id: upload_release
if: matrix.make_package && needs.configure.outputs.tag != null
shell: bash
env:
GH_TOKEN: ${{github.token}}
tag_name: ${{needs.configure.outputs.tag}}
asset_path: ${{steps.build.outputs.path}}
asset_name: ${{steps.build.outputs.name}}
run: gh release upload "$tag_name" "$asset_path#$asset_name"
- name: Attest binary provenance
id: attestation
if: steps.upload_release.outcome == 'success'
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{steps.build.outputs.name}}
subject-digest: sha256:${{ steps.upload_artifact.outputs.artifact-digest }}
- name: Verify binary attestation
if: steps.attestation.outcome == 'success'
shell: bash
env:
GH_TOKEN: ${{github.token}}
run: gh attestation verify ${{steps.build.outputs.path}} -R Cockatrice/Cockatrice
build-windows:
strategy:
fail-fast: false
matrix:
include:
- target: 7
qt_version: 5.15.*
qt_arch: msvc2019_64
- target: 10
qt_version: 6.6.*
qt_arch: msvc2019_64
qt_modules: "qtimageformats qtmultimedia qtwebsockets"
name: Windows ${{matrix.target}}
needs: configure
runs-on: windows-2022
env:
CMAKE_GENERATOR: 'Visual Studio 17 2022'
steps:
- name: Add msbuild to PATH
id: add-msbuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Checkout
uses: actions/checkout@v5
with:
submodules: recursive
- name: Install Qt ${{matrix.qt_version}}
uses: jurplel/install-qt-action@v4
with:
cache: true
setup-python: true
version: ${{matrix.qt_version}}
arch: win64_${{matrix.qt_arch}}
modules: ${{matrix.qt_modules}}
- name: Setup vcpkg cache
id: vcpkg-cache
uses: TAServers/vcpkg-cache@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Cockatrice
id: build
shell: bash
env:
PACKAGE_SUFFIX: '-Win${{matrix.target}}'
CMAKE_GENERATOR: '${{env.CMAKE_GENERATOR}}'
CMAKE_GENERATOR_PLATFORM: 'x64'
QTDIR: '${{github.workspace}}\Qt\${{matrix.qt_version}}\win64_${{matrix.qt_arch}}'
VCPKG_DISABLE_METRICS: 1
VCPKG_BINARY_SOURCES: 'clear;files,${{ steps.vcpkg-cache.outputs.path }},readwrite'
# No need for --parallel flag, MTT is added in the compile script to let cmake/msbuild manage core count,
# project and process parallelism: https://devblogs.microsoft.com/cppblog/improved-parallelism-in-msbuild/
run: .ci/compile.sh --server --release --test --package
- name: Upload artifact
id: upload_artifact
uses: actions/upload-artifact@v4
with:
name: Windows${{matrix.target}}-installer
path: ${{steps.build.outputs.path}}
if-no-files-found: error if-no-files-found: error
- name: Upload pdb database - name: Upload pdb database
if: matrix.os == 'Windows'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: Windows${{matrix.target}}-debug-pdbs name: Windows${{ matrix.target }}-debug-pdbs
path: | path: |
build/cockatrice/Release/*.pdb build/cockatrice/Release/*.pdb
build/servatrice/Release/*.pdb build/servatrice/Release/*.pdb
@ -498,10 +438,10 @@ jobs:
if: needs.configure.outputs.tag != null if: needs.configure.outputs.tag != null
shell: bash shell: bash
env: env:
GH_TOKEN: ${{github.token}} GH_TOKEN: ${{ github.token }}
tag_name: ${{needs.configure.outputs.tag}} tag_name: ${{ needs.configure.outputs.tag }}
asset_path: ${{steps.build.outputs.path}} asset_path: ${{ steps.build.outputs.path }}
asset_name: ${{steps.build.outputs.name}} asset_name: ${{ steps.build.outputs.name }}
run: gh release upload "$tag_name" "$asset_path#$asset_name" run: gh release upload "$tag_name" "$asset_path#$asset_name"
- name: Attest binary provenance - name: Attest binary provenance
@ -509,12 +449,12 @@ jobs:
if: steps.upload_release.outcome == 'success' if: steps.upload_release.outcome == 'success'
uses: actions/attest-build-provenance@v3 uses: actions/attest-build-provenance@v3
with: with:
subject-name: ${{steps.build.outputs.name}} subject-name: ${{ steps.build.outputs.name }}
subject-digest: sha256:${{ steps.upload_artifact.outputs.artifact-digest }} subject-digest: sha256:${{ steps.upload_artifact.outputs.artifact-digest }}
- name: Verify binary attestation - name: Verify binary attestation
if: steps.attestation.outcome == 'success' if: steps.attestation.outcome == 'success'
shell: bash shell: bash
env: env:
GH_TOKEN: ${{github.token}} GH_TOKEN: ${{ github.token }}
run: gh attestation verify ${{steps.build.outputs.path}} -R Cockatrice/Cockatrice run: gh attestation verify ${{ steps.build.outputs.path }} -R Cockatrice/Cockatrice