mirror of
https://github.com/1dot13/source.git
synced 2026-07-29 13:52:17 +02:00
A skipped job still shows up in a pull request's check list, so assemble and release reported there as two permanently skipped checks. A job can only be left out of a run graph it does not belong to, so move both into release.yml, which triggers on master, v* tags and manual dispatch, and gets its build by calling build.yml through workflow_call. A pull request now runs build.yml directly and reports exactly the five checks it can actually pass. The global_vars step only existed to compute assemble_release for the two jobs that left, and it read the workflow_dispatch input, which a called workflow cannot see. Its logic moves to a condition on assemble itself, unchanged: a manual run assembles only when asked, tags always assemble, master assembles only upstream. The release job needs no condition since a skipped assemble skips it. Check out the source rather than cloning it by hand. A pull request builds its merge commit, which is on no branch and so is absent from a clone of branches and tags; it resolved only because --filter=tree:0 made the clone partial and git fetched it from the promisor remote on demand. The action fetches the merge ref itself, so nothing hinges on the filter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
194 lines
6.8 KiB
YAML
194 lines
6.8 KiB
YAML
name: build
|
|
|
|
on:
|
|
pull_request:
|
|
# release.yml calls this workflow, which is how master, tags and manual runs
|
|
# build. Keeping the release jobs out of here keeps them off the pull request
|
|
# check list, where they would only ever show up as skipped.
|
|
workflow_call:
|
|
|
|
jobs:
|
|
workflow_setup:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v7
|
|
with:
|
|
path: source
|
|
filter: 'tree:0'
|
|
fetch-depth: 0
|
|
|
|
- name: Clone gamedir metadata
|
|
run: |
|
|
set -eux
|
|
|
|
GAMEDIR_REPOSITORY=1dot13/gamedir
|
|
GAMEDIR_LANGUAGES_REPOSITORY=1dot13/gamedir-languages
|
|
|
|
# filter tree is what makes this fast
|
|
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
|
https://github.com/$GAMEDIR_REPOSITORY \
|
|
gamedir
|
|
|
|
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
|
https://github.com/$GAMEDIR_LANGUAGES_REPOSITORY \
|
|
gamedir-languages
|
|
|
|
mkdir dist/
|
|
echo -n "
|
|
GAMEDIR_REPOSITORY=$GAMEDIR_REPOSITORY
|
|
GAMEDIR_LANGUAGES_REPOSITORY=$GAMEDIR_LANGUAGES_REPOSITORY
|
|
" > dist/versions.env
|
|
|
|
- name: Generate source version information
|
|
working-directory: source
|
|
run: |
|
|
set -eux
|
|
|
|
SOURCE_COMMIT_DATETIME=$(TZ=UTC0 git log -1 --date=iso-strict-local --format=%cd $GITHUB_SHA)
|
|
SOURCE_COMMIT_DATE=$(TZ=UTC0 git log -1 --date=short-local --format=%cd $GITHUB_SHA)
|
|
|
|
# GAME_VERSION is used to detect outdated save games and is the main version used for tracking
|
|
if [[ "$GITHUB_REF_TYPE" == 'tag' ]]
|
|
then
|
|
# if we build for a specific tag, use that as the game version
|
|
# examples:
|
|
# - v1.13.1
|
|
# - v1.13.2-rc2
|
|
GAME_VERSION="$GITHUB_REF_NAME"
|
|
else
|
|
# uses `git describe`, which tries to find a tag in the commit hierarchy. or fall back to a v1.13 version
|
|
# example five (5) commits after v1.13:
|
|
# - v1.13-5-7g7ffa
|
|
GAME_VERSION="$(git describe --tags --match='v[0-9]*' $GITHUB_SHA || echo v0-$(git rev-list --skip 1 --count $GITHUB_SHA)-g${GITHUB_SHA:0:8})"
|
|
fi
|
|
# max 15 CHAR8
|
|
GAME_VERSION="${GAME_VERSION:0:15}"
|
|
|
|
GAME_BUILD_INFORMATION="$SOURCE_COMMIT_DATE GitHub $GITHUB_REPOSITORY"
|
|
# in case of a branch or if the tag is truncated
|
|
if [[ "$GAME_VERSION" != *"$GITHUB_REF_NAME"* ]]
|
|
then
|
|
GAME_BUILD_INFORMATION="$GAME_BUILD_INFORMATION $GITHUB_REF_TYPE $GITHUB_REF_NAME"
|
|
fi
|
|
# max 255 CHAR16
|
|
GAME_BUILD_INFORMATION="${GAME_BUILD_INFORMATION:0:255}"
|
|
|
|
echo -n "
|
|
SOURCE_COMMIT_DATETIME=$SOURCE_COMMIT_DATETIME
|
|
GAME_VERSION=$GAME_VERSION
|
|
GAME_BUILD_INFORMATION=$GAME_BUILD_INFORMATION
|
|
" >> ../dist/versions.env
|
|
|
|
# due to building everything in parallel, versions should be pinned at the start so everything builds based on the same versions
|
|
- name: Generate gamedir version information
|
|
working-directory: gamedir
|
|
run: |
|
|
set -eux
|
|
|
|
GAMEDIR_COMMIT_SHA=$(git rev-parse HEAD)
|
|
GAMEDIR_COMMIT_DATETIME=$(TZ=UTC0 git log -1 --date=iso-strict-local --format=%cd $GAMEDIR_COMMIT_SHA)
|
|
|
|
echo -n "
|
|
GAMEDIR_COMMIT_SHA=$GAMEDIR_COMMIT_SHA
|
|
GAMEDIR_COMMIT_DATETIME=$GAMEDIR_COMMIT_DATETIME
|
|
" >> ../dist/versions.env
|
|
|
|
# due to building everything in parallel, versions should be pinned at the start so everything builds based on the same versions
|
|
- name: Generate gamedir-languages version information
|
|
working-directory: gamedir-languages
|
|
run: |
|
|
set -eux
|
|
|
|
GAMEDIR_LANGUAGES_COMMIT_SHA=$(git rev-parse HEAD)
|
|
GAMEDIR_LANGUAGES_COMMIT_DATETIME=$(TZ=UTC0 git log -1 --date=iso-strict-local --format=%cd $GAMEDIR_LANGUAGES_COMMIT_SHA)
|
|
|
|
echo -n "
|
|
GAMEDIR_LANGUAGES_COMMIT_SHA=$GAMEDIR_LANGUAGES_COMMIT_SHA
|
|
GAMEDIR_LANGUAGES_COMMIT_DATETIME=$GAMEDIR_LANGUAGES_COMMIT_DATETIME
|
|
" >> ../dist/versions.env
|
|
|
|
- name: Show version information summary
|
|
run: |
|
|
set -eux
|
|
cat dist/versions.env
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: versions.env
|
|
path: dist/
|
|
|
|
# every executable contains all languages and picks one at runtime, so one build serves every package
|
|
compile:
|
|
needs: [ workflow_setup ]
|
|
runs-on: windows-latest # required for the MSVC toolchain
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
application: [ja2, ja2mapeditor, ja2ub, ja2ubmapeditor]
|
|
env:
|
|
# store the compiler cache in the GitHub Actions cache
|
|
SCCACHE_GHA_ENABLED: 'true'
|
|
|
|
steps:
|
|
- name: Checkout source
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Download versions.env
|
|
uses: actions/download-artifact@v8
|
|
with:
|
|
name: versions.env
|
|
path: artifacts
|
|
- name: Restore versions.env
|
|
shell: bash
|
|
run: cat artifacts/versions.env >> $GITHUB_ENV
|
|
|
|
# TODO: Move this into CMake, just taking the GitHub Actions parameters as -D variables
|
|
- name: Update GameVersion.cpp
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
GAME_VERSION=$(echo "$GAME_VERSION" | tr -cd '[:print:]' | tr -d '"\\')
|
|
GAME_BUILD=$(echo "$GAME_BUILD_INFORMATION" | tr -cd '[:print:]' | tr -d '"\\')
|
|
sed -i "s|@Version@|${GAME_VERSION:0:15}|" Ja2/GameVersion.cpp
|
|
sed -i "s|@Build@|${GAME_BUILD:0:255}|" Ja2/GameVersion.cpp
|
|
cat Ja2/GameVersion.cpp
|
|
|
|
- name: Prepare build properties
|
|
shell: bash
|
|
run: |
|
|
set -eux
|
|
|
|
touch CMakePresets.json
|
|
|
|
JA2Application=$(echo '${{ matrix.application }}' | tr '[:lower:]' '[:upper:]')
|
|
|
|
echo "
|
|
JA2Application=$JA2Application
|
|
" >> $GITHUB_ENV
|
|
|
|
- uses: egor-tensin/vs-shell@v2
|
|
with:
|
|
arch: x86
|
|
- uses: mozilla-actions/sccache-action@v0.0.10
|
|
- name: Prepare build
|
|
run: |
|
|
# sccache can only cache MSVC objects when the debug information is embedded
|
|
# in them (/Z7) instead of collected in a shared PDB (/Zi, the CMake default)
|
|
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DApplications="$Env:JA2Application"
|
|
- name: Build
|
|
run: |
|
|
cmake --build build/ -- -v
|
|
- name: List build artifacts
|
|
shell: bash
|
|
run: |
|
|
find build/
|
|
sccache --show-stats
|
|
|
|
- name: Upload
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: ${{ matrix.application }}
|
|
path: build/*.exe
|