2023-01-28 13:32:30 +01:00
|
|
|
name: Release (Windows)
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
2023-04-25 19:43:45 +02:00
|
|
|
survey_key:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
default: ""
|
2023-01-28 13:32:30 +01:00
|
|
|
is_tag:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
windows:
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- arch: x86
|
|
|
|
host: x86
|
|
|
|
- arch: x64
|
|
|
|
host: x64
|
|
|
|
- arch: arm64
|
|
|
|
host: x64_arm64
|
|
|
|
|
2023-04-29 21:59:01 +02:00
|
|
|
name: Windows (${{ matrix.arch }})
|
2023-04-27 20:15:09 +02:00
|
|
|
|
2023-01-28 13:32:30 +01:00
|
|
|
runs-on: windows-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Download source
|
2024-01-25 22:22:33 +01:00
|
|
|
uses: actions/download-artifact@v4
|
2023-01-28 13:32:30 +01:00
|
|
|
with:
|
|
|
|
name: internal-source
|
|
|
|
|
|
|
|
- name: Unpack source
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
tar -xf source.tar.gz --strip-components=1
|
|
|
|
|
2023-08-30 20:27:15 +02:00
|
|
|
- name: Install Rust toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
|
|
|
|
- name: Enable Rust cache
|
|
|
|
uses: Swatinem/rust-cache@v2
|
|
|
|
|
2023-12-30 17:58:18 +01:00
|
|
|
- name: Setup vcpkg caching
|
2024-01-25 22:22:33 +01:00
|
|
|
uses: actions/github-script@v7
|
2023-12-30 17:58:18 +01:00
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
|
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
|
|
core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
|
|
|
|
|
2023-01-28 13:32:30 +01:00
|
|
|
- name: Install dependencies
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2023-08-30 20:27:15 +02:00
|
|
|
echo "::group::Install choco dependencies"
|
2023-01-28 13:32:30 +01:00
|
|
|
choco install pandoc
|
2023-08-30 20:27:15 +02:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Install breakpad dependencies"
|
|
|
|
cargo install dump_syms
|
|
|
|
echo "::endgroup::"
|
2023-01-28 13:32:30 +01:00
|
|
|
|
|
|
|
- name: Install MSVC problem matcher
|
|
|
|
uses: ammaraskar/msvc-problem-matcher@master
|
|
|
|
|
|
|
|
- name: Configure developer command prompt for tools
|
|
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
with:
|
|
|
|
arch: x64
|
|
|
|
|
|
|
|
- name: Build tools
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
mkdir build-host
|
|
|
|
cd build-host
|
|
|
|
|
|
|
|
echo "::group::CMake"
|
|
|
|
cmake ${GITHUB_WORKSPACE} \
|
|
|
|
-GNinja \
|
|
|
|
-DOPTION_TOOLS_ONLY=ON \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
|
|
# EOF
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Build"
|
|
|
|
cmake --build . --target tools
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Configure developer command prompt for ${{ matrix.arch }}
|
|
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
|
|
with:
|
|
|
|
arch: ${{ matrix.host }}
|
|
|
|
|
|
|
|
- name: Import code signing certificate
|
|
|
|
shell: powershell
|
|
|
|
# If this is run on a fork, there may not be a certificate set up - continue in this case
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
$tempFile = [System.IO.Path]::GetTempFileName()
|
|
|
|
$bytes = [System.Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_P12)
|
|
|
|
[IO.File]::WriteAllBytes($tempFile, $bytes)
|
|
|
|
$pwd = ConvertTo-SecureString $env:WINDOWS_CERTIFICATE_PASSWORD -AsPlainText -Force
|
|
|
|
Import-PfxCertificate -FilePath $tempFile -CertStoreLocation Cert:\CurrentUser\My -Password $pwd
|
|
|
|
Remove-Item $tempFile
|
|
|
|
env:
|
|
|
|
WINDOWS_CERTIFICATE_P12: ${{ secrets.WINDOWS_CERTIFICATE_P12 }}
|
|
|
|
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
|
|
|
|
|
|
|
|
- name: Build (with installer)
|
|
|
|
if: inputs.is_tag == 'true'
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
|
|
|
|
echo "::group::CMake"
|
|
|
|
cmake ${GITHUB_WORKSPACE} \
|
|
|
|
-GNinja \
|
|
|
|
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE="c:\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
|
|
|
-DOPTION_USE_NSIS=ON \
|
|
|
|
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
2023-04-25 19:43:45 +02:00
|
|
|
-DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
|
2023-01-28 13:32:30 +01:00
|
|
|
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
|
|
|
|
# EOF
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Build"
|
2023-05-02 23:43:16 +02:00
|
|
|
cmake --build . --target openttd
|
2023-01-28 13:32:30 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
env:
|
|
|
|
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
|
|
|
|
|
|
|
- name: Build (without installer)
|
|
|
|
if: inputs.is_tag != 'true'
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
|
|
|
|
echo "::group::CMake"
|
|
|
|
cmake ${GITHUB_WORKSPACE} \
|
|
|
|
-GNinja \
|
|
|
|
-DVCPKG_TARGET_TRIPLET=${{ matrix.arch }}-windows-static \
|
|
|
|
-DCMAKE_TOOLCHAIN_FILE="c:\vcpkg\scripts\buildsystems\vcpkg.cmake" \
|
|
|
|
-DHOST_BINARY_DIR=${GITHUB_WORKSPACE}/build-host \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
2023-04-25 19:43:45 +02:00
|
|
|
-DOPTION_SURVEY_KEY=${{ inputs.survey_key }} \
|
2023-01-28 13:32:30 +01:00
|
|
|
-DWINDOWS_CERTIFICATE_COMMON_NAME="${WINDOWS_CERTIFICATE_COMMON_NAME}" \
|
|
|
|
# EOF
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Build"
|
2023-05-02 23:43:16 +02:00
|
|
|
cmake --build . --target openttd
|
2023-01-28 13:32:30 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
env:
|
|
|
|
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
|
|
|
|
2023-08-30 20:27:15 +02:00
|
|
|
- name: Create breakpad symbols
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
cd build
|
|
|
|
dump_syms openttd.pdb --inlines --store symbols
|
|
|
|
|
2023-01-28 13:32:30 +01:00
|
|
|
- name: Create bundles
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
cd ${GITHUB_WORKSPACE}/build
|
|
|
|
echo "::group::Run CPack"
|
|
|
|
cpack
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
2023-08-30 20:27:15 +02:00
|
|
|
echo "::group::Move PDB and exe to symbols"
|
|
|
|
PDB_FOLDER=$(find symbols -mindepth 2 -type d)
|
|
|
|
cp openttd.pdb ${PDB_FOLDER}/
|
|
|
|
|
|
|
|
EXE_FOLDER=symbols/openttd.exe/$(grep "INFO CODE_ID" symbols/*/*/openttd.sym | cut -d\ -f3)
|
|
|
|
mkdir -p ${EXE_FOLDER}
|
|
|
|
cp openttd.exe ${EXE_FOLDER}/
|
2023-01-28 13:32:30 +01:00
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
echo "::group::Cleanup"
|
|
|
|
# Remove the sha256 files CPack generates; we will do this ourself at
|
|
|
|
# the end of this workflow.
|
|
|
|
rm -f bundles/*.sha256
|
|
|
|
echo "::endgroup::"
|
|
|
|
|
|
|
|
- name: Sign installer
|
|
|
|
if: inputs.is_tag == 'true'
|
|
|
|
shell: bash
|
|
|
|
# If this is run on a fork, there may not be a certificate set up - continue in this case
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
cd ${GITHUB_WORKSPACE}/build/bundles
|
|
|
|
../../os/windows/sign.bat *.exe "${WINDOWS_CERTIFICATE_COMMON_NAME}"
|
|
|
|
env:
|
|
|
|
WINDOWS_CERTIFICATE_COMMON_NAME: ${{ secrets.WINDOWS_CERTIFICATE_COMMON_NAME }}
|
|
|
|
|
|
|
|
- name: Store bundles
|
2024-01-25 22:22:33 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-01-28 13:32:30 +01:00
|
|
|
with:
|
|
|
|
name: openttd-windows-${{ matrix.arch }}
|
|
|
|
path: build/bundles
|
|
|
|
retention-days: 5
|
2023-08-30 20:27:15 +02:00
|
|
|
|
|
|
|
- name: Store symbols
|
2024-01-25 22:22:33 +01:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-08-30 20:27:15 +02:00
|
|
|
with:
|
|
|
|
name: symbols-windows-${{ matrix.arch }}
|
|
|
|
path: build/symbols
|
|
|
|
retention-days: 5
|