Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/actions/artifact-name/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Artifact filename
description: Generate a branch or pull request artifact filename
inputs:
prefix:
description: Filename prefix
required: true
extension:
description: Filename extension
required: true
outputs:
name:
description: Generated artifact filename
value: ${{ steps.filename.outputs.name }}
runs:
using: composite
steps:
- id: filename
uses: actions/github-script@v9
env:
REF_NAME: ${{ github.ref_name }}
ARTIFACT_PREFIX: ${{ inputs.prefix }}
ARTIFACT_EXTENSION: ${{ inputs.extension }}
with:
script: |
const suffix = context.eventName === 'pull_request'
? `pr-${context.payload.pull_request.number}`
: process.env.REF_NAME.replace(/[^A-Za-z0-9._-]/g, '-');
core.setOutput('name', `${process.env.ARTIFACT_PREFIX}-${suffix}.${process.env.ARTIFACT_EXTENSION}`);
81 changes: 81 additions & 0 deletions .github/workflows/build-blakserv-linux-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Build Blakserv Linux x64

on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 30
outputs:
artifact_name: ${{ steps.artifact_name.outputs.name }}
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Set artifact filename
id: artifact_name
uses: ./.github/actions/artifact-name
with:
prefix: blakserv-linux-x64
extension: tar.gz

- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y g++ make flex bison libjansson-dev libpq-dev

- name: Build Blakserv and runtime data
run: make -f makefile.linux Bserver Bresource Bkod

- name: Package server runtime
env:
ARTIFACT_NAME: ${{ steps.artifact_name.outputs.name }}
run: |
server_dir=dist/blakserv-linux-x64
install -d "$server_dir/loadkod" "$server_dir/memmap" "$server_dir/rooms" \
"$server_dir/rsc" "$server_dir/channel" "$server_dir/savegame"
test -s run/server/loadkod/system.bof
test -s run/server/rsc/rsc0000.rsb
install -m 0755 blakserv/debug/blakserv "$server_dir/blakserv"
install -m 0755 run/server/blakadmin.sh "$server_dir/blakadmin.sh"
sed -i 's/\r$//' "$server_dir/blakadmin.sh"
install -m 0644 run/server/packages.txt run/server/blakston.khd \
run/server/protocol.khd run/server/kodbase.txt "$server_dir/"
cp -a run/server/loadkod/. "$server_dir/loadkod/"
cp -a run/server/memmap/. "$server_dir/memmap/"
cp -a run/server/rooms/. "$server_dir/rooms/"
cp -a run/server/rsc/. "$server_dir/rsc/"
tar -C "$server_dir" --exclude=.gitignore -czf "$ARTIFACT_NAME" .

- name: Upload Linux x64 artifact
uses: actions/upload-artifact@v7
with:
path: ${{ steps.artifact_name.outputs.name }}
archive: false
if-no-files-found: error
retention-days: ${{ github.event_name == 'pull_request' && 5 || 90 }}

cleanup-old-branch-artifacts:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
needs: build
permissions:
actions: write
uses: ./.github/workflows/cleanup-old-branch-artifacts.yml
with:
artifact-name: ${{ needs.build.outputs.artifact_name }}
127 changes: 127 additions & 0 deletions .github/workflows/build-blakserv-windows-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: Build Blakserv Windows x64

on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop
- master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
runs-on: windows-2022
timeout-minutes: 30
outputs:
artifact_name: ${{ steps.artifact_name.outputs.name }}
steps:
- name: Check out source
uses: actions/checkout@v4

- name: Set artifact filename
id: artifact_name
uses: ./.github/actions/artifact-name
with:
prefix: blakserv-windows-x64
extension: zip

- name: Set up MSBuild
uses: microsoft/setup-msbuild@v2

- name: Set up MSVC developer environment
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Build Blakserv and server KOD data
shell: pwsh
run: |
msbuild Meridian59.sln '/t:Server\blakserv;Server\blakod' /m:2 /nologo /p:Configuration=Release /p:Platform=x64 /p:BuildServerResources=false

- name: Package server runtime
shell: pwsh
env:
ARTIFACT_NAME: ${{ steps.artifact_name.outputs.name }}
run: |
$serverDir = "dist\blakserv-windows-x64"
$serverDirs = @("loadkod", "memmap", "rooms", "rsc", "channel", "savegame")
foreach ($directory in $serverDirs) {
New-Item -ItemType Directory -Force -Path (Join-Path $serverDir $directory) | Out-Null
}

