mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
create empty CMakeUserPresets.json file so build happens on first run comment doesn't apply anymore no need to specify the compiler when using msbuild@xxx ask ninja for the verbose command line when building
205 lines
6.4 KiB
YAML
205 lines
6.4 KiB
YAML
name: build language
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
language:
|
|
description: 'any of Chinese German English French Polish Italian Dutch Russian'
|
|
required: true
|
|
default: 'English'
|
|
type: string
|
|
assemble:
|
|
description: 'assemble full package'
|
|
required: true
|
|
default: true
|
|
type: boolean
|
|
continue-on-error:
|
|
description: 'allows a language to fail, used when building all languages'
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
jobs:
|
|
compile:
|
|
runs-on: windows-latest # required for msbuild
|
|
continue-on-error: ${{ inputs.continue-on-error }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
application: [ja2, ja2mapeditor, ja2ub, ja2ubmapeditor]
|
|
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Download versions.env
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: versions.env
|
|
path: artifacts
|
|
- name: Restore versions.env
|
|
shell: bash
|
|
run: cat artifacts/versions.env >> $GITHUB_ENV
|
|
|
|
- name: Update GameVersion.cpp
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
INPUTS_LANGUAGE=${{ inputs.language }}
|
|
GAME_VERSION=$(echo "$GAME_VERSION" | tr -cd '[:print:]' | tr -d '"\\')
|
|
GAME_BUILD="${INPUTS_LANGUAGE:0:2} $GAME_BUILD_INFORMATION"
|
|
GAME_BUILD=$(echo "$GAME_BUILD" | tr -cd '[:print:]' | tr -d '"\\')
|
|
sed -i "s|@Version@|${GAME_VERSION:0:15}|" GameVersion.cpp
|
|
sed -i "s|@Build@|${GAME_BUILD:0:255}|" GameVersion.cpp
|
|
cat GameVersion.cpp
|
|
|
|
- name: Prepare build properties
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
|
|
touch CMakeUserPresets.json
|
|
|
|
JA2Language=$(echo '${{ inputs.language }}' | tr '[:lower:]' '[:upper:]')
|
|
JA2Application=$(echo '${{ matrix.application }}' | tr '[:lower:]' '[:upper:]')
|
|
|
|
echo "
|
|
JA2Language=$JA2Language
|
|
JA2Application=$JA2Application
|
|
" >> $GITHUB_ENV
|
|
|
|
- uses: microsoft/setup-msbuild@v1.1
|
|
with:
|
|
msbuild-architecture: x86
|
|
- uses: ilammy/msvc-dev-cmd@v1
|
|
with:
|
|
arch: x86
|
|
- name: Prepare build
|
|
run: |
|
|
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DLanguages="$Env:JA2Language" -DApplications="$Env:JA2Application"
|
|
- name: Build
|
|
run: |
|
|
cmake --build build/ -- -v
|
|
- name: List build artifacts
|
|
shell: bash
|
|
run: |
|
|
find build/
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_${{ matrix.application }}
|
|
path: build/*.exe
|
|
|
|
assemble:
|
|
needs: [ compile ]
|
|
if: inputs.assemble
|
|
runs-on: windows-latest # required for case-insensitive filesystem handling
|
|
continue-on-error: ${{ inputs.continue-on-error }}
|
|
|
|
steps:
|
|
- name: Download versions.env
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: versions.env
|
|
path: artifacts
|
|
- name: Restore versions.env
|
|
shell: bash
|
|
run: cat artifacts/versions.env >> $GITHUB_ENV
|
|
|
|
- name: Checkout gamedir
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: ${{ env.GAMEDIR_REPOSITORY }}
|
|
ref: ${{ env.GAMEDIR_COMMIT_SHA }}
|
|
path: gamedir
|
|
|
|
- name: Checkout gamedir-languages
|
|
if: inputs.language != 'English'
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: ${{ env.GAMEDIR_LANGUAGES_REPOSITORY }}
|
|
ref: ${{ env.GAMEDIR_LANGUAGES_COMMIT_SHA }}
|
|
path: gamedir-languages
|
|
|
|
- name: Copy gamedir-languages files to gamedir
|
|
if: inputs.language != 'English'
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
cp -a gamedir-languages/${{ inputs.language }}_Version/* gamedir/
|
|
|
|
- name: Download ja2
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_ja2
|
|
path: artifacts/ja2
|
|
|
|
- name: Download ja2mapeditor
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_ja2mapeditor
|
|
path: artifacts/ja2mapeditor
|
|
|
|
- name: Download ja2ub
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_ja2ub
|
|
path: artifacts/ja2ub
|
|
|
|
- name: Download ja2ubmapeditor
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_ja2ubmapeditor
|
|
path: artifacts/ja2ubmapeditor
|
|
|
|
- name: Copy application files to gamedir
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
for APP in ja2 ja2mapeditor ja2ub ja2ubmapeditor
|
|
do
|
|
mv artifacts/${APP}/*.exe gamedir/${APP}.exe
|
|
done
|
|
|
|
- name: Create version information file
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
|
|
# "-" separates words, "_" combines words, see double-click behavior
|
|
DIST_PREFIX='JA2_113'
|
|
DIST_NAME="${DIST_PREFIX}-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ inputs.language }}"
|
|
echo "DIST_NAME=$DIST_NAME" >> $GITHUB_ENV
|
|
|
|
echo "If you encounter problems during gameplay, please provide the following version information:
|
|
Distribution Name: $DIST_NAME
|
|
Game Version: $GAME_VERSION
|
|
Language: ${{ inputs.language }}
|
|
Build Information: $GAME_BUILD_INFORMATION
|
|
Source Repository: $GITHUB_REPOSITORY
|
|
Source Commit SHA: $GITHUB_SHA
|
|
Source Commit Date: $SOURCE_COMMIT_DATETIME
|
|
Gamedir Repository: $GAMEDIR_REPOSITORY
|
|
Gamedir Commit SHA: $GAMEDIR_COMMIT_SHA
|
|
Gamedir Commit Date: $GAMEDIR_COMMIT_DATETIME
|
|
Gamedir Languages Repository: $GAMEDIR_LANGUAGES_REPOSITORY
|
|
Gamedir Languages Commit SHA: $GAMEDIR_LANGUAGES_COMMIT_SHA
|
|
Gamedir Languages Commit Date: $GAMEDIR_LANGUAGES_COMMIT_DATETIME
|
|
" > "gamedir/${DIST_PREFIX}-Version.txt"
|
|
cat "gamedir/${DIST_PREFIX}-Version.txt"
|
|
|
|
- name: Create release archive
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
mkdir dist/
|
|
cd gamedir/
|
|
7z a -bb -xr'!.*' "../dist/${DIST_NAME}.7z" .
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ inputs.language }}_release
|
|
path: dist/
|