Skip to content

Commit a4b788b

Browse files
coopryansolcloud
authored andcommitted
ci: add server standalone static php executable asset support
1 parent 227b4df commit a4b788b

3 files changed

Lines changed: 110 additions & 8 deletions

File tree

.github/workflows/electron.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ jobs:
3232
cd electron/
3333
rm -rf build/
3434
npm run build
35-
zip -r linux.zip build/build-linux*/
36-
zip -r windows.zip build/build-win*/
37-
zip -r macos.zip build/build-mas*/
35+
mv build/ csf/
36+
zip -r linux.zip csf/build-linux*/
37+
zip -r windows.zip csf/build-win*/
38+
zip -r macos.zip csf/build-mas*/
39+
rm -rf csf/
3840
3941
- name: "Publish Linux Artifact"
4042
timeout-minutes: 5
@@ -49,7 +51,7 @@ jobs:
4951
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
5052
-H "X-GitHub-Api-Version: 2022-11-28" \
5153
-H "Content-Type: application/zip" \
52-
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=client-linux.zip" \
54+
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=csf-client-linux.zip" \
5355
--data-binary "@electron/linux.zip"
5456
5557
- name: "Publish Windows Artifact"
@@ -65,7 +67,7 @@ jobs:
6567
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
6668
-H "X-GitHub-Api-Version: 2022-11-28" \
6769
-H "Content-Type: application/zip" \
68-
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=client-windows.zip" \
70+
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=csf-client-windows.zip" \
6971
--data-binary "@electron/windows.zip"
7072
7173
- name: "Publish MacOS Artifact"
@@ -81,5 +83,5 @@ jobs:
8183
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
8284
-H "X-GitHub-Api-Version: 2022-11-28" \
8385
-H "Content-Type: application/zip" \
84-
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=client-macos.zip" \
86+
"https://uploads.github.com/repos/solcloud/Counter-Strike/releases/${RELEASE_ID}/assets?name=csf-client-macos.zip" \
8587
--data-binary "@electron/macos.zip"

.github/workflows/server.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
env:
2+
PHP_VERSION: "8.4.12"
3+
4+
name: "Server"
5+
on:
6+
release:
7+
types: [created]
8+
9+
jobs:
10+
server-build:
11+
if: github.actor == 'solcloud'
12+
permissions:
13+
contents: write
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
persist-credentials: false
19+
20+
- name: "Install Linux dependencies"
21+
timeout-minutes: 4
22+
run: |
23+
sudo apt-get update && sudo apt-get install -y \
24+
composer zip tar curl
25+
26+
- name: "Install Composer dependencies"
27+
timeout-minutes: 6
28+
run: |
29+
composer install -a --no-dev
30+
31+
- name: "Pack into phar"
32+
timeout-minutes: 4
33+
run: |
34+
curl -Lo box.phar "https://github.com/box-project/box/releases/latest/download/box.phar"
35+
ln -s cli/server.php index.php
36+
php box.phar compile
37+
38+
- name: "Pack into static executable"
39+
timeout-minutes: 6
40+
run: |
41+
echo "Packing for linux"
42+
curl -Lo linux.tar.gz "https://dl.static-php.dev/static-php-cli/common/php-${PHP_VERSION}-micro-linux-x86_64.tar.gz"
43+
tar xf linux.tar.gz
44+
cat micro.sfx index.phar > server-linux-x86_64
45+
rm micro.sfx
46+
echo "Packing for mac"
47+
curl -Lo mac.tar.gz "https://dl.static-php.dev/static-php-cli/common/php-${PHP_VERSION}-micro-macos-x86_64.tar.gz"
48+
tar xf mac.tar.gz
49+
cat micro.sfx index.phar > server-mac-x86_64
50+
rm micro.sfx
51+
echo "Packing for windows"
52+
curl -Lo windows.zip "https://dl.static-php.dev/static-php-cli/windows/spc-max/php-${PHP_VERSION}-micro-win.zip"
53+
unzip windows.zip
54+
cat micro.sfx index.phar > server-windows-x86_64
55+
rm micro.sfx
56+
57+
- name: "Publish Linux server executable"
58+
timeout-minutes: 6
59+
env:
60+
RELEASE_ID: ${{ github.event.release.id }}
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
curl -L \
64+
-X POST \
65+
-H "Accept: application/vnd.github+json" \
66+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
67+
-H "X-GitHub-Api-Version: 2022-11-28" \
68+
-H "Content-Type: application/octet-stream" \
69+
"https://uploads.github.com/repos/coopryan/csf/releases/${RELEASE_ID}/assets?name=csf-server-linux" \
70+
--data-binary "@server-linux-x86_64"
71+
72+
- name: "Publish macOS server executable"
73+
timeout-minutes: 6
74+
env:
75+
RELEASE_ID: ${{ github.event.release.id }}
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
curl -L \
79+
-X POST \
80+
-H "Accept: application/vnd.github+json" \
81+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
82+
-H "X-GitHub-Api-Version: 2022-11-28" \
83+
-H "Content-Type: application/octet-stream" \
84+
"https://uploads.github.com/repos/coopryan/csf/releases/${RELEASE_ID}/assets?name=csf-server-mac" \
85+
--data-binary "@server-mac-x86_64"
86+
87+
- name: "Publish Windows server executable"
88+
timeout-minutes: 6
89+
env:
90+
RELEASE_ID: ${{ github.event.release.id }}
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
curl -L \
94+
-X POST \
95+
-H "Accept: application/vnd.github+json" \
96+
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
97+
-H "X-GitHub-Api-Version: 2022-11-28" \
98+
-H "Content-Type: application/octet-stream" \
99+
"https://uploads.github.com/repos/coopryan/csf/releases/${RELEASE_ID}/assets?name=csf-server-windows.bat" \
100+
--data-binary "@server-windows-x86_64"

cli/server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$port = (int)($argv[2] ?? 8080);
1515
$debug = in_array('--debug', $argv);
1616
$bindAddress = "udp://0.0.0.0:$port";
17-
$map = new Maps\DefaultMap();
17+
$map = Maps\DefaultMap::class;
1818
/////
1919

2020
$settings = new ServerSetting($playersMax); // must be first for correctly setting the global tickRate (Util::$TICK_RATE)
@@ -23,7 +23,7 @@
2323
$logger->info("Preparing game for launch, please wait...");
2424

2525
$game = ($debug ? GameFactory::createDebug() : GameFactory::createDefaultCompetitive());
26-
$game->loadMap($map);
26+
$game->loadMap(new $map);
2727

2828
$logger->info("Starting server on '{$bindAddress}', waiting maximum of '{$settings->warmupWaitSec}' sec for '{$playersMax}' player" . ($playersMax > 1 ? 's' : '') . " to connect.");
2929
$net = new ClueSocket($bindAddress);

0 commit comments

Comments
 (0)