foreach ($file in @("run\server\loadkod\system.bof", "run\server\rsc\rsc0000.rsb")) {
if (-not (Test-Path $file -PathType Leaf) -or (Get-Item $file).Length -eq 0) {
throw "Missing or empty generated server data: $file"
}
}
$serverFiles = @("blakadmin.sh", "packages.txt", "blakston.khd", "protocol.khd", "kodbase.txt")
foreach ($file in $serverFiles) {
Copy-Item (Join-Path "run\server" $file) $serverDir
}
foreach ($directory in @("loadkod", "memmap", "rsc")) {
$source = Join-Path "run\server" $directory
$destination = Join-Path $serverDir $directory
Copy-Item "$source\*" $destination -Recurse -Force
}
Copy-Item "blakserv\x64\Release\blakserv.exe" $serverDir
Copy-Item "blakserv\x64\Release\blakserv.map" $serverDir
Copy-Item "blakserv\x64\Release\blakserv.pdb" $serverDir

Copy-Item "resource\rooms\*.roo" (Join-Path $serverDir "rooms")

$runtimeDlls = @(
"libpq.dll",
"libcrypto-3-x64.dll",
"libintl-9.dll",
"libssl-3-x64.dll",
"libiconv-2.dll",
"libwinpthread-1.dll"
)
foreach ($dll in $runtimeDlls) {
$source = Join-Path "bin" $dll
if (-not (Test-Path $source)) {
throw "Missing runtime dependency: $source"
}
Copy-Item $source $serverDir
}

Get-ChildItem $serverDir -Filter ".gitignore" -File -Recurse -Force | Remove-Item -Force
Compress-Archive -Path "$serverDir\*" -DestinationPath $env:ARTIFACT_NAME -Force
Add-Type -AssemblyName System.IO.Compression.FileSystem
$archive = [System.IO.Compression.ZipFile]::Open((Join-Path (Get-Location) $env:ARTIFACT_NAME), [System.IO.Compression.ZipArchiveMode]::Update)
try {
foreach ($directory in $serverDirs) {
if (-not $archive.GetEntry("$directory/")) {
[void]$archive.CreateEntry("$directory/")
}
}
} finally {
$archive.Dispose()
}

- name: Upload Windows x64 artifact
uses: actions/upload-artifact@v7
with:
path: ${{ steps.artifact_name.outputs.name }}
archive: false
if-no-files-found: error
retention-days: ${{ github.event_name == 'pull_request' && 5 || 90 }}

cleanup-old-branch-artifacts:
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop'
needs: build
permissions:
actions: write
uses: ./.github/workflows/cleanup-old-branch-artifacts.yml
with:
artifact-name: ${{ needs.build.outputs.artifact_name }}
51 changes: 51 additions & 0 deletions .github/workflows/cleanup-old-branch-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Cleanup old branch artifacts

on:
workflow_call:
inputs:
artifact-name:
description: Name of the artifact to keep for the current branch
required: true
type: string

permissions:
actions: write

