Skip to content

Commit 4d78360

Browse files
committed
skeleton
0 parents  commit 4d78360

File tree

6 files changed

+316
-0
lines changed

6 files changed

+316
-0
lines changed

.github/workflows/c-cpp.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build & Deploy HLSDK
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ${{ matrix.os }}
6+
continue-on-error: true
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
include:
11+
- os: ubuntu-20.04
12+
targetos: linux
13+
targetarch: amd64
14+
- os: ubuntu-20.04
15+
targetos: linux
16+
targetarch: i386
17+
- os: ubuntu-20.04
18+
targetos: linux
19+
targetarch: arm64
20+
- os: ubuntu-20.04
21+
targetos: linux
22+
targetarch: armhf
23+
- os: ubuntu-20.04
24+
targetos: linux
25+
targetarch: riscv64
26+
- os: ubuntu-20.04
27+
targetos: linux
28+
targetarch: ppc64el
29+
env:
30+
YQ_VERSION: 4.44.6
31+
GH_CPU_OS: ${{ matrix.targetos }}
32+
GH_CPU_ARCH: ${{ matrix.targetarch }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
submodules: recursive
38+
- name: Install dependencies
39+
run: bash scripts/gha/deps_${{ matrix.targetos }}.sh
40+
- name: Build HLSDK
41+
env:
42+
FWGS_PFX_PASSWORD: ${{ secrets.FWGS_PFX_PASSWORD }}
43+
run: bash scripts/gha/build_${{ matrix.targetos }}.sh
44+
- name: Upload HLSDK (artifacts)
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: artifact-${{ matrix.targetos }}-${{ matrix.targetarch }}
48+
path: out/*
49+
release:
50+
name: "Upload releases"
51+
runs-on: ubuntu-latest
52+
needs: build
53+
if: ${{ github.event_name == 'push' }}
54+
steps:
55+
- name: Remove old release, fetch artifacts, repackage binaries and upload new release
56+
env:
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }}
59+
run: |
60+
gh release delete "$RELEASE_TAG" \
61+
--yes \
62+
--cleanup-tag \
63+
--repo "$GITHUB_REPOSITORY" || true
64+
sleep 20s
65+
gh run download "$GITHUB_RUN_ID" \
66+
--dir out/ \
67+
--repo "$GITHUB_REPOSITORY"
68+
pushd out/
69+
echo "Found artifacts:"
70+
ls
71+
for i in $(find -mindepth 1 -maxdepth 1 -type d); do
72+
mv "$i"/* .
73+
rm -rf "$i"
74+
done
75+
echo "Repackaged artifacts:"
76+
ls -R
77+
popd
78+
sleep 20s
79+
gh release create "$RELEASE_TAG" out/* \
80+
--title "HLSDK Mega Continuous ${{ github.ref_name }} Build" \
81+
--target $GITHUB_SHA \
82+
--repo "$GITHUB_REPOSITORY" \
83+
--prerelease

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out/
2+
hlsdk-portable/
3+
install-man-page.sh
4+
yq*
5+

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# hlsdk-mega-build
2+
3+
This repository uses cron job to rebuild all known HLSDK branches and puts prebuilt binaries on GitHub releases where they could be accessed by anyone.
4+
5+
## Manifest
6+
7+
The definition of mods is kept within `manifest.yml` file which is a YAML file consisting of array of structured data:
8+
9+
| Key | Value |
10+
|---------|-------|
11+
|`branch` |Branch name used for in the repository.|
12+
|`repo` |URL of Git repository. If not set, defaults to hlsdk-portable.|
13+
|`dl_name`|If set, it means that game directory specified in mod_options.txt differs from branch name.|
14+
|`games` |An array of game objects, see below. Used to automatically fetching game libraries.|
15+
16+
### Game object
17+
18+
| Key | Value |
19+
|-------|-------|
20+
|`title`|Human readable title of the game.|
21+
|`dir` |Game directory name of the game.|
22+
|`steam`|If set, the game is available from Steam. The object must have `app_id` with Steam AppID and `depot_id` with array of **content** depot IDs.|
23+
|`moddb`|If set, the game is available from ModDB. The object must have `url` with ModDB page, `dl` with main ModDBs download link and array of `patches` links, if they are any|
24+
25+
## Build scripts
26+
27+
The `deps` scripts prepare to build environment for a specified target. The `build` scripts parse manifest, run build for all branches and create archives for all games in `out` directory. After that it's collected and published on GitHub releases page.
28+
29+
## TODO
30+
31+
- [ ] Support other build systems than Waf and other repos than `hlsdk-portable`.
32+
- [ ] Add more build targets, ideally all supported by Xash3D FWGS.
33+
- [ ] Implement a client which will look up which game libraries are missing for selected gamedir and download them from this repository, optionally download the game files from ModDB and Steam, apply patches, have a beautiful GUI......
34+
- [ ] Cache object files for faster rebuilds.
35+
- [ ] Make this run daily? Bi-weekly?

manifest.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
- branch: master
3+
dl_name: valve
4+
games:
5+
- title: 'Half-Life'
6+
dir: valve
7+
steam:
8+
app_id: 70
9+
depot_ids: [1, 71, 96]
10+
- branch: opfor
11+
games:
12+
- title: 'Half-Life: Opposing Force'
13+
url: 'https://store.steampowered.com/app/50/HalfLife_Opposing_Force/'
14+
steam:
15+
app_id: 50
16+
depot_ids: [1, 51, 96]
17+
- branch: bshift
18+
games:
19+
- title: 'Half-Life: Blue Shift'
20+
url: 'https://store.steampowered.com/app/130/HalfLife_Blue_Shift/'
21+
steam:
22+
app_id: 130
23+
depot_ids: [1, 130, 96]
24+
#- branch: aghl
25+
#- branch: aom
26+
#- branch: aomdc
27+
#- branch: asheep
28+
#- branch: biglolly
29+
#- branch: blackops
30+
#- branch: bubblemod
31+
#- branch: caseclosed
32+
#- branch: CAd
33+
#- branch: clcampaign
34+
#- branch: dmc
35+
#- branch: echoes
36+
#- branch: eftd
37+
#- branch: induction
38+
#- branch: invasion
39+
#- branch: half-screwed
40+
#- branch: halloween
41+
#- branch: hltopdown
42+
#- branch: hl_urbicide
43+
#- branch: half-secret
44+
#- branch: noffice
45+
#- branch: redempt
46+
#- branch: sewer_beta
47+
#- branch: sohl1.2
48+
#- branch: tot
49+
#- branch: zombie-x

scripts/gha/build_linux.sh

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#!/bin/bash
2+
3+
# "booo, bash feature!"
4+
declare -A ARCH_TRIPLET CROSS_COMPILE_CC CROSS_COMPILE_CXX
5+
ARCH_TRIPLET[amd64]=x86_64-linux-gnu
6+
ARCH_TRIPLET[i386]=i386-linux-gnu
7+
ARCH_TRIPLET[arm64]=aarch64-linux-gnu
8+
ARCH_TRIPLET[armhf]=arm-linux-gnueabihf
9+
ARCH_TRIPLET[riscv64]=riscv64-linux-gnu
10+
ARCH_TRIPLET[ppc64el]=powerpc64le-linux-gnu
11+
CROSS_COMPILE_CC[amd64]=cc
12+
CROSS_COMPILE_CC[i386]="cc -m32"
13+
CROSS_COMPILE_CXX[amd64]=c++
14+
CROSS_COMPILE_CXX[i386]="c++ -m32"
15+
for i in arm64 armhf riscv64 ppc64el; do
16+
CROSS_COMPILE_CC[$i]=${ARCH_TRIPLET[$i]}-gcc
17+
CROSS_COMPILE_CXX[$i]=${ARCH_TRIPLET[$i]}-g++
18+
done
19+
export PKG_CONFIG_PATH=${ARCH_TRIPLET[$GH_CPU_ARCH]}
20+
export CC=${CROSS_COMPILE_CC[$GH_CPU_ARCH]}
21+
export CXX=${CROSS_COMPILE_CXX[$GH_CPU_ARCH]}
22+
23+
MODS=$(./yq length manifest.yml)
24+
25+
build_with_waf()
26+
{
27+
local WAF_ENABLE_VGUI_OPTION=''
28+
local WAF_ENABLE_AMD64_OPTION=''
29+
30+
# run build in it's out build folder
31+
export WAFLOCK=".lock-waf_$1"
32+
33+
if [ "$GH_CPU_ARCH" == "amd64" ]; then
34+
WAF_ENABLE_AMD64_OPTION="-8"
35+
elif [ "$GH_CPU_ARCH" == "i386" ]; then
36+
# not all waf-based hlsdk trees have vgui support
37+
python waf --help | grep 'enable-vgui' && WAF_ENABLE_VGUI_OPTION=--enable-vgui
38+
fi
39+
40+
python waf -o "build/$1" configure \
41+
$WAF_ENABLE_AMD64_OPTION \
42+
$WAF_ENABLE_VGUI_OPTION || return 1
43+
44+
python waf install --destdir=../stage || return 3
45+
46+
unset WAFLOCK
47+
48+
return 0
49+
}
50+
51+
build_hlsdk_portable_branch()
52+
{
53+
# hlsdk-portable has mods in git branches
54+
git checkout "$1" || return 1
55+
56+
# all hlsdk-portable branches have mod_options.txt file
57+
GAMEDIR=$(grep GAMEDIR mod_options.txt | tr '=' ' ' | cut -d' ' -f2 )
58+
59+
build_with_waf "$GAMEDIR"
60+
SUCCESS=$?
61+
62+
if [ $SUCCESS -eq 2 ]; then # means something went wrong during install phase
63+
rm -rf "../stage/$GAMEDIR" # better cleanup
64+
fi
65+
66+
if [ $SUCCESS -ne 0 ]; then
67+
return 2
68+
fi
69+
70+
return 0
71+
}
72+
73+
pack_staged_gamedir()
74+
{
75+
mkdir -p out || return 1
76+
77+
pushd stage/ || return 1
78+
zip -r "../out/$1-$2.zip" "$1" || return 2
79+
popd || return 1
80+
81+
return 0
82+
}
83+
84+
for (( i = 0 ; i < MODS ; i++ )); do
85+
BRANCH=$(./yq -r ".[$i].branch" manifest.yml)
86+
87+
GAMEDIR="" # expected to be set within build_hlsdk_portable_branch
88+
89+
pushd hlsdk-portable || exit 1
90+
build_hlsdk_portable_branch "$BRANCH"
91+
SUCCESS=$?
92+
93+
if [ $SUCCESS -ne 0 ]; then
94+
continue
95+
fi
96+
popd || exit 1
97+
98+
pack_staged_gamedir "$GAMEDIR" "$GH_CPU_OS-$GH_CPU_ARCH"
99+
done

scripts/gha/deps_linux.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
cd "$GITHUB_WORKSPACE" || exit 1
4+
5+
# "booo, bash feature!", -- posix sh users, probably
6+
declare -A BASE_BUILD_PACKAGES
7+
8+
BASE_BUILD_PACKAGES[common]=""
9+
BASE_BUILD_PACKAGES[amd64]="build-essential"
10+
BASE_BUILD_PACKAGES[i386]="gcc-multilib g++-multilib"
11+
BASE_BUILD_PACKAGES[arm64]="crossbuild-essential-arm64"
12+
BASE_BUILD_PACKAGES[armhf]="crossbuild-essential-armhf"
13+
BASE_BUILD_PACKAGES[riscv64]="crossbuild-essential-riscv64"
14+
BASE_BUILD_PACKAGES[ppc64el]="crossbuild-essential-ppc64el"
15+
16+
regenerate_sources_list()
17+
{
18+
# this is evil but to speed up update, specify all repositories manually
19+
sudo rm /etc/apt/sources.list
20+
sudo rm -rf /etc/apt/sources.list.d
21+
22+
for i in focal focal-updates focal-backports focal-security; do
23+
echo "deb [arch=$GH_CPU_ARCH] http://azure.ports.ubuntu.com/ubuntu-ports $i main universe" | sudo tee -a /etc/apt/sources.list
24+
echo "deb [arch=amd64] http://azure.archive.ubuntu.com/ubuntu $i main universe" | sudo tee -a /etc/apt/sources.list
25+
done
26+
}
27+
28+
if [ "$GH_CPU_ARCH" != "amd64" ] && [ -n "$GH_CPU_ARCH" ]; then
29+
if [ "$GH_CPU_ARCH" != "i386" ]; then
30+
regenerate_sources_list
31+
fi
32+
sudo dpkg --add-architecture "$GH_CPU_ARCH"
33+
fi
34+
35+
sudo apt update || exit 2
36+
sudo apt install aptitude || exit 2 # aptitude is just more reliable at resolving dependencies
37+
38+
# shellcheck disable=SC2086 # splitting is intended here
39+
sudo aptitude install -y ${BASE_BUILD_PACKAGES[common]} ${BASE_BUILD_PACKAGES[$GH_CPU_ARCH]} || exit 2
40+
41+
####################
42+
git clone --recursive https://github.com/FWGS/hlsdk-portable
43+
44+
wget "https://github.com/mikefarah/yq/releases/download/v$YQ_VERSION/yq_linux_amd64.tar.gz" -O- | tar -xzvf -
45+
mv yq_linux_amd64 yq

0 commit comments

Comments
 (0)