jobs:
cleanup:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- name: Keep only the latest branch artifact
uses: actions/github-script@v9
env:
ARTIFACT_NAME: ${{ inputs.artifact-name }}
with:
script: |
const branch = context.ref.replace(/^refs\/heads\//, "");
const repositoryId = context.payload.repository.id;
const currentRunId = Number(context.runId);
const artifacts = await github.paginate(
github.rest.actions.listArtifactsForRepo,
{
owner: context.repo.owner,
repo: context.repo.repo,
name: process.env.ARTIFACT_NAME,
per_page: 100,
},
(response) => response.data.artifacts,
);

const staleArtifacts = artifacts.filter((artifact) =>
artifact.workflow_run?.head_branch === branch &&
artifact.workflow_run?.head_repository_id === repositoryId &&
artifact.workflow_run?.id !== currentRunId
);

for (const artifact of staleArtifacts) {
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
});
}
2 changes: 1 addition & 1 deletion blakserv/blakserv.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ call "$(ProjectDir)copy_postgres_runtime.bat" "$(SolutionDir)bin" "$(SolutionDir
<ProjectReference Include="..\libjansson\jansson.vcxproj">
<Project>{f61a1cc1-dc47-4407-bfe0-a2221e5eecca}</Project>
</ProjectReference>
<ProjectReference Include="..\resource\resource.vcxproj">
<ProjectReference Include="..\resource\resource.vcxproj" Condition="'$(BuildServerResources)' != 'false'">
<Project>{15142a8c-248c-402a-90bf-c4b5c14cd8dc}</Project>
<Private>false</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
Expand Down
8 changes: 4 additions & 4 deletions kod/blakod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(ProjectDir)</OutDir>
<TargetName>blakdiff</TargetName>
<NMakeBuildCommandLine>nmake all
<NMakeBuildCommandLine>nmake all || exit /b 1
rmdir /S /Q $(ProjectDir)\vsbuildfolder &gt;nul 2&gt;&amp;1
</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake clean all
<NMakeReBuildCommandLine>nmake clean all || exit /b 1
rmdir /S /Q $(ProjectDir)\vsbuildfolder &gt;nul 2&gt;&amp;1</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake clean</NMakeCleanCommandLine>
<IntDir>$(ProjectDir)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(ProjectDir)</OutDir>
<TargetName>blakdiff</TargetName>
<NMakeBuildCommandLine>nmake all
<NMakeBuildCommandLine>nmake all || exit /b 1
rmdir /S /Q $(ProjectDir)\vsbuildfolder &gt;nul 2&gt;&amp;1
</NMakeBuildCommandLine>
<NMakeReBuildCommandLine>nmake clean all
<NMakeReBuildCommandLine>nmake clean all || exit /b 1
rmdir /S /Q $(ProjectDir)\vsbuildfolder &gt;nul 2&gt;&amp;1</NMakeReBuildCommandLine>
<NMakeCleanCommandLine>nmake clean</NMakeCleanCommandLine>
<IntDir>$(ProjectDir)</IntDir>
Expand Down
2 changes: 1 addition & 1 deletion kod/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ all :
@echo Copying .rsc files, creating server and client .rsb files
@-$(RM) $(BLAKSERVRUNDIR)\rsc\*.rsb >nul 2>&1
@-$(RM) $(CLIENTRUNDIR)\resource\*.rsb >nul 2>&1
-@$(RSCMERGE) $(BLAKSERVRUNDIR)\rsc\rsc0000.rsb $(BLAKSERVRUNDIR)\rsc
@$(RSCMERGE) $(BLAKSERVRUNDIR)\rsc\rsc0000.rsb $(BLAKSERVRUNDIR)\rsc
-@$(CP) $(BLAKSERVRUNDIR)\rsc\rsc0000.rsb $(CLIENTRUNDIR)\resource\ 2>&1

clean :
Expand Down
24 changes: 7 additions & 17 deletions makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,27 @@ TOPDIR=.
include common.mak.linux

# make ignores targets if they match directory names
.PHONY: all Bserver Bcompiler Bkod Butil Bresource clean

all: Bserver Bresource Bkod Butil

Bserver:
@echo Making $(COMMAND) in $(BLAKSERVDIR); \
cd $(BLAKSERVDIR); \
$(MAKE) -f makefile.linux $(COMMAND); \
cd ..
$(MAKE) -C $(BLAKSERVDIR) -f makefile.linux $(COMMAND)

Bcompiler:
@echo Making $(COMMAND) in $(BLAKCOMPDIR); \
cd $(BLAKCOMPDIR); \
$(MAKE) -f makefile.linux $(COMMAND); \
cd ..
$(MAKE) -C $(BLAKCOMPDIR) -f makefile.linux $(COMMAND)

Bkod: Bcompiler Butil
@echo Making $(COMMAND) in $(KODDIR); \
cd $(KODDIR); \
$(MAKE) -f makefile.linux $(COMMAND); \
cd ..
$(MAKE) -C $(KODDIR) -f makefile.linux $(COMMAND)

Butil:
@echo Making $(COMMAND) in $(UTILDIR); \
cd $(UTILDIR); \
$(MAKE) -f makefile.linux $(COMMAND); \
cd ..
$(MAKE) -C $(UTILDIR) -f makefile.linux $(COMMAND)

# Copy room files to server run directory (equivalent of Windows Bresource)
Bresource:
@echo Copying room files to server
@mkdir -p $(BLAKSERVRUNDIR)/rooms
-@$(CP) $(RESOURCEDIR)/rooms/*.roo $(BLAKSERVRUNDIR)/rooms/ 2>/dev/null
$(CP) $(RESOURCEDIR)/rooms/*.roo $(BLAKSERVRUNDIR)/rooms/

clean:
env COMMAND='clean' $(MAKE) -sf makefile.linux
Expand Down
Loading